Bitmaps StretchBlt Functon

//Copying a bitmap using the StretchBlt function
#include <windows.h>
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
PWSTR lpCmdLine, int nCmdShow)
{
MSG msg ;
WNDCLASS wc = {0};
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpszClassName = TEXT("Screen copy");
wc.hInstance = hInstance;
wc.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
wc.lpfnWndProc = WndProc;
wc.hCursor = LoadCursor(0, IDC_ARROW);
RegisterClass(&wc);
CreateWindow(wc.lpszClassName, TEXT("screen copy"),WS_OVERLAPPEDWINDOW | WS_VISIBLE,100, 100, 390, 350, NULL, NULL, hInstance, NULL);

while( GetMessage(&msg, NULL, 0, 0)) {
DispatchMessage(&msg);
}

return (int) msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam)
{

static int maxX;
static int maxY;
HBITMAP hbit;

switch(msg)
{
case WM_LBUTTONDOWN:
maxX=GetSystemMetrics(SM_CXSCREEN);
maxY=GetSystemMetrics(SM_CYSCREEN);
int width;
int height;
HDC mhdc;
HDC hdc;
RECT rect;
;
if(GetWindowRect(hwnd, &rect))
{
width = rect.right - rect.left;
height = rect.bottom - rect.top;
}

mhdc = GetWindowDC(NULL);//creates a main windows device context
hdc=GetDC(hwnd);//creates application window device context
hbit=CreateCompatibleBitmap(mhdc,maxX,maxY);//create screen device context compatible bitmap
StretchBlt(hdc, 0, 0, width, height,mhdc,0,0,maxX,maxY,MERGECOPY);//copies main window bitmap to application screen
ReleaseDC(hwnd,mhdc);
ReleaseDC(hwnd,hdc);
break;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}