`
Windows API: How transparent and flat buttons are drawn 2004-06-25 -- Robert Zaunere Newsgroups: sv.clarion.bugreports >Here's a two apps (in the attached zip file) that demonstrates the following >behavior. > >Two issues: > >1) See the attached image. >I'm not sure if this is a feature or a bug. >Here are two apps one in C55 and the other in C61 (CR3). Using Flat and >Transparent buttons in C61 gives quite a different effect. As the mouse >moves over the button it changes from being transparent to the grey-white >XP button color. > The TRN is overridden by the FLAT attribute when visual styles are active and the button becomes hot. I don't know how other products using flat buttons outside toolbars/toolboxes make them paint so we had to select how flat buttons are drawn if they are placed in the client area of a window when visual styles are active. If visual styles are active, MS is drawing the flat button face opaque. Because the entire MS toolbar is a single window and "controls" are just areas within a toolbar, applying the WS_EX_TRANSPARENT style to buttons is not possible. For owner draw flat buttons on toolbars in other products there are different variants but they are never transparent when hot, in best cases alpha blending is used. On the other hand, visual styles change the view of normal buttons and some their attributes or settings (e.g., font) are ignored by COMCTL32 and settings from the active theme file are used instead. Probably using a REGION to achieve this effect would be better: buttons controls require very complex drawing even if they transparent, and drawing of transparent buttons is very expensive because several additional device contexts must be used. In my opinion, there is nothing wrong in how the program works when visual styles are used. >2) The underscores are not automatically hidden if the users "Hide >underlined letters for keyboard navigation until I press the Alt key" >settings is set (Control Panel | Display | Appearance | Effects | Hide >underlined letters for keyboard navigation until I press the Alt key). > What happens is that Windows is sending WM_CHANGEUISTATE and WM_UPDATEUISTATE messages with the UIS_SET command, as expected, but the parameters of this command are not expected: UISF_HIDEACCEL (hide underlining of hot keys - expected) _and_ UISF_HIDEFOCUS (hide focus indicators - not expected). The RTL is passing both messages to COMCTL32 for the buttons which are drawn by Windows completely and it seems that Windows does not draw the focus rectangle in accordance with the set UI state. When the ALT key is pressed for the first time, Windows is sending WM_CHANGEUISTATE and WM_UPDATEUISTATE messages with the UIS_CLEAR command to all controls and windows and the focus rectangle is drawn by COMCTL32 again. Releasing or again pressing the ALT key does not set UI state back. We tried to work around this behavior to the extent possible. Regards, Robert Zaunere SoftVelocity Inc Printed November 21, 2024, 7:32 am This article has been viewed/printed 35326 times. Google search has resulted in 246 hits on this article since January 25, 2004. |