fork download
  1. #include <windows.h>
  2. #include "test.h"
  3. static HBRUSH hbrBackColor;
  4.  
  5. LRESULT CALLBACK WndProc(HWND hwnd , UINT msg , WPARAM wp , LPARAM lp) {
  6. static int enable;
  7.  
  8. switch (msg) {
  9. case WM_CLOSE:
  10. PostQuitMessage(0);
  11. return 1;
  12.  
  13. case WM_CREATE:
  14. SendMessage(GetDlgItem(hwnd, IDEDIT), WM_ENABLE, 1, 0);
  15. enable = 1;
  16. return 1;
  17.  
  18. case WM_CTLCOLORDLG:
  19. return (LRESULT)hbrBackColor;
  20.  
  21. case WM_CTLCOLORSTATIC:
  22. SetBkColor((HDC)wp, RGB(0xf0, 0xb0, 0xb0));
  23. return (LRESULT)hbrBackColor;
  24.  
  25. case WM_COMMAND:
  26. switch (LOWORD(wp)) {
  27. case IDBUTTON:
  28. if (enable) { SendMessage(GetDlgItem(hwnd, IDEDIT), WM_ENABLE, 0, 0); enable = 0; }
  29. else { SendMessage(GetDlgItem(hwnd, IDEDIT), WM_ENABLE, 1, 0); enable = 1; }
  30. }
  31. return 0;
  32. }
  33. return DefDlgProc(hwnd , msg , wp , lp);
  34. }
  35.  
  36. int WINAPI WinMain(HINSTANCE hInstance , HINSTANCE hPrevInstance ,
  37. PSTR lpCmdLine , int nCmdShow ) {
  38. HWND hwnd;
  39. MSG msg;
  40. WNDCLASS winc;
  41.  
  42. winc.style = CS_HREDRAW | CS_VREDRAW;
  43. winc.lpfnWndProc = WndProc;
  44. winc.cbClsExtra = 0;
  45. winc.cbWndExtra = DLGWINDOWEXTRA; /* need for dialog-base application */
  46. winc.hInstance = hInstance;
  47. winc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  48. winc.hCursor = LoadCursor(NULL , IDC_ARROW);
  49. // winc.hbrBackground = hbrBackColor;
  50. winc.hbrBackground = NULL;
  51. winc.lpszMenuName= NULL;
  52. winc.lpszClassName = TEXT("TEST");
  53.  
  54. if (!RegisterClass(&winc)) return -1;
  55.  
  56. hbrBackColor = CreateSolidBrush(RGB(0xf0, 0xb0, 0xb0));
  57.  
  58. hwnd = CreateDialog(hInstance , TEXT("TEST") , 0 , NULL);
  59. if (hwnd == NULL) {
  60. MessageBox(0, TEXT("CreateDialog()failed."), TEXT("ERROR"), MB_OK);
  61. DeleteObject(hbrBackColor);
  62. return -1;
  63. }
  64.  
  65. while(GetMessage(&msg , NULL , 0 , 0) > 0) {
  66. TranslateMessage(&msg);
  67. DispatchMessage(&msg);
  68. }
  69. DeleteObject(hbrBackColor);
  70. return msg.wParam;
  71. }
  72. /* end */
  73.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:1:10: fatal error: 'windows.h' file not found
#include <windows.h>
         ^~~~~~~~~~~
1 error generated.
stdout
Standard output is empty