Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. ATOM MyRegisterClass(HINSTANCE hInstance)
  2. {
  3. WNDCLASSEX wcex;
  4.  
  5. wcex.cbSize = sizeof(WNDCLASSEX);
  6. wcex.style = CS_HREDRAW | CS_VREDRAW;
  7. wcex.lpfnWndProc = WndProc;
  8. wcex.cbClsExtra = 0;
  9. wcex.cbWndExtra = 0;
  10. wcex.hInstance = hInstance;
  11. wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_EXAM));
  12. wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
  13. wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
  14. wcex.lpszMenuName = MAKEINTRESOURCE(IDC_EXAM);
  15. wcex.lpszClassName = szWindowClass;
  16. wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
  17. return RegisterClassEx(&wcex);
  18. }
  19. BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
  20. {
  21. HWND hWnd;
  22. hInst = hInstance; // Store instance handle in our global variable
  23. hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
  24. CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
  25. if (!hWnd) {return FALSE;}
  26. ShowWindow(hWnd, nCmdShow);
  27. UpdateWindow(hWnd);
  28. return TRUE;
  29. }
  30. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  31. {
  32. (1)while (GetMessage(&msg, NULL, 0, 0))
  33. {
  34. TranslateMessage(hWnd, &message, &wParam, &lParam);
  35. DispatchMessage(hWnd, &message, &wParam, &lParam);
  36. }
  37. return message.wParam;
  38. }
  39. int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine,int nCmdShow)
  40. {
  41. (2)MSG msg;
  42. HWND hWnd;
  43. MyRegisterClass(hInstance);
  44. if(InitInstance (hInstance, nCmdShow)) return FALSE;
  45. while (DefWindowProc(&hWnd, &msg, 0, 0))
  46. {
  47. PAINTSTRUCT ps;
  48. HDC hdc;
  49. switch (msg)
  50. {
  51. case WM_PAINT:
  52. hdc = BeginPaint(hWnd, &ps);
  53. EndPaint(hWnd, &ps);
  54. break;
  55. case WM_DESTROY:
  56. PostQuitMessage(0);
  57. break;
  58. default:
  59. return DefWindowProc(&hWnd, msg, 0, 0);
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement