fork(2) download
  1. #include <windows.h>
  2. #define BUTTON 100
  3. #define EDIT 101
  4.  
  5. /* Функция обработки сообщений */
  6. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
  7. switch(message)
  8. {
  9. case WM_COMMAND: if(LOWORD(wParam) == BUTTON) MessageBox(hWnd, "Вы кликнули!", "Событие", 0); break;
  10. case WM_DESTROY: PostQuitMessage(0); break;
  11. default: return DefWindowProc(hWnd, message, wParam, lParam);
  12. }
  13. return DefWindowProc(hWnd, message, wParam, lParam);
  14. }
  15.  
  16. /* функция регистрации класса окон */
  17. ATOM RegMyWindowClass(HINSTANCE hInst, LPCTSTR lpzClassName) {
  18. WNDCLASS wc = {0};
  19. wc.lpfnWndProc = (WNDPROC)WndProc;
  20. wc.style = CS_HREDRAW|CS_VREDRAW;
  21. wc.hInstance = hInst;
  22. wc.lpszClassName = lpzClassName;
  23. wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  24. wc.hbrBackground = (HBRUSH)COLOR_WINDOWFRAME;
  25. wc.hIcon = LoadImage(NULL, "img.ico", IMAGE_ICON, 32, 32, LR_LOADFROMFILE);
  26. return RegisterClass(&wc);
  27. }
  28.  
  29. /* Функция вхождений программы WinMain */
  30. int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
  31. FreeConsole();
  32. LPCTSTR lpzClass = "Window";
  33. if(!RegMyWindowClass(hInstance, lpzClass)) return 1;
  34.  
  35. /* Вычисление координат центра экрана */
  36. RECT screen;
  37. GetWindowRect(GetDesktopWindow(), &screen);
  38. int width = 500;
  39. int height = 300;
  40. int x = (screen.right - width)/2;
  41. int y = (screen.bottom - height)/2;
  42.  
  43. /* Создание окна */
  44. HWND hWnd = CreateWindow(
  45. lpzClass,
  46. "Main",
  47. WS_OVERLAPPEDWINDOW | WS_VISIBLE,
  48. x, y,
  49. width, height,
  50. NULL,
  51. NULL,
  52. hInstance,
  53. NULL
  54. );
  55.  
  56. /* Создание кнопки */
  57. HWND OK = CreateWindow(
  58. "BUTTON",
  59. "OK",
  60. WS_CHILD | WS_VISIBLE,
  61. 212, 200,
  62. 75, 23,
  63. hWnd,
  64. (HMENU)BUTTON,
  65. hInstance,
  66. NULL
  67. );
  68.  
  69. /* Создание текстового поля */
  70. HWND Edit = CreateWindowEx(
  71. WS_EX_CLIENTEDGE,
  72. "edit",
  73. "",
  74. WS_CHILD | WS_VISIBLE,
  75. 10, 10,
  76. 246, 23,
  77. hWnd,
  78. (HMENU)EDIT,
  79. hInstance,
  80. NULL
  81. );
  82.  
  83. MSG msg = {0};
  84. int state = 0;
  85. while((state = GetMessage(&msg, NULL, 0, 0 )) != 0)
  86. DispatchMessage(&msg);
  87. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:1:21: fatal error: windows.h: No such file or directory
 #include <windows.h>
                     ^
compilation terminated.
stdout
Standard output is empty