Page 1 of 1

Posted: Thu Oct 10, 2002 12:05 am
by BackupUser
Restored from previous forum. Originally posted by scurrier.

Anyone have a working example on how to use setsyscolor_() to change the background color of a window


Thanks
Sean

Posted: Thu Oct 10, 2002 3:12 am
by BackupUser
Restored from previous forum. Originally posted by SoulTaker.

SetSysColors
The SetSysColors function sets the colors for one or more display elements. Display elements are the various parts of a window and the display that appear on the system display screen.

BOOL SetSysColors(
int cElements, // number of elements
CONST INT *lpaElements, // array of elements
CONST COLORREF *lpaRgbValues // array of RGB values
);
Parameters
cElements
[in] Specifies the number of display elements in the array pointed to by the lpaElements parameter.
lpaElements
[in] Pointer to an array of integers that specify the display elements to be changed. For a list of display elements, see GetSysColor.
lpaRgbValues
[in] Pointer to an array of COLORREF values that contain the new red, green, blue (RGB) color values for the display elements in the array pointed to by the lpaElements parameter. To generate a COLORREF, use the RGB macro.
Return Values
If the function succeeds, the return value is a nonzero value.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks
The SetSysColors function sends a WM_SYSCOLORCHANGE message to all windows to inform them of the change in color. It also directs the system to repaint the affected portions of all currently visible windows.

The SetSysColors function changes the current session only. The new colors are not saved when the system terminates.

Requirements
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Winuser.h; include Windows.h.
Library: Use User32.lib.

See Also
System Information Overview, System Information Functions, GetSysColor , COLORREF, RGB

WM_SYSCOLORCHANGE
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
);
Parameters
This message has no parameters.

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.

Requirements
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Winuser.h; include Windows.h.

See Also
Colors Overview, Color Messages, WM_PAINT



Abit BD7-II Raid P4 1.9 gHz 384 Ram Xtasy GFroce 3 TI 200 CD-RW DirectX 9.0 Beta 3 Sound Blaster Live! XP Pro, Registered PureBasic version 3.30 For Windows.

Posted: Thu Oct 10, 2002 5:11 am
by BackupUser
Restored from previous forum. Originally posted by Danilo.

scurrier:
You can use the commands SetWinBackgroundColor() and
SetWinBackgroundImage() from my SkinWin Library to
do what you want.
http://www.reelmediaproductions.com/pb/ ... nwin10.zip on http://www.reelmediaproductions.com/pb/

SetSysColor_() sets the SYSTEM COLORS (the command name says all).
For setting the color for your Window, you simply use
CreateBrushIndirect_() and SetClassLong_() ... its the same
what SetWinBackgroundColor() does.

SoulTaker:
Is it really needed to post this public documentation here ??
Everybody can read this in the help files of the free
MS Platform SDK or on MSDN (every API programmer has this).
We generally post more code and hand-written answers here
instead only cut and paste some documentation only.
Just a thought... no offense :)


cya,
...Danilo

(registered PureBasic user)

Posted: Thu Oct 10, 2002 6:07 am
by BackupUser
Restored from previous forum. Originally posted by PB.
Is it really needed to post this public documentation here ??
Everybody can read this in the help files of the free
MS Platform SDK or on MSDN (every API programmer has this).
We generally post more code and hand-written answers here
instead only cut and paste some documentation only.
Just a thought... no offense :)
I agree with you Danilo... no offense, SoulTaker, but you didn't post
a working example as requested. :) Your intentions are good, we know.


PB - Registered PureBasic Coder

Posted: Thu Oct 10, 2002 6:08 am
by BackupUser
Restored from previous forum. Originally posted by SoulTaker.

Sorry Danilo,

I'll Refrain from those long posts, was just trying to give him some information.

But I do see your point no problem and thanks for letting me know.



Abit BD7-II Raid P4 1.9 gHz 384 Ram Xtasy GFroce 3 TI 200 CD-RW DirectX 9.0 Beta 3 Sound Blaster Live! XP Pro, Registered PureBasic version 3.30 For Windows.

Posted: Thu Oct 10, 2002 6:59 am
by BackupUser
Restored from previous forum. Originally posted by blueb.

Danilo,
I've been playing with your SkinWin Library and have
been able to get the Window background to work (Win XP Pro).
As you can see from the snippet:
-Frame gadget backgrounds don't work
-Panels work
-Textgadgets BG do not work

Ideas?

--blueb

Code: Select all

; ================================================================================
;Quick cut and paste...sorry

hWnd = OpenWindow(0, 100, 120, 400, 370, #PB_Window_MinimizeGadget, "PureBasic")
;works <-------------------
SetWinBackgroundColor(hWnd, RGB( 209, 209, 224)) 
  
 If CreateGadgetList(WindowID())
    ; doesn't work <-------------------
    hFrame = Frame3DGadget(13, 10, Top, 370, 330, " Select: ", 0)
    SetWinBackgroundColor(hFrame, RGB( 209, 209, 224))
    ; works <-------------------
    hPanel = PanelGadget(3, 20, 20, 350, 300)
    SetWinBackgroundColor(hPanel, RGB( 209, 209, 224))
    ; doesn't work <-------------------
    hText = TextGadget  (9, 10, 335, 240, 18, "File Names:")
    SetWinBackgroundColor(hText, RGB( 209, 209, 224)) 

     
      AddGadgetItem(3, 0, "Sample 1")
        ListViewGadget(99, 6, 10, 280, 180, #LBS_SORT | #LBS_NOINTEGRALHEIGHT | #LBS_HASSTRINGS)
      AddGadgetItem(3, 1, "Sample 2")
         ListViewGadget(98, 6, 10, 280, 180, #LBS_SORT | #LBS_NOINTEGRALHEIGHT | #LBS_HASSTRINGS)
      AddGadgetItem(3, 2, "Other")
  
    ClosePanelGadget()
    ButtonGadget(15, 300, 335, 80, 24, "Quit")
 
  EndIf
  
; ====================== Windows Event Loop ======================== 
  Repeat
    EventID = WaitWindowEvent()
    If EventID = #PB_EventGadget
      Select EventGadgetID()
        Case 15 ; Quit...
          EventID = #PB_EventCloseWindow
      EndSelect
    EndIf
  Until EventID = #PB_EventCloseWindow
End ; Exit Program

Posted: Thu Oct 10, 2002 7:15 am
by BackupUser
Restored from previous forum. Originally posted by Danilo.

blueb:
This works for Windows Backgrounds, not Gadgets generally.
For Gadgets (ListView etc..) many ppl including myself
have posted some examples on this forum (all API).
I thought setting the Windows background was requested here, sorry... :cry:

SoulTaker:
Its not ment to be offensive, its just a thought.
I know you want to help and thats really nice !!
I just thought writing a nice little answer by
hand makes the atmosphere here better (like it is).
I dont say "dont do this!"... its your thing and
i respect your work. Thanks!

cya,
...Danilo
(registered PureBasic user)

Posted: Sun Oct 13, 2002 4:07 pm
by BackupUser
Restored from previous forum. Originally posted by scurrier.

Thanks to everyone for all your help

Sean