Witam mam pewien problem, mianowicie:
Gdy całego case WM_PAINT dam w komentarz to przy próbie zamknięcia programu ładnie wyskakuje MsgBox z odpowiednim komunikatem zaś gdy WM_PAINT jest włączony w program to tak jakby nie pokazuje się MsgBox a w okienku nic niemożna zrobić bo uruchomiliśmy MsgBox.
Oto kod:
#include <windows.h>
static TCHAR lpszAppName[] = TEXT( "API Windows v 1.0" );
static int windowWidth = 640;
static int windowHeight = 480;
HINSTANCE hInst;
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
HDC hDC;
HDC hDCII;
HBITMAP hBitmap;
switch (uMsg)
{
case WM_CLOSE:
if(MessageBox(hWnd,L"Czy chcesz zamknąć aplikacje ?", lpszAppName, MB_YESNO) == IDYES)
PostQuitMessage(0);
break;
case WM_PAINT:
hBitmap = (HBITMAP) LoadImage(hInst, L"c:/images/test.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hDC = GetDC(hWnd);
hDCII = CreateCompatibleDC(hDC);
SelectObject(hDCII,hBitmap);
BitBlt(hDC, LOWORD(lParam), HIWORD(lParam), 192, 224, hDCII, 0, 0, SRCCOPY);
ReleaseDC(hWnd, hDC);
DeleteDC(hDCII);
break;
default:
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
return(0L);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
MSG msg;
WNDCLASS wndclass;
HWND hWnd;
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = MainWndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = NULL;
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = lpszAppName;
hInst = hInstance;
if(RegisterClass(&wndclass) == 0)
return FALSE;
hWnd = CreateWindow(
lpszAppName, lpszAppName,
WS_OVERLAPPEDWINDOW| WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
100, 100, windowWidth, windowHeight,
NULL, NULL, hInstance, NULL);
if(hWnd == NULL)
return FALSE;
ShowWindow(hWnd, SW_SHOW);
UpdateWindow(hWnd);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
Proszę o pomoc.