Documente Academic
Documente Profesional
Documente Cultură
Raport
Lucrarea de laborator nr.4-5
Disciplina: Programarea Pilotată de Evenimente
Chișinău - 2020
Tema: “Ceasul sistemului Windows. Ferestre descendent”
Obiective:
Listingul programului:
#include <WindowsProject5.h>
#include <tchar.h>
#include "Resource1.h"
HWND hwnd;
MSG msg;
WNDCLASSW wc = { 0 };
wc.lpszClassName = L"Quiz";
wc.hInstance = hInstance;
wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
wc.lpfnWndProc = WndProc;
wc.hCursor = LoadCursor(0, IDC_ARROW);
g_hinst = hInstance;
RegisterClassW(&wc);
hwnd = CreateWindowW(wc.lpszClassName, L"Quiz",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
200, 100, 700, 400, 0, 0, hInstance, 0);
while (GetMessage(&msg, NULL, 0, 0)) {
DispatchMessage(&msg);
}
return (int)msg.wParam;
}
switch (msg) {
case WM_CREATE:
LoadMyImage();
hsti = CreateWindowW(L"Static", L"",
WS_CHILD | WS_VISIBLE | SS_BITMAP,
480, 70, 300, 300, hwnd, (HMENU) 1, NULL, NULL);
SendMessage(hsti, STM_SETIMAGE,
(WPARAM)IMAGE_BITMAP, (LPARAM)hBitmap);
CreateWindowW(L"Button", L"Panama",
WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
550, 170, 80, 25, hwnd, (HMENU)ID_PANAMA, NULL, NULL);
CreateWindowW(L"Button", L"Argentina",
WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
450, 200, 80, 25, hwnd, (HMENU)ID_ARGENTINA, NULL, NULL);
CreateWindowW(L"Button", L"Portugal",
WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
550, 200, 80, 25, hwnd, (HMENU)ID_PORTUGAL, NULL, NULL);
break;
case WM_COMMAND:
if (LOWORD(wParam) == ID_DONE) {
KillTimer(hwnd, 1);
MessageBox(hwnd, "Congratulations! You finished the test", "",
NULL);
}
if (LOWORD(wParam) == ID_QUIT) {
PostQuitMessage(0);
}
if (HIWORD(wParam) == BN_CLICKED) {
switch (LOWORD(wParam)) {
case ID_BLUE:
MessageBox(hwnd, "False", "", MB_ICONHAND);
CheckDlgButton(hwnd, ID_BLUE, BST_UNCHECKED);
break;
case ID_GREEN:
MessageBox(hwnd, "Correct", "", MB_ICONINFORMATION);
break;
case ID_ORANGE:
MessageBox(hwnd, "False", "", MB_ICONHAND);
CheckDlgButton(hwnd, ID_ORANGE, BST_UNCHECKED);
break;
//-----------------------------------------------------------
case ID_CAIRO:
MessageBox(hwnd, "False", "", MB_ICONHAND);
CheckDlgButton(hwnd, ID_CAIRO, BST_UNCHECKED);
break;
case ID_ANKARA:
MessageBox(hwnd, "Correct", "", MB_ICONINFORMATION);
break;
case ID_CANBERRA:
MessageBox(hwnd, "False", "", MB_ICONHAND);
CheckDlgButton(hwnd, ID_CANBERRA, BST_UNCHECKED);
break;
//----------------------------------------------------------------------
case ID_ARGENTINA:
MessageBox(hwnd, "False", "", MB_ICONHAND);
break;
case ID_COLOMBIA:
MessageBox(hwnd, "Correct", "", MB_ICONINFORMATION);
EnableWindow(hButton, FALSE);
break;
case ID_PANAMA:
MessageBox(hwnd, "False", "", MB_ICONHAND);
break;
case ID_PORTUGAL:
MessageBox(hwnd, "False", "", MB_ICONHAND);
break;
}
InvalidateRect(hwnd, NULL, TRUE);
}
if (LOWORD(wParam) == ID_SASE) {
MessageBox(hwnd, "Correct", "", MB_ICONINFORMATION);
}
if (LOWORD(wParam) == ID_OPT) {
MessageBox(hwnd, "False", "", MB_ICONHAND);
CheckDlgButton(hwnd, ID_OPT, BST_UNCHECKED);
}
if (LOWORD(wParam) == ID_H2O) {
MessageBox(hwnd, "False", "", MB_ICONHAND);
CheckDlgButton(hwnd, ID_H2O, BST_UNCHECKED);
}
if (LOWORD(wParam) == ID_CO2) {
MessageBox(hwnd, "False", "", MB_ICONHAND);
CheckDlgButton(hwnd, ID_CO2, BST_UNCHECKED);
}
if (LOWORD(wParam) == ID_CAC2) {
MessageBox(hwnd, "Correct", "", MB_ICONINFORMATION);
}
break;
case WM_TIMER:
t++;
InvalidateRect(hwnd, NULL, TRUE);
break;
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
_tcscat(str + 9, _itot(t, s, 10));
TextOut(hdc, 600, 10, str, _tcsclen(str));
TextOut(hdc, 460, 140, "Which country is this flag", 26);
EndPaint(hwnd, &ps);
break;
case WM_DESTROY:
DeleteObject(hBitmap);
PostQuitMessage(0);
break;
}
Rezultatele programului:
Concluzie: