Re: Responding to system color changes
- Posted by Elliott Sales de Andrade <quantum_analyst at hotmail.com> Mar 14, 2003
- 411 views
According to MSDN, the message for this is WM_SYSCOLORCHANGE. Here are some of the remarks... -=- The system sends a WM_PAINT message to any window that is affected by a system color change. Applications that have brushes using the existing system colors should delete those brushes and recreate them using the new system colors. Top level windows that use common controls must forward the WM_SYSCOLORCHANGE message to the controls; otherwise, the controls will not be notified of the color change. This ensures that the colors used by your common controls are consistent with those used by other user interface objects. For example, a toolbar control uses the "3D Objects" color to draw its buttons. If the user changes the 3D Objects color but the WM_SYSCOLORCHANGE message is not forwarded to the toolbar, the toolbar buttons will remain in their original color while the color of other buttons in the system changes. -=- So, what would be needed is to recreate any system brushes that win32lib might have and SendMessage() the WM_SYSCOLORCHANGE notification to all common controls. >From: Jonas Temple <jtemple at yhti.net> >Reply-To: EUforum at topica.com >To: EUforum <EUforum at topica.com> >Subject: Responding to system color changes >Date: Fri, 14 Mar 2003 16:30:28 +0000 > > >I know this is trivial, but if a user changes the system color scheme >within Windows while your win32lib based program is running, the >background colors for all your controls are the same as when the program >started. Not a big deal, but it would be nice if win32lib based >programs responded to these color changes like other Windows programs. > >To that end, I submit the following routine that I use. The beauty is >you don't have to code all the controls to be changed, the routine will >change all child windows/controls based on the passed parent. So if you >have a main window with several child windows and they have controls and >child windows and so on, this routine will work. > > >procedure setChildColor(integer parent, atom color) > sequence children > > children = findChildren(parent) > for i = 1 to length(children) do > if children[i][2] = Window then > setWindowBackColor(children[i][1], color) > end if > if >find(children[i][2],{PushButton,DefPushButton,LText,Radio,CheckBox}) >then > setWindowBackColor(children[i][1], color) > elsif children[i][2]=Group then > setWindowBackColor(children[i][1],color) > setChildColor(children[i][1],color) > else > setChildColor(children[i][1], color) > end if > end for > >end procedure > >In context, here's how I use it: > >atom cur_color > >procedure Main_onPaint (integer self, integer event, sequence >params)--params is ( int x1, int y1, int x2, int y2 ) > object color > color = getSysColor(COLOR_BTNFACE) > if color != cur_color then > cur_color = color > setWindowBackColor(Main, color) > setChildColor(Main, color) > end if >end procedure >setHandler( Main, w32HPaint, routine_id("Main_onPaint")) > > > >TOPICA - Start your own email discussion group. FREE!