Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. #include <Windows.h>
  2. #include "resource.h"
  3. MSG msg;
  4. HWND hWnd;
  5. WNDCLASSEX wc;
  6. LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  7.  
  8.  
  9. int CALLBACK wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR szCmdLine, int nCmdShow) {
  10. wc.cbSize = sizeof(WNDCLASSEX);
  11. wc.cbClsExtra = 0;
  12. wc.cbWndExtra = 0;
  13. wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  14. wc.hInstance = hInstance;
  15. wc.hCursor = LoadCursor(wc.hInstance, IDC_ARROW);
  16. wc.hIcon = LoadIcon(wc.hInstance, IDI_ERROR);
  17. wc.hIconSm = LoadIcon(wc.hInstance, IDI_ERROR);
  18. wc.lpfnWndProc = (WNDPROC)WndProc;
  19. wc.lpszClassName = "Application";
  20. wc.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1);
  21. wc.style = CS_VREDRAW | CS_HREDRAW;
  22. if (!RegisterClassEx(&wc))
  23. return EXIT_FAILURE;
  24. hWnd = CreateWindow(wc.lpszClassName, wc.lpszClassName, WS_OVERLAPPEDWINDOW, 0, 0, 1680, 1050, nullptr, nullptr, wc.hInstance, nullptr);
  25. if (hWnd == INVALID_HANDLE_VALUE)
  26. return EXIT_FAILURE;
  27. ShowWindow(hWnd, nCmdShow);
  28. UpdateWindow(hWnd);
  29. while (GetMessage(&msg, nullptr, 0, 0)) {
  30. TranslateMessage(&msg);
  31. DispatchMessage(&msg);
  32. }
  33. return msg.wParam;
  34. }
  35.  
  36. LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
  37. switch (uMsg) {
  38. case WM_COMMAND:
  39. switch (LOWORD(wParam)) {
  40. case ID_CHANGE_CURSOR:
  41. SetClassLong(hWnd, GCL_HCURSOR, (LONG)LoadCursor(wc., IDC_CROSS));
  42. break;
  43. case ID_CHANGE_BACKGROUND:
  44. SetClassLong(hWnd, GCL_HBRBACKGROUND, (LONG)CreateSolidBrush(RGB(0, 0, 255)));
  45. InvalidateRect(hWnd, nullptr, TRUE);
  46. break;
  47. }
  48. break;
  49. case WM_DESTROY:
  50. PostQuitMessage(EXIT_SUCCESS);
  51. break;
  52. }
  53. return DefWindowProc(hWnd, uMsg, wParam, lParam);
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement