MFC

BitBlt,WM_CLOSE

박__주홍 2020. 9. 7. 20:33

왼쪽 마우스키를 누르면 비트맵 복사해서 만든 다른 윈도우(클라이언트)에 출력하는 코드

LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if(uMsg == WM_DESTROY)PostQuitMessage(0);
else if(uMsg == WM_LBUTTONDOWN){
HDC h_wnd_dc = ::GetWindowDC(NULL);
HDC h_dc = GetDC(hWnd);

BitBlt(h_dc, 0, 0, 300, 200, h_wnd_dc, 50, 50, SRCINVERT);

ReleaseDC(hWnd,h_dc);
ReleaseDC(NULL);
}
return DefWindowProc(hWnd,uMsg,wParam,lParam);
}

 

윈도우창 닫을때 한번 더 물어보는 코드

LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (uMsg == WM_DESTROY)PostQuitMessage(0);
else if (uMsg == WM_CLOSE) {
int check = MessageBox(hWnd, L"프로그램을 종료하시겠습니까?",
L"프로그램 창 닫기", MB_ICONQUESTION | MB_OKCANCEL);

if (check == IDCANCEL)return 0;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}