I'm working on an astronomy application in which I want a "night vision" option which turns all windows and objects to a monochrome dark red. I have been unable to change the gray background of messageboxes and other dialogs. Everything else I can change. What parameter is it or is there some other trick?
Announcement
Collapse
No announcement yet.
SetSysColor
Collapse
X
-
There is a %WM_CTLCOLORMSGBOX message designed to work with MessageBox() dialogs (not MSGBOX, as the parent is not able to be specified with MSGBOX). However, this message does not seem to work, and I remember seeing some discussion in MSDN on it. {later} Yep, this message is obsolete in Win32... see http://msdn.microsoft.com/library/ps...boxes_4ud4.htm
Therefore the best solution is to use your own (DDT) dialogs and handle the %WM_ERASEBKGND or %WM_PAINT event yourself, and fill the client area with the color you want (FillRect). Be sure to add the %WS_CLIPCHILDREN style to all child controls.
If you already have your callback functions, this will take almost no time at all to add. Replacing MSGBOX() and MessageBox() calls may take a little longer.
------------------
Lance
PowerBASIC Support
mailto:[email protected][email protected]</A>Lance
mailto:[email protected]
-
Maybe one of the button face equates ?
Code:'----------------------------------------------- '*choose item which the color is to be changed '----------------------------------------------- case %IDC_ACTIVEBORDER DspElements(0) = %COLOR_ACTIVEBORDER case %IDC_ACTIVECAPTION DspElements(0) = %COLOR_ACTIVECAPTION case %IDC_APPWORKSPACE DspElements(0) = %COLOR_APPWORKSPACE case %IDC_BACKGROUND DspElements(0) = %COLOR_BACKGROUND case %IDC_BTNFACE DspElements(0) = %COLOR_BTNFACE case %IDC_BTNSHADOW DspElements(0) = %COLOR_BTNSHADOW case %IDC_BTNTEXT DspElements(0) = %COLOR_BTNTEXT case %IDC_CAPTIONTEXT DspElements(0) = %COLOR_CAPTIONTEXT case %IDC_GRAYTEXT DspElements(0) = %COLOR_GRAYTEXT case %IDC_HIGHLIGHT DspElements(0) = %COLOR_HIGHLIGHT case %IDC_HIGHLIGHTTEXT DspElements(0) = %COLOR_HIGHLIGHTTEXT case %IDC_INACTIVEBORDER DspElements(0) = %COLOR_INACTIVEBORDER case %IDC_INACTIVECAPTION DspElements(0) = %COLOR_INACTIVECAPTION case %IDC_MENU DspElements(0) = %COLOR_MENU case %IDC_MENUTEXT DspElements(0) = %COLOR_MENUTEXT case %IDC_SCROLLBAR DspElements(0) = %COLOR_SCROLLBAR case %IDC_WINDOW DspElements(0) = %COLOR_WINDOW case %IDC_WINDOWFRAME DspElements(0) = %COLOR_WINDOWFRAME case %IDC_WINDOWTEXT DspElements(0) = %COLOR_WINDOWTEXT '*get new RGB values RgbValues(0) = RGB(RGBV(0), RGBV(1), RGBV(2)) '*change system color Call SetSysColors(1, VarPtr(DspElements(0)), VarPtr(RgbValues(0)))
Regards, mailto:[email protected][email protected]</A>
[This message has been edited by Jules Marchildon (edited June 14, 2000).]
Comment
-
Okay, you can see I am struggling here. O'Dear, Just shoot me!
The WM_SYSCOLORCHANGE message is sent to all top-level windows when a change is made to a system color setting.
A window receives this message through its WindowProc function.
LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // WM_SYSCOLORCHANGE
WPARAM wParam, // not used
LPARAM lParam // not used
);
Applications that have brushes using the existing system colors should delete those brushes and recreate them
using the new system colors.
I still like to know how you got the SetSysColor function to work.
Thanks! Jules
Comment
-
Brent, Jules,
I did some test myself trying to change system colors using something like that:
Code:GLOBAL OriginalColors&(), NewColors&(), ColorArray&()
Code:DIM OriginalColors&(25), NewColors&(25), ColorArray&(25) FOR K& = 0 TO 25 OriginalColors&(K&) = GetSysColor(K&): ColorArray&(K&) = K& NewColors&(K&) = OriginalColors&(K&) NEXT NewColors&(%COLOR_BTNSHADOW) = skGetSysColor(%SKCOLOR_WINDOW) NewColors&(%COLOR_HIGHLIGHTTEXT) = skGetSysColor(%SKCOLOR_HILITETEXT NewColors&(%COLOR_HIGHLIGHT) = skGetSysColor (%SKCOLOR_HILITEBACK) NewColors&(%COLOR_BTNHIGHLIGHT) = skGetSysColor(%SKCOLOR_WINDOWTEXT) Fore& = skGetSysColor(%SKCOLOR_WINDOWTEXT) Back& = skGetSysColor(%SKCOLOR_WINDOW) IF Fore& > Back& THEN SWAP Fore&, Back& NewColors&(%COLOR_INFOTEXT) = Fore& NewColors&(%COLOR_INFOBK) = Back& CALL SetSysColors(25, ColorArray&(0), NewColors&(0))
Code:CALL SetSysColors(25, ColorArray&(0), OriginalColors&(0))
------------------
Patrice Terrier
mailto[email protected][email protected]</A>
Patrice Terrier
www.zapsolution.com
www.objreader.com
Addons: GDImage.DLL 32/64-bit (Graphic library), WinLIFT.DLL 32/64-bit (Skin Engine).
Comment
-
In my previous message change the skGetSysColor function by any RGB value of your own.
------------------
Patrice Terrier
mailto[email protected][email protected]</A>
Patrice Terrier
www.zapsolution.com
www.objreader.com
Addons: GDImage.DLL 32/64-bit (Graphic library), WinLIFT.DLL 32/64-bit (Skin Engine).
Comment
-
I think that more or less correct place, where to change system colors is %WM_ACTIVATEAPP event, something like this.
Code:#Compile Exe #Register None #Dim All #Include "win32api.INC" Sub GetSetSysColors (Tp As Long) %COLOR_GRADIENTACTIVECAPTION = 27 Static Clr1 As Long, Clr2 As Long, clr3 As Long If Tp = 0 Then Clr1 = GetSysColor (%COLOR_ACTIVECAPTION) Clr2 = GetSysColor (%COLOR_GRADIENTACTIVECAPTION) Clr3 = GetSysColor (%COLOR_BTNFACE) ElseIf Tp = 1 Then SetSyscolors 1, %COLOR_ACTIVECAPTION, %Red SetSyscolors 1, %COLOR_GRADIENTACTIVECAPTION, %Green SetSyscolors 1, %COLOR_BTNFACE, %Cyan ElseIf Tp = 2 Then SetSyscolors 1, %COLOR_ACTIVECAPTION, Clr1 SetSyscolors 1, %COLOR_GRADIENTACTIVECAPTION, Clr2 SetSyscolors 1, %COLOR_BTNFACE, Clr3 End If End Sub CallBack Function DlgProc Select Case CbMsg Case %WM_INITDIALOG Control Add Button, CbHndl, %IDOK, "&Ok", 50, 10, 100, 14 Case %WM_ACTIVATEAPP If CbWparam Then GetSetSysColors 1 Else GetSetSysColors 2 End Select End Function Function PbMain Local hDlg As Long GetSetSysColors 0 Dialog New 0, "SysColor", , , 200, 30, %WS_SYSMENU Or %WS_MINIMIZEBOX Or _ %WS_MAXIMIZEBOX Or %WS_CAPTION Or %WS_THICKFRAME To hDlg Dialog Show Modal hDlg, Call DlgProc GetSetSysColors 2 End Function
------------------
Comment
-
Semen,
>> But in general I don't like apps, which change common resources.
I don't like it either, it is why for those using the WinLIFT Pro Edition the part that does handle it has been REMed out.
------------------
Patrice Terrier
mailto[email protected][email protected]</A>
Patrice Terrier
www.zapsolution.com
www.objreader.com
Addons: GDImage.DLL 32/64-bit (Graphic library), WinLIFT.DLL 32/64-bit (Skin Engine).
Comment
Comment