case WM_MOUSEMOVE:
if(wParam == MK_LBUTTON)
{
DrawMousePointer(hWnd,LOWORD(lParam), HIWORD(lParam));
}
break;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_CLOSE:
if(MessageBox(hWnd, "Chcete ukoncit aplikaci?","WinHello", MB_YESNO | MB_ICONQUESTION)==IDYES)
{
PostQuitMessage(0);
}
return 0;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
void DrawWndContent (HWND hWnd,HDC hDc)
{
RECT wrct;
SIZE tsize;
COLORREF zelena = RGB(0,255,0);
HBRUSH stetec, stary_stetec;
//vytvoreni noveho stetce
stetec = CreateSolidBrush(zelena);
// zjisteni velikosti okna
GetClientRect(hWnd, &wrct);
// zjisteni velikosti textu
GetTextExtentPoint32(hDc, szText, strlen(szText),&tsize);
// priradime novy stetec do kontextu zarizeni
stary_stetec = (HBRUSH)SelectObject(hDc,stetec);
//zaramovani textu
Rectangle (hDc, wrct.right/2-tsize.cx/2-5,wrct.bottom/2 - tsize.cy/2-5,
wrct.right/2+tsize.cx/2 + 5,wrct.bottom/2+tsize.cy/2 +5 );
//nastaveni pozadi textu
SetBkColor(hDc,zelena);
// nastaveni modu pozadi textu s pruhlednzm pozadim - transparant
SetBkMode(hDc, TRANSPARENT);
//tisk textu do okna
TextOut(hDc, wrct.right/2-tsize.cx/2,
wrct.bottom/2 - tsize.cy/2,
szText, strlen(szText));
// vraceni stareho stetce do kontextu zarizeni
SelectObject(hDc,stary_stetec);
// smazani objektu noveho stetce
DeleteObject(stetec);
}
void DrawMousePointer(HWND hWnd, int x,int y)
{
// ziskat kontext zarizeni
HDC hDc = GetDC(hWnd);
Ellipse(hDc,x -10,y-10,x+10,y+10);
// uvolneni kontextu zarizeni
ReleaseDC(hWnd, hDc);
}
void SetDefalut(HWND hWnd)
{
HMENU hMenu;
hMenu = GetMenu(hWnd);
CheckMenuItem(hMenu, ID_DEFALUT, MF_CHECKED);
CheckMenuItem(hMenu, ID_RED, MF_UNCHECKED);
CheckMenuItem(hMenu, ID_GREEN, MF_UNCHECKED);
ColorR=100;
ColorG=100;
ColorB=255;
InvalidateRect(hWnd, NULL, TRUE);
}