Thread: Dialog Bg

  1. #1
    Registered User
    Join Date
    Apr 2007

    Dialog Bg

    I am trying to set a bitmap background for my dialog box. The compilation runs without any errors but the background does not appear at all.

    Dont you know what might be wrong?

    #include <windows.h>
    #include <commctrl.h>
    #include <tchar.h>
    #include "resource.h"
    HBRUSH		hBG;
    HINSTANCE	hInstance;
    HDC		hDC;
    INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
    	switch ( uMsg )
    		case WM_COMMAND:
    			switch ( LOWORD(wParam) )
    			case IDCANCEL:
    				EndDialog(hwndDlg, LOWORD(lParam));
    		case WM_CTLCOLORDLG:
    			SetBkMode((HDC)wParam, TRANSPARENT);
    			return (INT_PTR)hBG;
    		case WM_INITDIALOG:
    			hBG = CreatePatternBrush(LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_bg)));
    	return FALSE;
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,
    	LPSTR lpCmdLine, int nShow)
    	return DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG_MAIN),
    		NULL, (DLGPROC)DialogProc);

    Thank you for any help

  2. #2
    Join Date
    Jan 2002
    Looks like you've declared hInstance but not initialised it. What's the return value from LoadBitmap(you should be using use LoadImage instead)? If it's NULL use GetLastError to give you some diagnostic information.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 02-13-2008, 02:59 PM
  2. Edit controls of a dialog from another dialog...
    By Snake in forum Windows Programming
    Replies: 9
    Last Post: 07-01-2005, 02:18 PM
  3. make Child Dialog not Popup?
    By Zeusbwr in forum Windows Programming
    Replies: 5
    Last Post: 04-08-2005, 02:42 PM
  4. Getting the position of a dialog without parent on the screen
    By stormbringer in forum Windows Programming
    Replies: 1
    Last Post: 08-27-2003, 02:59 AM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM