#include <windows.h>
 

BITMAP   bmp;
 

void PaintBkBitmap(HWND hWndDlg) {
 

    HDC      hdc, hMemDC;
 

    PAINTSTRUCT ps;

    HGDIOBJ hOld;
 

    RECT rc;
 

    GetClientRect(hWndDlg,&rc);
 

    hdc = BeginPaint(hWndDlg,&ps);
 
 

    hMemDC = CreateCompatibleDC(hdc);
 

    hOld = SelectObject(hMemDC,hBitmap);
 

    BOOL bRet = BitBlt(hdc,rc.right - 50 - 200,10,200,87,hMemDC,0,0,SRCAND);
 

    SelectObject(hMemDC,hOld);

    DeleteDC(hMemDC);

    ReleaseDC(hWndDlg,hdc);

    EndPaint(hWndDlg,&ps);

}
 
 
 

LRESULT CALLBACK DlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
 

int APIENTRY WinMain(HINSTANCE hInstance,

                     HINSTANCE hPrevInstance,

                     LPTSTR    lpCmdLine,

                     int       nCmdShow)

{

    UNREFERENCED_PARAMETER(hPrevInstance);

    UNREFERENCED_PARAMETER(lpCmdLine);
 

    hInst = hInstance;
 

    int nRet = (int)DialogBox(hInst,MAKEINTRESOURCE(IDD_DIALOG),0,(DLGPROC) DlgProc);
 

    if (-1 == nRet)

    {

      return FALSE;

    }
 

    return 0;

}
 
 
 

BOOL       DlgCmd   (   HWND    hwndDlg,        // handle to dialog box

                        UINT    uMsg,           // message

                        WPARAM  wParam,         // first message parameter

                        LPARAM  lParam          // second message parameter

                    ) {
 

    WORD    wNotifyCode;

    WORD    wID;

    HWND    hwndCtl;
 

    wNotifyCode =   HIWORD(wParam); // notification code 

    wID         =   LOWORD(wParam); // item, control, or accelerator identifier 

    hwndCtl     =   (HWND) lParam;  // handle of control 
 

    if  (BN_CLICKED ==  wNotifyCode) {  //  nothing else will happen...

    

            switch(wID){
 

                case    IDC_OK:
 

                            return DlgOK(hwndDlg);

                            break;
 

                case    IDC_CANCEL:
 

                            EndDialog(hwndDlg,IDOK);

                            break;
 

            }

        }

                                        

    return( TRUE);

}
 

BOOL DlgOK(HWND hwndDlg) {
 

    return TRUE;

}
 

BOOL DlgInit(HWND hwndDlg) {
 

    hBitmap = LoadBitmap(hInst,MAKEINTRESOURCE(IDB_BITMAP));
 

    int nRet = GetObject(hBitmap, sizeof(BITMAP), (LPVOID)&bmp);

 

    return TRUE;

}
 

LRESULT CALLBACK DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
 

     switch (uMsg) {
 

                case    WM_INITDIALOG:  return  (   DlgInit   (   hwndDlg));
 

                case    WM_COMMAND:     return  (   DlgCmd    (   hwndDlg,

                                                                        uMsg,

                                                                        wParam,

                                                                        lParam

                                                                    )

                                                );  
 

                case    WM_PAINT:       PaintBkBitmap( hwndDlg);
 

            };
 

    return FALSE;

}

Select all

Advertisements