How to define custom message without conflict


#1

Hi there,

I’ve just started to use Message and overriding handleMessage() in my custom component.

I want to send a massage from thread which let component should repaint(), TableListBox::updateContents(), etc.

Message can take four arguments but there are no restrictions. How should I define the “magic number” for my custom messages? Are there any similarities to WM_USER in WIN32 API?

Cheers,
Masa


#2

There aren’t any predefined numbers, though it’s unlikely you’ll cause a conflict. If you’re worried, you can also use a subclass of Message that contains whatever data you want, then try to dynamic_cast the incoming message to this class to see if it’s one of yours.


#3

Do you mean I always should use the pointer argument and pass “this” pointer and use dynamic cast?

Best regards,
Masanao Hayashi


#4

No, I mean you can actually post an object that’s a subclass of Message, and make that contain anything you want.


#5

Ah! Gotcha! :smiley:

It’s nice, I wanted to send Uuid to some components but I couldn’t find the good way to do. Subclassing Message class makes easy to do too.

Thanks!

Best regards,
Masanao Hayashi