XKSYU2021 1 mese fa
parent
commit
b81dc3a421

+ 2 - 1
Ui for BDS/Function.h

@@ -20,4 +20,5 @@ void ClearLog();
 void Log(HWND hwnd);
 
 HWND CreateChildWindow(HWND hFather, LPCWCHAR childTitle, int x, int y, WNDPROC procFunc, LPCWCHAR className, HINSTANCE hInstance);
-HWND CreateLogWindow(LPCWCHAR childTitle, int x, int y, WNDPROC procFunc, LPCWCHAR className, HINSTANCE hInstanceF);
+HWND CreateLogWindow(LPCWCHAR childTitle, int x, int y, WNDPROC procFunc, LPCWCHAR className, HINSTANCE hInstanceF);
+HWND CreateStartWindow(int x, int y, WNDPROC procFunc, LPCWCHAR className, HINSTANCE hInstanceF);

+ 1 - 1
Ui for BDS/SharedValue.h

@@ -7,7 +7,7 @@
 #define C(x) (x "\n")
 
 extern HANDLE UIw_key, BDSr_key, UIr_log, BDSw_log;
-extern HWND hWnd, hLog, hTime, hWeather, hPlayer, hConfig, hBackup;
+extern HWND hWnd, hLog, hTime, hWeather, hPlayer, hConfig, hBackup, hStart;
 
 #define TITLE _T("UI for BDS")
 

+ 1 - 0
Ui for BDS/Ui for BDS.vcxproj

@@ -137,6 +137,7 @@
     <ClInclude Include="Win32.h" />
   </ItemGroup>
   <ItemGroup>
+    <ClCompile Include="backup.cpp" />
     <ClCompile Include="childProc.cpp" />
     <ClCompile Include="childProcSet.cpp" />
     <ClCompile Include="cmdSend.cpp" />

+ 3 - 0
Ui for BDS/Ui for BDS.vcxproj.filters

@@ -65,6 +65,9 @@
     <ClCompile Include="config.cpp">
       <Filter>源文件</Filter>
     </ClCompile>
+    <ClCompile Include="backup.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="Ui for BDS.rc">

+ 5 - 0
Ui for BDS/backup.cpp

@@ -0,0 +1,5 @@
+#include "Win32.h"
+#include "Config.h"
+#include "Function.h"
+#include "SharedValue.h"
+

+ 26 - 0
Ui for BDS/childProc.cpp

@@ -5,6 +5,31 @@
 
 HFONT Font();
 
