Well how to do it?
I have tryed to search for something like WM_SETCOLOR, but there is no such thing...
Help!
Well how to do it?
I have tryed to search for something like WM_SETCOLOR, but there is no such thing...
Help!
lu lu lu I've got some apples lu lu lu You've got some too lu lu lu Let's make some applesauce Take off our clothes and lu lu lu
Have you tried processing the WM_CTLCOLORBTN message? This is the message that the child window sends to the parent window procedure when the child window is about to paint its client area. The parent window can use this to alter the colors that the child window procedure will use for painting.
Good question, that I am also curious about.Originally Posted by ElastoManiac
I can change the color of an edit box, but I don't know how to change the color of a regular child window. (A few weeks ago I posted code to change the color of an edit box to red/blue by left/right mouse clicks)
A simple code example (non MFC) would be nice.
I have, and it works!Originally Posted by BobS0327
Thanks!
Heres How:
Code:case WM_CTLCOLORLISTBOX: SetBkColor((HDC)wParam, RGB(10,10,10)); SetTextColor((HDC)wParam, RGB(100,200,10)); return (LRESULT)CreateSolidBrush(RGB(10,50,10));
lu lu lu I've got some apples lu lu lu You've got some too lu lu lu Let's make some applesauce Take off our clothes and lu lu lu
Yes, but that would only work for list boxes. It's terrifyingly difficult to work out what you mean by a "child window". There are two types of child window: ones that use predefined classes supplied by the system and ones that use your own classes.
I take it that you meant ones that use predefined classes?
For a child window, I answered my own question:Originally Posted by SMurf
(left/right mouse clicks change the color of main or child windows)
Code:// basic window red, child window white; change background color on left/right mouse clicks //gcc prog.c -mwindows -o prog.exe #include <windows.h> HBRUSH hBrushR; HBRUSH hBrushG; HBRUSH hBrushB; HBRUSH hBrushW; LRESULT CALLBACK WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) { switch(msg) { case WM_LBUTTONDOWN: SetClassLong(hwnd,GCL_HBRBACKGROUND,(LONG) hBrushG); InvalidateRect(hwnd,NULL,TRUE); return 0; case WM_RBUTTONDOWN: SetClassLong(hwnd,GCL_HBRBACKGROUND,(LONG) hBrushB); InvalidateRect(hwnd,NULL,TRUE); return 0; case WM_DESTROY: PostQuitMessage (0); return 0; default: return DefWindowProc(hwnd,msg,wParam,lParam); } } int WINAPI WinMain(HINSTANCE hInst,HINSTANCE hPrev,LPSTR args,int nShow) { WNDCLASS wc = {0}; HWND M_hwnd; MSG msg; hBrushR = CreateSolidBrush(RGB(255,0,0)); // red hBrushG = CreateSolidBrush(RGB(0,255,0)); // green hBrushB = CreateSolidBrush(RGB(0,0,255)); // blue hBrushW = CreateSolidBrush(RGB(255,255,255)); // white wc.lpszClassName = "mainClass"; wc.style = CS_VREDRAW | CS_HREDRAW; wc.hInstance = hInst; wc.hbrBackground = hBrushR; wc.lpfnWndProc = WndProc ; wc.hCursor = LoadCursor(0,IDC_ARROW); RegisterClass(&wc); M_hwnd = CreateWindow("mainClass","test", WS_OVERLAPPEDWINDOW|WS_VISIBLE, 50,50,500,400, 0,0,hInst,0); wc.lpszClassName = "childClass"; wc.style = 0; wc.hInstance = hInst; wc.hbrBackground = hBrushW; wc.lpfnWndProc = WndProc ; wc.hCursor = LoadCursor(0,IDC_ARROW); RegisterClass(&wc); CreateWindow("childClass","", WS_CHILD|WS_BORDER|WS_VISIBLE, 50,50,50,50, M_hwnd,0,hInst,0); while( GetMessage(&msg,0,0,0) > 0) { TranslateMessage(&msg); DispatchMessage(&msg); } return (int)msg.wParam; }