Advertisement
Guest User

Untitled

a guest
Nov 2nd, 2020
36
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <windows.h>
  2.  
  3.  
  4. LRESULT CALLBACK MainWindowCallBack(
  5. HWND hwnd,
  6. UINT uMsg,
  7. WPARAM wParam,
  8. LPARAM lParam
  9. )
  10.  
  11. {
  12. LRESULT Result =0;
  13.  
  14. switch(uMsg)
  15. {
  16.  
  17. case WM_SIZE:
  18. {
  19. OutputDebugStringA("WM_SIZE\n");
  20. }break;
  21.  
  22.  
  23. case WM_DESTROY:
  24. {
  25. OutputDebugStringA("WM_DESTROY\n");
  26. }break;
  27.  
  28.  
  29. case WM_CLOSE:
  30. {
  31. OutputDebugStringA("WM_CLOSE");
  32. }break;
  33.  
  34.  
  35. case WM_ACTIVATEAPP:
  36. {
  37. OutputDebugStringA("WM_ACTIVATEAPP");
  38. }break;
  39. case WM_PAINT:
  40. { PAINTSTRUCT Paint;
  41. HDC DeviceContext=BeginPaint( hwnd, &Paint );
  42. int X=Paint.rcPaint.left;
  43. int Y=Paint.rcPaint.top;
  44. int Height= Paint.rcPaint.bottom - Paint.rcPaint.top;
  45. int width =Paint.rcPaint.right - Paint.rcPaint.left;
  46.  
  47. PatBlt( DeviceContext,X,Y,Height,width,WHITENESS );
  48. EndPaint( hwnd, &Paint);
  49. }
  50.  
  51. default:
  52. {
  53. Result= DefWindowProc(hwnd,uMsg,wParam,lParam);
  54. // OutputDebugStringA("Default\n");
  55. } break;
  56.  
  57. }
  58.  
  59. return(Result);
  60. }
  61.  
  62.  
  63. int CALLBACK WinMain(
  64. HINSTANCE hInstance,
  65. HINSTANCE hPrevInstance,
  66. LPSTR lpCmdLine,
  67. int nShowCmd
  68. )
  69. {
  70.  
  71. WNDCLASSA WindowClass ={};
  72.  
  73. WindowClass.style=CS_OWNDC|CS_HREDRAW|CS_VREDRAW ;
  74. WindowClass.lpfnWndProc =MainWindowCallBack ;
  75. WindowClass.hInstance = hInstance;
  76. WindowClass.lpszClassName ="HandmadeHeroWindowClass" ;
  77. //WindowClass.hIcon
  78.  
  79. if (RegisterClassA(&WindowClass))
  80. {
  81. HWND WindowHandle = CreateWindowExA(
  82. 0,
  83. WindowClass.lpszClassName,
  84. "HandMade Hero",
  85. WS_OVERLAPPEDWINDOW|WS_VISIBLE,
  86. CW_USEDEFAULT,
  87. CW_USEDEFAULT,
  88. CW_USEDEFAULT,
  89. CW_USEDEFAULT,
  90. 0,
  91. 0,
  92. hInstance,
  93. 0
  94. );
  95. if (WindowHandle)
  96. {
  97. for (;;)
  98. {
  99. MSG Message;
  100. BOOL MessageResult= GetMessage(&Message ,0 ,0,0);
  101. if(MessageResult>0)
  102. {
  103. TranslateMessage(&Message);
  104. DispatchMessage(&Message);
  105. }
  106. else
  107. {
  108. break;
  109. }
  110. }
  111. }
  112. else
  113. {
  114. // todo(bill):logging
  115. }
  116. }
  117. else
  118. {
  119. // todo(bill):Logging
  120. }
  121.  
  122. return(0);
  123.  
  124. }
Advertisement
RAW Paste Data Copied
Advertisement