+LRESULT CALLBACK StartProc(HWND hWnd1, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+    switch (msg)
+    {
+    case WM_CREATE:
+    {
+        HWND hLabel = CreateWindow(
+            L"STATIC", L"UI For BDS",
+            WS_VISIBLE | WS_CHILD,
+            20, 20, 130, 50,
+            hWnd1, NULL,
+            (HINSTANCE)GetWindowLongPtr(hWnd1, GWLP_HINSTANCE), NULL
+        );
+        break;
+    }
+    case WM_DESTROY:
+        hStart = NULL;
+        break;
+    default:
+        return DefWindowProc(hWnd1, msg, wParam, lParam);
+    }
+    return 0;
+}
+
+
 LRESULT CALLBACK WeatherProc(HWND hWnd1, UINT msg, WPARAM wParam, LPARAM lParam) {
     switch (msg) {
     case WM_CREATE:
@@ -579,3 +604,4 @@ LRESULT CALLBACK BkProc(HWND hWnd1, UINT msg, WPARAM wParam, LPARAM lParam) {
     }
     return 0;
 }
+

+ 42 - 0
Ui for BDS/childProcSet.cpp

@@ -1,6 +1,14 @@
 #include "Win32.h"
 #include "Function.h"
 
+static void AutoMid(int Wx,int Wy, int& x, int& y)
+{
+    int screenWidth = GetSystemMetrics(SM_CXSCREEN);
+    int screenHeight = GetSystemMetrics(SM_CYSCREEN);
+    x = (screenWidth - Wx) / 2;
+    y = (screenHeight - Wy) / 2;
+}
+
 HWND CreateChildWindow(HWND hFather, LPCWCHAR childTitle ,int x, int y, WNDPROC procFunc, LPCWCHAR className, HINSTANCE hInstanceF)
 {
     HWND hChild = NULL;
@@ -63,4 +71,38 @@ HWND CreateLogWindow(LPCWCHAR childTitle, int x, int y, WNDPROC procFunc, LPCWCH
     Err(hChild,
         _T("Create ChildWindow failed!"));
     return hChild;
+}
+
+HWND CreateStartWindow(int x, int y, WNDPROC procFunc, LPCWCHAR className, HINSTANCE hInstanceF)
+{
+    HWND hChild = NULL;
+    static WNDCLASSEX wcexF;
+    wcexF.cbSize = sizeof(WNDCLASSEX);
+    wcexF.style = CS_HREDRAW | CS_VREDRAW | CS_NOCLOSE;
+    wcexF.lpfnWndProc = procFunc;
+    wcexF.cbClsExtra = 0;
+    wcexF.cbWndExtra = 0;
+    wcexF.hInstance = hInstanceF;
+    wcexF.hIcon = LoadIcon(wcexF.hInstance, IDI_APPLICATION);
+    wcexF.hCursor = LoadCursor(NULL, IDC_ARROW);
+    wcexF.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
+    wcexF.lpszMenuName = NULL;
+    wcexF.lpszClassName = className;
+    wcexF.hIconSm = LoadIcon(wcexF.hInstance, IDI_APPLICATION);
+    RegisterClassEx(&wcexF);
+
+    int Sx, Sy;
+    AutoMid(x, y, Sx, Sy);
+
+    hChild = CreateWindowEx(
+        NULL,
+        className, NULL,
+        WS_POPUP | WS_VISIBLE,
+        Sx, Sy,
+        x, y, NULL, NULL,
+        hInstanceF, NULL
+    );
+    Err(hChild,
+        _T("Create ChildWindow failed!"));
+    return hChild;
 }

+ 9 - 2
Ui for BDS/mainProc.cpp

@@ -3,7 +3,7 @@
 #include "Function.h"
 #include "SharedValue.h"
 
-InitHW(hTime);   InitHW(hWeather);   InitHW(hLog);   InitHW(hPlayer); InitHW(hConfig); InitHW(hBackup);
+InitHW(hTime);   InitHW(hWeather);   InitHW(hLog);   InitHW(hPlayer); InitHW(hConfig); InitHW(hBackup); InitHW(hStart);
 
 LRESULT CALLBACK TimeProc(HWND hWnd1, UINT msg, WPARAM wParam, LPARAM lParam);
 LRESULT CALLBACK WeatherProc(HWND hWnd1, UINT msg, WPARAM wParam, LPARAM lParam);
@@ -11,7 +11,7 @@ LRESULT CALLBACK LogProc(HWND hWnd1, UINT msg, WPARAM wParam, LPARAM lParam);
 LRESULT CALLBACK PlayerProc(HWND hWnd1, UINT msg, WPARAM wParam, LPARAM lParam);
 LRESULT CALLBACK ConfProc(HWND hWnd1, UINT msg, WPARAM wParam, LPARAM lParam);
 LRESULT CALLBACK BkProc(HWND hWnd1, UINT msg, WPARAM wParam, LPARAM lParam);
-
+LRESULT CALLBACK StartProc(HWND hWnd1, UINT msg, WPARAM wParam, LPARAM lParam);
 
 LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 {
@@ -31,6 +31,13 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
         //StartBDS();
 
+        HINSTANCE HI_Start = NULL;
+        hStart = CreateStartWindow(
+            700, 450,
+            StartProc, _T("start"), HI_Start);
+        Sleep(1000);
+        DestroyWindow(hStart);
+
         HINSTANCE HI_Log = NULL;
         hLog = CreateLogWindow(
             _T("ÈÕÖ¾"),