Good morning
I have a question If its possible to Change whole color of a window frame including titlebar ?
Setsyscolors() must be responsible
The Background of winmain I can Change only Like black_brush white_brush etc
See my Code example
Oxygen
'http://msdn.microsoft.com/en-us/library/ms632598(VS.85).aspx
$ filename "t.exe"
includepath "$/inc/"
'#include "RTL32.inc"
'#include "RTL64.inc"
#include "MinWin.inc"
% ID_FIRSTCHILD 100
% ID_SECONDCHILD 101
% ID_THIRDCHILD 102
sys hinstance
sys hWndMain
'===================================
sys inst=GetModuleHandle 0
asciiz * cmdline
@cmdline=GetCommandLine
string szAppName="Hello 2Window"
string szconfirm="Confirm Quit"
'===================================
print "setsyscolors"
extern lib "user32.dll"
! SetSysColors
! SetSysColorsTemp
end extern
print "setsyscolors ok"
'Common RGB Colors
% BLACK 0x000000
% BLUE 0xFF0000
% GREEN 0x00FF00
% CYAN 0xFFFF00
% RED 0x0000FF
% MAGENTA 0xFF00FF
% YELLOW 0x00FFFF
% WHITE 0xFFFFFF
% GRAY 0x808080
% LTGRAY 0xC0C0C0
% TRANSPARENT 1
% OPAQUE 2
% WHITE_BRUSH 0
% LTGRAY_BRUSH 1
% GRAY_BRUSH 2
% DKGRAY_BRUSH 3
% BLACK_BRUSH 4
% HOLLOW_BRUSH 5
% NULL_BRUSH 5
% COLOR_ACTIVECAPTION 2
% COLOR_ACTIVEBORDER 10
function RGB(sys red,green,blue) as sys
sys color
color = red
color = color + green*256
color = color + blue*65536
return color
end function
'------------------------------------------------------------ -------
Function WinMain(sys inst, prevInst, asciiz*cmdline, sys show) as sys
'====================================================================
'
; window handle
dim a,b,c,style,hWnd as sys
dim wc as WndClass
dim wm as MSG
with wc '
.style=CS_HREDRAW or CS_VREDRAW
.lpfnWndProc=@wndproc
.cbClsExtra=0
.cbWndExtra=0
.hInstance=inst
.hIcon=LoadIcon 0, IDI_APPLICATION
.hCursor=LoadCursor 0,IDC_ARROW
.hbrBackground=GetStockObject DKGRAY_BRUSH ''BLACK_BRUSH ''WHITE_BRUSH '
.lpszMenuName=0
.lpszClassName=@"Wins"
end with
hinstance=inst
if not RegisterClass @wc
MessageBox 0,`Registration failed`,`Problem`,MB_ICONERROR
exit function
end if
style=WS_OVERLAPPEDWINDOW
style=WS_OVERLAPPEDWINDOW | // overlapped window
WS_HSCROLL | // horizontal scroll bar
WS_VSCROLL // vertical scroll bar
// Create the main window.
hwndMain = CreateWindowEx(
0, // no extended styles
"Wins", // class name
"Main Color Window", // window name '"Main Window"
style, //
CW_USEDEFAULT, // default horizontal position
CW_USEDEFAULT, // default vertical position
CW_USEDEFAULT, // default width
CW_USEDEFAULT, // default height
NULL, // no parent or owner window
NULL, // class menu used
hinstance, // instance handle
NULL); // no window creation data
// Show the window using the flag specified by the program
// that started the application, and send the application
// a WM_PAINT message.
hwnd=hwndMain
if not hWnd then
MessageBox 0,`Unable to create window`,`problem`,MB_ICONERROR
exit function
end if
'%COLOR_ACTIVEBORDER 10
' Change window frame color to black (adjust COLOR_ACTIVEBORDER for other parts of the frame)
'SetSysColors(1, @(COLOR_ACTIVEBORDER), @(RGB(0, 0, 0)))
'SetSysColors(hwnd, COLOR_ACTIVEBORDER, RGB(0,0,0)) 'winuser.h 10 'WM_SYSCOLORCHANGE
'---------------------------------------------------------------------------------- //
'how to set a new color to SetSysColor to window title bar and whole window frame?
'---------------------------------------------------------------------------------- //
'SetSysColors(hwnd, COLOR_ACTIVECAPTION, RGB(0,0,0)) 'winuser.h 10 'WM_SYSCOLORCHANGE
SetSysColors(hwnd, COLOR_ACTIVEBORDER, RGB(0,0,0))
'COLOR_CAPTIONTEXT COLOR_ACTIVECAPTION 2 Active window title bar
' foreground color is COloR-captiontext
'SetSysColors(2,aElements,aNewColors) '
'COLOR_WINDOW, COLOR_ACTIVECAPTION
'BOOL SetSysColors(
' int cElements,
' const int *lpaElements,
' const COLORREF *lpaRgbValues
');
ShowWindow hWnd,show
UpdateWindow hWnd
'
'MESSAGE LOOP
'
'do while GetMessage &wm,0,0,0
' TranslateMessage &wm
' DispatchMessage &wm
'wend
'
sys bRet
'
do while bRet := GetMessage (&wm, 0, 0, 0)
if bRet == -1 then
'show an error message?
else
TranslateMessage &wm
DispatchMessage &wm
end if
wend
'
'
function=wm.wparam
end function ; end of WinMain
WinMain inst,0,cmdline,SW_NORMAL
' end
dim cRect as rect
dim Paintst as paintstruct
dim hDC as sys
'------------------------------------------------------------------------------------
function WndProc(dword hwnd, dword uMsg, dword wParam, dword lParam) as long callback
'====================================================================================
{
RECT rcClient;
sys i,w,px,py,lx,ly,id,idmenu,style
string sty
select umsg
case WM_CREATE: // creating main window
// Create three child windows.
style=WS_CHILD | WS_BORDER | WS_VISIBLE
idmenu=0
py=10 : ly=480
;
for i = 0 to 1 '2
id=ID_FIRSTCHILD '+i
px=10+i*200 : lx=180
'
if i<2 then
sty="Edit"
elseif i=2 then
sty="graphic"
end if
'
w=CreateWindowEx(0,*sty, NULL, style, px,py,lx,ly, hwnd, id, inst, NULL);
next
return 0;
case WM_SIZE: // main window changed size
// Get the dimensions of the main window's client
// area, and enumerate the child windows. Pass the
// dimensions to the child windows during enumeration.
GetClientRect(hwnd, &rcClient);
EnumChildWindows(hwnd, & EnumChildProc, &rcClient);
return 0;
case WM_CLOSE:
// Create the message box. If the user clicks
// the Yes button, destroy the main window.
if (MessageBox(hwnd, *szConfirm, *szAppName, MB_YESNOCANCEL) == IDYES)
DestroyWindow(hwndMain);
else
return 0;
end if
case WM_DESTROY:
// Post the WM_QUIT message to
// quit the application terminate.
PostQuitMessage(0);
return 0;
end select
'
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
'-------------------------------------------------------------
function EnumChildProc(sys hwndChild, lParam) as bool callback
'=============================================================
{
RECT * rcParent;
sys i, idChild;
sys v,w,info
// Retrieve the child-window identifier. Use it to set the
// position of the child window.
info=GWL_ID
idChild = GetWindowLong(hwndChild, info)
if idChild == ID_FIRSTCHILD then
i = 0;
else if (idChild == ID_SECONDCHILD)
i = 1;
else
i = 2;
end if
// Size and position the child window.
& rcParent = lParam;
v=rcParent.right/3
w=v*i
MoveWindow(hwndChild, w, 0, v, rcParent.bottom, TRUE);
// Make sure the child window is visible.
ShowWindow(hwndChild, SW_SHOW);
return TRUE;
}
Help is Welcome thx
Frank
Hi Frank,
Apparently SetSysColors affects the display of all windows for the current session only:
https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getsyscolor
https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setsyscolors
Yes found all about setsyscolors / getsyscolors function in different Foren and saw a greeny window frame in another Python language with titlebar color changed too so I supposed this must Work with oxygen too :)
Perhaps you can Check my updated oxygen Code I think theres only a little Thing Missing thanks and U have learned a Lot about window Statements and features
'http://msdn.microsoft.com/en-us/library/ms632598(VS.85).aspx
$ filename "t.exe"
includepath "$/inc/"
'#include "RTL32.inc"
'#include "RTL64.inc"
#include "MinWin.inc"
% ID_FIRSTCHILD 100
% ID_SECONDCHILD 101
% ID_THIRDCHILD 102
sys hinstance
sys hWndMain
'===================================
sys inst=GetModuleHandle 0
asciiz * cmdline
@cmdline=GetCommandLine
string szAppName="Hello myWindow"
string szconfirm="Confirm Quit"
'===================================
'print "setsyscolors"
extern lib "user32.dll"
! GetSysColor
! GetSysColorBrush
! SetSysColors
! SetSysColorsTemp
end extern
'Common RGB Colors
% BLACK 0x000000
% BLUE 0xFF0000
% GREEN 0x00FF00
% CYAN 0xFFFF00
% RED 0x0000FF
% MAGENTA 0xFF00FF
% YELLOW 0x00FFFF
% WHITE 0xFFFFFF
% GRAY 0x808080
% LTGRAY 0xC0C0C0
% TRANSPARENT 1
% OPAQUE 2
% WHITE_BRUSH 0
% LTGRAY_BRUSH 1
% GRAY_BRUSH 2
% DKGRAY_BRUSH 3
% BLACK_BRUSH 4
% HOLLOW_BRUSH 5
% NULL_BRUSH 5
% COLOR_ACTIVECAPTION 2
% COLOR_ACTIVEBORDER 10
% COLOR_ACTIVECAPTION = 2
% COLOR_ACTIVEBORDER = 10
% COLOR_WINDOW = 5 'window background
% COLOR_WINDOWTEXT = 8
% COLOR_HOTLITE = 26
macro RGB(r,g,b) {r+(g<<8)+(b<<16)}
typedef dword COLORREF ' R G B bytes
function RGB(sys red,green,blue) as sys
sys color
color = red
color = color + green*256
color = color + blue*65536
return color
end function
'------------------------------------------------------------ -------
Function WinMain(sys inst, prevInst, asciiz*cmdline, sys show) as sys
'====================================================================
'
; window handle
dim a,b,c,style,hWnd as sys
dim wc as WndClass
dim wm as MSG
with wc '
.style=CS_HREDRAW or CS_VREDRAW
.lpfnWndProc=@wndproc
.cbClsExtra=0
.cbWndExtra=0
.hInstance=inst
.hIcon=LoadIcon 0, IDI_APPLICATION
.hCursor=LoadCursor 0,IDC_ARROW
.hbrBackground=GetStockObject DKGRAY_BRUSH ''BLACK_BRUSH ''WHITE_BRUSH '
.lpszMenuName=0
.lpszClassName=@"Wins"
end with
hinstance=inst
if not RegisterClass @wc
MessageBox 0,`Registration failed`,`Problem`,MB_ICONERROR
exit function
end if
style=WS_OVERLAPPEDWINDOW or WS_EX_CONTROLPARENT or WS_EX_WINDOWEDGE
style=WS_OVERLAPPEDWINDOW | // overlapped window
WS_HSCROLL | // horizontal scroll bar
WS_VSCROLL // vertical scroll bar
// Create the main window.
hwndMain = CreateWindowEx(
0, // no extended styles
"Wins", // class name
"Main Color Window", // window name '"Main Window"
style, //
CW_USEDEFAULT, // default horizontal position
CW_USEDEFAULT, // default vertical position
CW_USEDEFAULT, // default width
CW_USEDEFAULT, // default height
NULL, // no parent or owner window
NULL, // class menu used
hinstance, // instance handle
NULL); // no window creation data
// Show the window using the flag specified by the program
// that started the application, and send the application
// a WM_PAINT message.
hwnd=hwndMain
if not hWnd then
MessageBox 0,`Unable to create window`,`problem`,MB_ICONERROR
exit function
end if
ShowWindow hWnd,show
UpdateWindow hWnd
'
'MESSAGE LOOP
'
'do while GetMessage &wm,0,0,0
' TranslateMessage &wm
' DispatchMessage &wm
'wend
'
sys bRet
'
do while bRet := GetMessage (&wm, 0, 0, 0)
if bRet == -1 then
'show an error message?
else
TranslateMessage &wm
DispatchMessage &wm
end if
wend
'
'
function=wm.wparam
end function ; end of WinMain
WinMain inst,0,cmdline,SW_NORMAL
' end
dim cRect as rect
dim Paintst as paintstruct
dim hDC as sys
'extern "user32.dll"
'function GetSysColor (nIndex as integer) as dword
'end extern
% COLOR_ACTIVECAPTION = 2
% COLOR_WINDOW = 5
declare function SetSysColors lib "User32.dll" alias "SetSysColors" _
(byval nChanges as long, byval lpSysColor as long , _
byval lpColorValues as sys) as long
'------------------------------------------------------------------------------------
function WndProc(dword hwnd, dword uMsg, dword wParam, dword lParam) as long callback
'====================================================================================
{
RECT rcClient;
sys i,w,px,py,lx,ly,id,idmenu,style
string sty
select umsg
'-------------------------------------------------------- //
' in winmain() all ok
' .hbrBackground=GetStockObject DKGRAY_BRUSH
'
case WM_CREATE // creating main window
string s
dim aElements(1) as integer
dim aOldColors(1) as sys
dim newColor as COLORREF
aElements(0) = COLOR_WINDOW
aElements(1) = COLOR_ACTIVECAPTION
' Retrieve current colors
aOldColors(0) = GetSysColor(COLOR_WINDOW)
aOldColors(1) = GetSysColor(COLOR_ACTIVECAPTION)
' Modify the colors as needed
'newColor = RGB(255, 255, 255) ' dark purple
newColor = RGB(255, 5, 5) ' red purple
' Set the new colors
s=SetSysColors(2, aElements(0), newColor)
return 0 ' Successful creation
'-------------------------------------------------------- //
// Create three child windows.
style=WS_CHILD | WS_BORDER | WS_VISIBLE
idmenu=0
py=10 : ly=480
;
for i = 0 to 1 '2
id=ID_FIRSTCHILD '+i
px=10+i*200 : lx=180
'
if i<2 then
sty="Edit"
elseif i=2 then
sty="graphic"
end if
'
w=CreateWindowEx(0,*sty, NULL, style, px,py,lx,ly, hwnd, id, inst, NULL);
next
return 0;
case WM_SIZE: // main window changed size
// Get the dimensions of the main window's client
// area, and enumerate the child windows. Pass the
// dimensions to the child windows during enumeration.
GetClientRect(hwnd, &rcClient);
EnumChildWindows(hwnd, & EnumChildProc, &rcClient);
return 0;
case WM_CLOSE:
// Create the message box. If the user clicks
// the Yes button, destroy the main window.
if (MessageBox(hwnd, *szConfirm, *szAppName, MB_YESNOCANCEL) == IDYES)
DestroyWindow(hwndMain);
else
return 0;
end if
case WM_DESTROY:
// Post the WM_QUIT message to
// quit the application terminate.
PostQuitMessage(0);
return 0;
end select
'
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
'-------------------------------------------------------------
function EnumChildProc(sys hwndChild, lParam) as bool callback
'=============================================================
{
RECT * rcParent;
sys i, idChild;
sys v,w,info
// Retrieve the child-window identifier. Use it to set the
// position of the child window.
info=GWL_ID
idChild = GetWindowLong(hwndChild, info)
if idChild == ID_FIRSTCHILD then
i = 0;
else if (idChild == ID_SECONDCHILD)
i = 1;
else
i = 2;
end if
// Size and position the child window.
& rcParent = lParam;
v=rcParent.right/3
w=v*i
MoveWindow(hwndChild, w, 0, v, rcParent.bottom, TRUE);
// Make sure the child window is visible.
ShowWindow(hwndChild, SW_SHOW);
return TRUE;
}
The Code is running Well but Not with the changed window frame color ... Perhaps at a later Moment I will get the solution
A lot a sys color options are not supported in windows 10 / 11
https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getsyscolor
QuoteCOLOR_WINDOWFRAME
6
Window frame.
Windows 10 or greater: This value is not supported.