Have anyone successfully written a program that uses a dialog, and sets a bitmap as its background. The closest I can get is changing the color of the dialog.... Can anyone help?
Posted on 2002-04-04 02:25:14 by Tsongkie[ii]
use the resources below:


#include "resource.h"
#include "resource.k"
3000 BITMAP "yourfile.BMP"

IDD_DIALOG2 DIALOG MOVEABLE IMPURE LOADONCALL DISCARDABLE 10, 10, 190, 244
STYLE WS_VISIBLE | WS_POPUP | DS_SYSMODAL | WS_BORDER
FONT 8, "MS Sans Serif"
BEGIN
CONTROL 3000,2000,"Static",SS_BITMAP,60,80,100,100
END

and then load this dialog with code :

invoke DialogBoxParam, hInstance,IDD_DIALOG2,NULL,addr DlgProc2,NULL

DlgProc2 proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM


DlgProc2 endp


may my answer fulfill your question :->
Posted on 2002-04-04 03:19:56 by newbies
Process WM_ERASEBKGND and StretchBlt your bitmap. Dialogboxes were designed
to be device independant so when you add a bitmap (or any device dependant
control) to your dialog it's important to do calculations to keep things in
proportion. Because you only want the background painted with the bitmap you
can simply StretchBlt it.

Here's a quick hack:



BOOL CALLBACK DlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
static HBITMAP bitmap;
static BITMAP bmpobj;
HDC memdc;
RECT rect;

switch (message)
{
case WM_INITDIALOG:
bitmap = LoadBitmap (GetModuleHandle (NULL), MAKEINTRESOURCE (IDB_BITMAP));

if (GetObject (bitmap, sizeof bmpobj, &bmpobj) == 0)
error_msg ();

return TRUE;

case WM_CLOSE:
EndDialog (hwndDlg, 0);
return 0;

case WM_ERASEBKGND:

GetClientRect (hwndDlg, &rect);

if ((memdc = CreateCompatibleDC ((HDC) wParam)) == NULL)
error_msg ();

SelectObject (memdc, bitmap);

if (StretchBlt ((HDC) wParam, 0, 0, rect.right, rect.bottom, (HDC) memdc,
0, 0, bmpobj.bmWidth, bmpobj.bmHeight, SRCCOPY) == 0)
error_msg ();

DeleteDC (memdc);
return TRUE;

default:
return FALSE;
}
}


Cheers,
Boggy
Posted on 2002-04-04 06:05:00 by Boggy
thanks a lot :) that seems to have solved my pronlem
Posted on 2002-04-04 21:52:32 by Tsongkie[ii]