I stumbled across a really weird behavior recently. When I use a TActionMainMenuBar (or a TActionToolBar) in my program, compile and run, and then start Photoshop CS5 or Internet Explorer 9, the ActionMainMenuBar (and ActionToolBar) loses all its settings. The colors defined in the assigned colormap disappear and the font settings are also lost. Has anyone seen this before and knows a workaround?
D2007 Pro (all updates applied), D2010 Pro (all updates applied), Vista Home Premium 32 bit, NVidia GForce 8600 GT, latest driver installed.
Steps to reproduce:
- Drop a TActionManager and a TActionMainMenuBar on a form
- Create a category with some menu items
- Drag category onto ActionMainMenuBar
- Assign TwilightColorMap to the ActionMainMenuBar
- Run program
- Start IE9 or Photoshop CS5
- Watch all predefined settings disappear (you have to close IE9 again to see the effect)
If you start Photoshop or IE first and then the Delphi program, nothing happens. The bug is also present when in design mode in the IDE. A fellow developer has already confirmed the described behavior for his system with Win7 Pro 32bit and a ATI Radeon 9800 Pro.
Thx for any comments/ solutions
Phil
PS: Using Photoshop CS3 doesn’t produce this bug
Here’s one other way of reproducing the problem:
Perform(WM_SETTINGCHANGE, 0, 0);in its click handler.So now we know that a
WM_SETTINGCHANGEbroadcast might be causing the problem, we might wonder if launching IE produces the same:After we run our application and then launch IE, a few seconds later the below appears in the memo:
I have no idea what IE has to say to our form (and all other top-level windows) at every launch, and I don’t know if it is doing this on every Windows box on earth or just yours and mine, but evidently the
ActionMainMenuBaris no good at handling it.A win control (the form), receiving a
WM_WININICHANGE, performs aCM_WININICHANGEand upon receiving it broadcasts the same to all its controls. The below is how it is handled by the menu bar:Thinking that the system menu font could have been changed (the code should have looked for a ‘WindowsThemeElement’ or ‘WindowMetrics’ section in the message, but anyway..), it is reassigned from the refreshed
Screen.MenuFont. The problem is, we weren’t exactly using it.Additionally the ColorMap responds to a
CM_WININICHANGEby resetting its colors by calling itsUpdateColorsmethod. This is even documented:So the solution would involve deciding what to do and overriding both behavior, I tried to comment the below solution for why I believe that it would be the correct solution: