CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2004
    Location
    Philippines
    Posts
    31

    How to change Dialog Background Color

    I created a dialog using MSVC++ resource editor (ID: IDC_DRAWING_AREA).
    Then I have this code:

    //Get a handle to IDC_DRAWING_AREA window
    hDwgArea = CreateDialog(hInstance,
    MAKEINTRESOURCE(IDC_DRAWING_AREA),
    hWindows[3], NULL);


    I want to change the background of IDC_DRAWING_AREA from its default color to WHITE. Is it doable?

  2. #2
    Join Date
    Jun 2004
    Posts
    102
    See MSDN related to WM_CTLCOLORDLG message

  3. #3
    Join Date
    May 2004
    Location
    Michigan, United States
    Posts
    457
    Here's an example:
    Code:
    BOOL CALLBACK DialogProc(HWND hwnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
    {
    	static HBRUSH hBrush = NULL;
    
    	switch (uMessage)
    	{
    		case WM_INITDIALOG:
    
    			hBrush = CreateSolidBrush(RGB(255, 255, 255));
    			return FALSE;
    		
    		case WM_CTLCOLORDLG:
    
    			if (hBrush)
    				return (INT_PTR) hBrush;
    			else
    				return FALSE;
    
    		case WM_CLOSE:
    			
    			if (hBrush)
    				DeleteObject(hBrush);
    
    			EndDialog(hwnd, 0);
    			return FALSE;
    
    		default:
    			return FALSE;
    	}
    }
    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

  4. #4
    Join Date
    Jun 2004
    Location
    Philippines
    Posts
    31
    Thank you very much Mr. Bond. I really appreciate you here being helpful to many codeguru members.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured