Sign in to follow this  
Xiachunyi

Win32 API: Dialog Bitmap Control Conflict

Recommended Posts

Xiachunyi    556
Hello, I am having problems currently with trying to let both a bitmap and a few controls on my dialog box coexist. I have successfully been able to add a bitmap "skin" over my dialog box, but the problem is that if I add a control to the dialog box, the bitmap disappears. Dialog Box
//~~~~~Query Dialog Box
BOOL CALLBACK Query_Dialog(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
    static HBITMAP hbitmap;
    static HDC hdc;
    static HDC image_dc;
    static HBITMAP old_hbitmap;

    switch(message)
	{
        case WM_INITDIALOG:
        {
        //Setup Bitmap
			hbitmap = (HBITMAP)LoadImage(hInstance, "Data\\Graphics\\Hi.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
			hdc = GetDC(hwnd);
			image_dc = CreateCompatibleDC(hdc);
			old_hbitmap = (HBITMAP)SelectObject(image_dc,hbitmap);
			BitBlt(hdc,0,0,350,263,image_dc,0,0,SRCCOPY);
	    //Send local dialog box handle to global
        }
        break;
		case WM_PAINT:
		{
             BitBlt(hdc,0,0,350,263,image_dc,0,0,SRCCOPY);
        }
        break;
		case WM_COMMAND:
        case WM_CLOSE:
		case WM_DESTROY:
		{
			SelectObject(image_dc,old_hbitmap);
			DeleteObject(hbitmap);
			ReleaseDC(hwnd, hdc);
			DeleteDC(image_dc);
			return TRUE;
		}
	}
	return FALSE;
}


Dialog Box's resource
//~~~~~Query Dialog Box
IDD_QUERY DIALOG DISCARDABLE  0, 0, 220, 150
STYLE DS_SETFOREGROUND | DS_CENTER | WS_POPUP | WS_VISIBLE
FONT 8, "MS Sans Serif"
BEGIN
    CONTROL         "800x600",IDC_QUERY_RES_A,"Button",BS_AUTORADIOBUTTON | 
                    BS_PUSHLIKE | BS_NOTIFY | BS_FLAT,1,73,53,11
    CONTROL         "1024x768",IDC_QUERY_RES_B,"Button",BS_AUTORADIOBUTTON | 
                    BS_PUSHLIKE | BS_NOTIFY | BS_FLAT,1,87,53,11
    CONTROL         "16 Bit Color",IDC_QUERY_RES_16BIT,"Button",
                    BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_NOTIFY | BS_FLAT,
                    166,73,53,11
    CONTROL         "32 Bit Color",IDC_QUERY_RES_32BIT,"Button",
                    BS_AUTORADIOBUTTON | BS_PUSHLIKE | BS_NOTIFY | BS_FLAT,
                    165,87,53,11
END


If the dialog box does not contain the controls, the bitmap shows, if it does then the bitmap is nowhere to be found. Adding a progress bar control does not do the same thing - the progress bar and bitmap can coexist with each other. Is there something I should be doing to allow both the control and bitmap to coexist? Thank you.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
have you tried placing a break statement after the case WM_COMMAND statement? it could be that the WM_COMMAND processing is falling through and closing down your dialog box.

Share this post


Link to post
Share on other sites
Xiachunyi    556
That worked, thank you!

I guess controls that recieve input are in effect, although it is wierd that the dialog box just does not exit instead of just sitting there.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this