childProcSet.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #include "Win32.h"
  2. #include "Function.h"
  3. static void AutoMid(int Wx,int Wy, int& x, int& y)
  4. {
  5. int screenWidth = GetSystemMetrics(SM_CXSCREEN);
  6. int screenHeight = GetSystemMetrics(SM_CYSCREEN);
  7. x = (screenWidth - Wx) / 2;
  8. y = (screenHeight - Wy) / 2;
  9. }
  10. HWND CreateChildWindow(HWND hFather, LPCWCHAR childTitle ,int x, int y, WNDPROC procFunc, LPCWCHAR className, HINSTANCE hInstanceF)
  11. {
  12. HWND hChild = NULL;
  13. static WNDCLASSEX wcexF;
  14. wcexF.cbSize = sizeof(WNDCLASSEX);
  15. wcexF.style = CS_HREDRAW | CS_VREDRAW;
  16. wcexF.lpfnWndProc = procFunc;
  17. wcexF.cbClsExtra = 0;
  18. wcexF.cbWndExtra = 0;
  19. wcexF.hInstance = hInstanceF;
  20. wcexF.hIcon = LoadIcon(wcexF.hInstance, IDI_APPLICATION);
  21. wcexF.hCursor = LoadCursor(NULL, IDC_ARROW);
  22. wcexF.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
  23. wcexF.lpszMenuName = NULL;
  24. wcexF.lpszClassName = className;
  25. wcexF.hIconSm = LoadIcon(wcexF.hInstance, IDI_APPLICATION);
  26. RegisterClassEx(&wcexF);
  27. hChild = CreateWindowEx(
  28. NULL,
  29. className, childTitle,
  30. WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU ,
  31. 700, 300,
  32. x, y, hFather, NULL,
  33. hInstanceF, NULL
  34. );
  35. Err(hChild,
  36. _T("Create ChildWindow failed!"));
  37. return hChild;
  38. }
  39. HWND CreateLogWindow(LPCWCHAR childTitle, int x, int y, WNDPROC procFunc, LPCWCHAR className, HINSTANCE hInstanceF)
  40. {
  41. HWND hChild = NULL;
  42. static WNDCLASSEX wcexF;
  43. wcexF.cbSize = sizeof(WNDCLASSEX);
  44. wcexF.style = CS_HREDRAW | CS_VREDRAW | CS_NOCLOSE;
  45. wcexF.lpfnWndProc = procFunc;
  46. wcexF.cbClsExtra = 0;
  47. wcexF.cbWndExtra = 0;
  48. wcexF.hInstance = hInstanceF;
  49. wcexF.hIcon = LoadIcon(wcexF.hInstance, IDI_APPLICATION);
  50. wcexF.hCursor = LoadCursor(NULL, IDC_ARROW);
  51. wcexF.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
  52. wcexF.lpszMenuName = NULL;
  53. wcexF.lpszClassName = className;
  54. wcexF.hIconSm = LoadIcon(wcexF.hInstance, IDI_APPLICATION);
  55. RegisterClassEx(&wcexF);
  56. hChild = CreateWindowEx(
  57. NULL,
  58. className, childTitle,
  59. WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,
  60. 1000, 400,
  61. x, y, NULL , NULL,
  62. hInstanceF, NULL
  63. );
  64. Err(hChild,
  65. _T("Create ChildWindow failed!"));
  66. return hChild;
  67. }
  68. HWND CreateStartWindow(int x, int y, WNDPROC procFunc, LPCWCHAR className, HINSTANCE hInstanceF)
  69. {
  70. HWND hChild = NULL;
  71. static WNDCLASSEX wcexF;
  72. wcexF.cbSize = sizeof(WNDCLASSEX);
  73. wcexF.style = CS_HREDRAW | CS_VREDRAW | CS_NOCLOSE;
  74. wcexF.lpfnWndProc = procFunc;
  75. wcexF.cbClsExtra = 0;
  76. wcexF.cbWndExtra = 0;
  77. wcexF.hInstance = hInstanceF;
  78. wcexF.hIcon = LoadIcon(wcexF.hInstance, IDI_APPLICATION);
  79. wcexF.hCursor = LoadCursor(NULL, IDC_ARROW);
  80. wcexF.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
  81. wcexF.lpszMenuName = NULL;
  82. wcexF.lpszClassName = className;
  83. wcexF.hIconSm = LoadIcon(wcexF.hInstance, IDI_APPLICATION);
  84. RegisterClassEx(&wcexF);
  85. int Sx, Sy;
  86. AutoMid(x, y, Sx, Sy);
  87. hChild = CreateWindowEx(
  88. NULL,
  89. className, NULL,
  90. WS_POPUP | WS_VISIBLE | WS_BORDER,
  91. Sx, Sy,
  92. x, y, NULL, NULL,
  93. hInstanceF, NULL
  94. );
  95. Err(hChild,
  96. _T("Create ChildWindow failed!"));
  97. return hChild;
  98. }