Jump to content
  • Advertisement
Sign in to follow this  
derek7

SetClassLong not work with CDialog

This topic is 4522 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

SetClassLong(dlg.GetSafeHwnd(),GCL_HBRBACKGROUND,(long)GetStockObject(WHITE_BRUSH)); why?

Share this post


Link to post
Share on other sites
Advertisement
What exactly are you trying to accomplish? What makes you say this "doesn't work"? Are you getting an error result from SetClassLong? Are you getting a crash or other failure? Are you simply not getting the results you expect?

Share this post


Link to post
Share on other sites
Quote:
Original post by ApochPiQ
What exactly are you trying to accomplish? What makes you say this "doesn't work"? Are you getting an error result from SetClassLong? Are you getting a crash or other failure? Are you simply not getting the results you expect?


yes I simply not getting the result. the dialog background color is still unchhanged.

Share this post


Link to post
Share on other sites
Quote:
Original post by Mike2343
Have you checked GetLastError()?

Post more code, likely help us.


yes ,it return 0;

source code here

HWND h = AfxGetMainWnd()->GetSafeHwnd(); // main window is dialog
DWORD d = SetClassLong(h,GCL_HBRBACKGROUND,(long)GetStockObject(WHITE_BRUSH)); // not work

CWnd *cc = AfxGetMainWnd();


MoveWindow(103,13,777,888);


if (c.Create(AfxRegisterWndClass(
CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW,
AfxGetApp()->LoadStandardCursor(IDC_ARROW),
(HBRUSH)GetStockObject(WHITE_BRUSH),
NULL),
NULL,WS_VISIBLE,
CRect(0,0,0,0),cc,11,NULL)==FALSE)
return false;
SetClassLong(c.GetSafeHwnd(),GCL_HBRBACKGROUND,(long)GetStockObject(GRAY_BRUSH)) ; // work



Share this post


Link to post
Share on other sites
Read the documentation I linked you to. It explicitly mentions exactly what you are doing and exactly why it does not work as you expect.

Share this post


Link to post
Share on other sites
if (c.CreateEx(
WS_EX_TOPMOST,
AfxRegisterWndClass(
CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW,
AfxGetApp()->LoadStandardCursor(IDC_ARROW),
(HBRUSH)GetStockObject(WHITE_BRUSH),
NULL),
NULL,
WS_VISIBLE,
CRect(0,0,0,0),
0,
11,
NULL)==0)
{
int i = GetLastError();
::MessageBox(0,"tetse",0,0);
return false;
}



another question : how can GetLastError() return 0?????

Share this post


Link to post
Share on other sites
I'm not sure what you're trying to achieve. Why register a new window class with one background colour then promptly try and change it to another background colour??? Referring back to the original title you need to process WM_CTLCOLOR to change the background colour of a dialog...

Jans.

Share this post


Link to post
Share on other sites
Quote:
Original post by Jansic
I'm not sure what you're trying to achieve. Why register a new window class with one background colour then promptly try and change it to another background colour??? Referring back to the original title you need to process WM_CTLCOLOR to change the background colour of a dialog...

Jans.


I just experience the function for exercise. the question still confuse me.
why CreateEx fail and why GetLastError return 0 when CreateEx fail?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!