ActivateClient() or DoCommand("MinimiseProgram") bug?

Posted by Ked on Thu 10 Nov 2005 11:16 AM — 3 posts, 13,703 views.

Russia #0
I've found something strange when using the ActivateClient() callback. If I use it after doing DoCommand("MinimiseProgram") while the client frame is active, then my toolbars (which I have arranged on one line to preserve space) get stacked one on top of another. This is especially strange because if the client is already minimised when DoCommand("MinimiseProgram") is called, then the toolbars stay in place after the ActivateClient() call.

To put it into perspective: I have an external display with a close button. When the close button is clicked, it hides the display frame and sends Mushclient a command to minimise itself (the DoCommand() is executed by a plugin). To bring both Mushclient and the display back up, I can doubleclick a tray icon, which shows the display and commands Mushclient to re-surface (ActivateClient() is called by the same plugin). Now, if I click on some icon (e.g. Firefox) in the task bar to push Mushclient to the background, then click the display's close button, and doubleclick the display's tray icon, then all goes well. Same thing when I click Mushclient's minimize button and then repeat the same sequence of actions with the display. But when I just click the display's close button directly and then dclick the tray icon, the toolbars get screwed up.
Australia Forum Administrator #1
If I type this into the command window:

/DoCommand("MinimiseProgram")

Then everything seems OK. I think you have set up a sequence of events where the code that saves the toolbar positions is confused somehow by minimizing the program when it isn't active.

The code to do that is hidden away in the MFC (Microsoft Foundation Class) libraries, and will be hard to find. Can you work around it somehow by activating MUSHclient before minimizing it, or something?
Russia #2
Actually, it seems that the cause is in my display... in some weird way, as it's in no way connected to Mushclient other than through a UDP socket. But the only way to reproduce that bug is to transfer the focus from Mushclient's frame to my display's frame just as you click its' (the display's) Hide button. In other words - the focus has to shift from Mushclient to the display directly. If the display gains focus from anything other than Mushclient then all is fine.

And I don't even have a theory for why that works the way it does. Maybe MFC is indeed doing something, but it has to be doing something very strange it seems. Though now that I think about it, since I am using wxWidgets I am also using MFC, so it's MFC talking to MFC here. Looks like we did find a scapegoat :)