0

I have a small application that needs to update GUI elements if some event occurs in lower levels, say, socket goes off-line, or something like that.

In Windows, I could use PostMessage which would be sent through the chain to all Windows, and the required ones could update accordingly.

How can I achieve something similar in wxWidgets? I cannot use OnUpdateUI, or something like that, because some controls doesn't seem to handle that at all.

The target window could be one or multiple, they could be frames or controls, so I'm confused a little here.

Does anyone have a suggestion?

Coder
  • 3,405
  • 5
  • 25
  • 40

2 Answers2

3

First, all controls do receive EVT_UPDATE_UI so you could use it for this and it's a very simple of doing it -- but also the most inefficient, so definitely not recommended for something like socket event processing (it's fine for checking whether the socket is connected or not though).

Second, the exact equivalent of Windows ::PostMessage() is wxQueueEvent() (which used to be called as wxPostEvent() actually but the new version is preferable). wxQueueEvent() is thread-safe in the sense that it can be used from a secondary thread to post an event to a GUI control managed by the main thread.

VZ.
  • 18,498
  • 3
  • 33
  • 39
1

You can use the same approach as in Win32 apps. You can create the custom event class and send it to windows using wxPostEvent function. There are some docs regarding this.

Not sure what you mean about wxUpdateUIEvent - from my experience it works pretty fine. What controls do not receive it? Did you add EVT_UPDATE_UI() macro to event table?

T-Rex
  • 870
  • 1
  • 5
  • 19