Click to See Complete Forum and Search --> : How to use SetClassLong ?


Andris Spruds
May 29th, 1999, 02:21 AM
Hello,
I'm trying to write a program that will change Windows appearence. But just hanged
up with basics - how to change windows class background for local app
(using SetClassLong), for example I want all buttons created in my app to be red.
Any advices ?
I use the following code (without success, of course) :

const COLORREF RED = RGB(255,0,0);
HBRUSH B = CreateSolidBrush(RED);
HWND hwnd;
hwnd = CreateWindow(
"BUTTON", // name of window class
"Sample", // title-bar string
WS_OVERLAPPEDWINDOW, // top-level window
10, // default horizontal position
10, // default vertical position
100, // default width
100, // default height
(HWND) NULL, // no owner window
(HMENU) NULL, // use class menu
AfxGetInstanceHandle(), // handle of application instance
(LPVOID) NULL); // no window-creation data
SetLastError(0);
DWORD dwresult;
dwresult=::SetClassLong(hwnd,GCL_HBRBACKGROUND,(LONG)B);
if (dwresult==0) {
AfxMessageBox("Error");
}
else {
AfxMessageBox("OK");
}

DangCongWei
May 31st, 1999, 04:45 AM
Hello:
I tried to changed the static-control's background brush and failed,
perhaps the controls draw themselves without the class's brushes but others.
If you want to change the button-controls, try to use own-draw,
it should work.



Best Regards!

Andris Spruds
May 31st, 1999, 10:21 AM
No, it's impossible. I'm trying to subclass window in another application.

Thanks,
Andris