You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
2.3 KiB

5 years ago
  1. #include <windows.h>
  2. #include <tchar.h>
  3. LRESULT CALLBACK windowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  4. {
  5. switch(msg)
  6. {
  7. case WM_SIZE:
  8. break;
  9. case WM_CLOSE:
  10. case WM_DESTROY:
  11. PostQuitMessage(0);
  12. break;
  13. default:
  14. break;
  15. }
  16. return DefWindowProc( hWnd, msg, wParam, lParam );
  17. }
  18. int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd )
  19. {
  20. // 1 ע�ᴰ����
  21. ::WNDCLASSEXA winClass;
  22. winClass.lpszClassName = "Raster";
  23. winClass.cbSize = sizeof(::WNDCLASSEX);
  24. winClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC | CS_DBLCLKS;
  25. winClass.lpfnWndProc = windowProc;
  26. winClass.hInstance = hInstance;
  27. winClass.hIcon = 0;
  28. winClass.hIconSm = 0;
  29. winClass.hCursor = LoadCursor(NULL, IDC_ARROW);
  30. winClass.hbrBackground = (HBRUSH)(BLACK_BRUSH);
  31. winClass.lpszMenuName = NULL;
  32. winClass.cbClsExtra = 0;
  33. winClass.cbWndExtra = 0;
  34. RegisterClassExA(&winClass);
  35. // 2 ��������
  36. HWND hWnd = CreateWindowEx(
  37. NULL,
  38. "Raster",
  39. "Raster",
  40. WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
  41. 0,
  42. 0,
  43. 480,
  44. 320,
  45. 0,
  46. 0,
  47. hInstance,
  48. 0
  49. );
  50. UpdateWindow( hWnd );
  51. ShowWindow(hWnd,SW_SHOW);
  52. MSG msg = {0};
  53. while(true)
  54. {
  55. if (msg.message == WM_DESTROY
  56. ||msg.message == WM_CLOSE
  57. ||msg.message == WM_QUIT)
  58. {
  59. break;
  60. }
  61. if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
  62. {
  63. TranslateMessage( &msg );
  64. DispatchMessage( &msg );
  65. }
  66. }
  67. return 0;
  68. }