https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2125fec23adb22186da43…
commit 2125fec23adb22186da43351edb9d680b171f379
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Mon Mar 30 00:37:45 2020 +0200
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Mon Mar 30 00:38:33 2020 +0200
[HOTPLUG] Enable the hotplug.cpl and add the 'Safely Remove Hardware' dialog
---
dll/cpl/CMakeLists.txt | 1 +
dll/cpl/hotplug/CMakeLists.txt | 3 ++
dll/cpl/hotplug/hotplug.c | 85 ++++++++++++++++++++++++++++++----------
dll/cpl/hotplug/hotplug.rc | 18 +++++++++
dll/cpl/hotplug/lang/de-DE.rc | 18 +++++++++
dll/cpl/hotplug/lang/en-US.rc | 18 +++++++++
dll/cpl/hotplug/resource.h | 19 ++++++---
dll/cpl/hotplug/resources/1.ico | Bin 0 -> 2550 bytes
8 files changed, 136 insertions(+), 26 deletions(-)
diff --git a/dll/cpl/CMakeLists.txt b/dll/cpl/CMakeLists.txt
index beaa7e200db..d4f7bfc499d 100644
--- a/dll/cpl/CMakeLists.txt
+++ b/dll/cpl/CMakeLists.txt
@@ -4,6 +4,7 @@ add_subdirectory(appwiz)
add_subdirectory(console)
add_subdirectory(desk)
add_subdirectory(hdwwiz)
+add_subdirectory(hotplug)
add_subdirectory(inetcpl)
add_subdirectory(input)
add_subdirectory(intl)
diff --git a/dll/cpl/hotplug/CMakeLists.txt b/dll/cpl/hotplug/CMakeLists.txt
index 65bd5237a20..ec6588697c5 100644
--- a/dll/cpl/hotplug/CMakeLists.txt
+++ b/dll/cpl/hotplug/CMakeLists.txt
@@ -5,6 +5,9 @@ list(APPEND SOURCE
hotplug.c
enum.c)
+file(GLOB hotplug_rc_deps resources/*.*)
+add_rc_deps(hotplug.rc ${hotplug_rc_deps})
+
add_library(hotplug MODULE
${SOURCE}
hotplug.rc
diff --git a/dll/cpl/hotplug/hotplug.c b/dll/cpl/hotplug/hotplug.c
index 295a3cbad82..c67d0d80376 100644
--- a/dll/cpl/hotplug/hotplug.c
+++ b/dll/cpl/hotplug/hotplug.c
@@ -8,26 +8,66 @@
#include "hotplug.h"
+#define NDEBUG
+#include <debug.h>
+
// globals
HINSTANCE hApplet = 0;
/* Applets */
APPLET Applets[NUM_APPLETS] =
{
- {IDC_CPLICON, IDS_CPLNAME, IDS_CPLDESCRIPTION, InitApplet}
+ {IDI_HOTPLUG, IDS_CPLNAME, IDS_CPLDESCRIPTION, InitApplet}
};
+INT_PTR
+CALLBACK
+SafeRemovalDlgProc(
+ HWND hwndDlg,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ UNREFERENCED_PARAMETER(lParam);
+
+ switch (uMsg)
+ {
+ case WM_INITDIALOG:
+ return TRUE;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam))
+ {
+ case IDCLOSE:
+ EndDialog(hwndDlg, TRUE);
+ break;
+
+ }
+ break;
+ }
+
+ return FALSE;
+}
+
+
LONG
APIENTRY
InitApplet(
- HWND hwnd,
+ HWND hwnd,
UINT uMsg,
LPARAM wParam,
LPARAM lParam)
{
+ DPRINT1("InitApplet()\n");
+
+ DialogBox(hApplet,
+ MAKEINTRESOURCE(IDD_SAFE_REMOVE_HARDWARE_DIALOG),
+ hwnd,
+ SafeRemovalDlgProc);
+
// TODO
- return FALSE;
+ return TRUE;
}
@@ -39,29 +79,32 @@ CPlApplet(
LPARAM lParam1,
LPARAM lParam2)
{
+ UINT i = (UINT)lParam1;
+
switch(uMsg)
{
case CPL_INIT:
- {
return TRUE;
- }
+
case CPL_GETCOUNT:
- {
return NUM_APPLETS;
- }
+
case CPL_INQUIRE:
- {
- CPLINFO *CPlInfo = (CPLINFO*)lParam2;
- CPlInfo->idIcon = Applets[0].idIcon;
- CPlInfo->idName = Applets[0].idName;
- CPlInfo->idInfo = Applets[0].idDescription;
+ {
+ CPLINFO *CPlInfo = (CPLINFO*)lParam2;
+ CPlInfo->lData = 0;
+ CPlInfo->idIcon = Applets[i].idIcon;
+ CPlInfo->idName = Applets[i].idName;
+ CPlInfo->idInfo = Applets[i].idDescription;
+ }
break;
- }
+
case CPL_DBLCLK:
- {
- InitApplet(hwndCPl, uMsg, lParam1, lParam2);
+ Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
break;
- }
+
+ case CPL_STARTWPARMSW:
+ return Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
}
return FALSE;
}
@@ -76,12 +119,12 @@ DllMain(
{
UNREFERENCED_PARAMETER(lpvReserved);
- switch(dwReason)
+ switch (dwReason)
{
- case DLL_PROCESS_ATTACH:
- case DLL_THREAD_ATTACH:
- hApplet = hinstDLL;
- break;
+ case DLL_PROCESS_ATTACH:
+ case DLL_THREAD_ATTACH:
+ hApplet = hinstDLL;
+ break;
}
return TRUE;
}
diff --git a/dll/cpl/hotplug/hotplug.rc b/dll/cpl/hotplug/hotplug.rc
index 95b9ee77cc4..270b75c77ef 100644
--- a/dll/cpl/hotplug/hotplug.rc
+++ b/dll/cpl/hotplug/hotplug.rc
@@ -7,11 +7,29 @@
*/
#include <windef.h>
+#include <winuser.h>
+#include <commctrl.h>
#include "resource.h"
+LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+
#define REACTOS_VERSION_DLL
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Hardware Safe Removal Support"
#define REACTOS_STR_INTERNAL_NAME "hotplug"
#define REACTOS_STR_ORIGINAL_FILENAME "hotplug.dll"
#include <reactos/version.rc>
+
+IDI_HOTPLUG ICON "resources/1.ico"
+
+#include <reactos/manifest_hosted.rc>
+
+/* UTF-8 */
+#pragma code_page(65001)
+
+#ifdef LANGUAGE_DE_DE
+ #include "lang/de-DE.rc"
+#endif
+#ifdef LANGUAGE_EN_US
+ #include "lang/en-US.rc"
+#endif
diff --git a/dll/cpl/hotplug/lang/de-DE.rc b/dll/cpl/hotplug/lang/de-DE.rc
new file mode 100644
index 00000000000..46e04653c88
--- /dev/null
+++ b/dll/cpl/hotplug/lang/de-DE.rc
@@ -0,0 +1,18 @@
+LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL
+
+IDD_SAFE_REMOVE_HARDWARE_DIALOG DIALOGEX 0, 0, 278, 245
+CAPTION "Hardware sicher entfernen"
+STYLE DS_SHELLFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+FONT 8, "MS Shell Dlg"
+BEGIN
+ ICON IDI_HOTPLUG, IDC_SAFE_REMOVE_ICON, 7, 10, 20, 20
+ LTEXT "Wählen Sie das Gerät aus, das Sie entfernen möchten, und klicken Sie auf
""Beenden"". Sie erhalten eine Benachrichtigung, wenn Sie das Gerät
sicher entfernen können.", IDC_STATIC, 36, 12, 234, 24, WS_CHILD | WS_VISIBLE |
WS_GROUP
+ LTEXT "&Hardwarekomponenten:", IDC_STATIC, 7, 42, 248, 8, WS_CHILD |
WS_VISIBLE | WS_GROUP
+ CONTROL "", IDC_SAFE_REMOVE_DEVICE_TREE, "SysTreeView32",
TVS_HASBUTTONS | TVS_HASLINES | TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | WS_CHILD |
WS_VISIBLE | WS_BORDER | WS_GROUP | WS_TABSTOP, 7, 52, 264, 102
+ LTEXT "", IDC_SAFE_REMOVE_TEXT, 7, 156, 264, 16, WS_CHILD | WS_VISIBLE |
WS_GROUP
+ PUSHBUTTON "E&igenschaften", IDC_SAFE_REMOVE_PROPERTIES, 158, 178, 55,
14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
+ PUSHBUTTON "B&eenden", IDC_SAFE_REMOVE_STOP, 216, 178, 55, 14, WS_CHILD
| WS_VISIBLE | WS_TABSTOP
+ CONTROL "", IDC_STATIC, "static", SS_CENTER | SS_SUNKEN |
WS_CHILD | WS_VISIBLE, 7, 200, 264, 1
+ AUTOCHECKBOX "&Gerätekomponenten anzeigen",
IDC_SAFE_REMOVE_DISPLAY_COMPONENTS, 7, 208, 112, 10, WS_CHILD | WS_VISIBLE | WS_TABSTOP
+ PUSHBUTTON "&Schließen", IDCLOSE, 216, 224, 55, 14, WS_CHILD |
WS_VISIBLE | WS_TABSTOP
+END
diff --git a/dll/cpl/hotplug/lang/en-US.rc b/dll/cpl/hotplug/lang/en-US.rc
new file mode 100644
index 00000000000..1ac4e2e06e2
--- /dev/null
+++ b/dll/cpl/hotplug/lang/en-US.rc
@@ -0,0 +1,18 @@
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+
+IDD_SAFE_REMOVE_HARDWARE_DIALOG DIALOGEX 0, 0, 278, 245
+CAPTION "Safely Remove Hardware"
+STYLE DS_SHELLFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+FONT 8, "MS Shell Dlg"
+BEGIN
+ ICON IDI_HOTPLUG, IDC_SAFE_REMOVE_ICON, 7, 10, 20, 20
+ LTEXT "Select the device you want to unplug or eject, and then click Stop. When
ReactOS notifies you that it is safe to do so unplug the device from your computer.",
IDC_STATIC, 36, 12, 234, 24, WS_CHILD | WS_VISIBLE | WS_GROUP
+ LTEXT "&Hardware devices:", IDC_STATIC, 7, 42, 248, 8, WS_CHILD |
WS_VISIBLE | WS_GROUP
+ CONTROL "", IDC_SAFE_REMOVE_DEVICE_TREE, "SysTreeView32",
TVS_HASBUTTONS | TVS_HASLINES | TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | WS_CHILD |
WS_VISIBLE | WS_BORDER | WS_GROUP | WS_TABSTOP, 7, 52, 264, 102
+ LTEXT "", IDC_SAFE_REMOVE_TEXT, 7, 156, 264, 16, WS_CHILD | WS_VISIBLE |
WS_GROUP
+ PUSHBUTTON "&Properties", IDC_SAFE_REMOVE_PROPERTIES, 158, 178, 55, 14,
WS_CHILD | WS_VISIBLE | WS_TABSTOP
+ PUSHBUTTON "&Stop", IDC_SAFE_REMOVE_STOP, 216, 178, 55, 14, WS_CHILD |
WS_VISIBLE | WS_TABSTOP
+ CONTROL "", IDC_STATIC, "static", SS_CENTER | SS_SUNKEN |
WS_CHILD | WS_VISIBLE, 7, 200, 264, 1
+ AUTOCHECKBOX "&Display device components",
IDC_SAFE_REMOVE_DISPLAY_COMPONENTS, 7, 208, 112, 10, WS_CHILD | WS_VISIBLE | WS_TABSTOP
+ PUSHBUTTON "&Close", IDCLOSE, 216, 224, 55, 14, WS_CHILD | WS_VISIBLE |
WS_TABSTOP
+END
diff --git a/dll/cpl/hotplug/resource.h b/dll/cpl/hotplug/resource.h
index 35f5f2a5195..5ad44b59c03 100644
--- a/dll/cpl/hotplug/resource.h
+++ b/dll/cpl/hotplug/resource.h
@@ -1,12 +1,21 @@
#pragma once
+/* Icon ids */
+#define IDI_HOTPLUG 100
+
/* Dialog ids */
-#define IDD_SAFE_REMOVE_HARDWARE_DIALOG 100
-#define IDD_CONFIRM_STOP_HARDWARE_DIALOG 101
+#define IDC_STATIC -1
+
+#define IDD_SAFE_REMOVE_HARDWARE_DIALOG 300
+#define IDC_SAFE_REMOVE_ICON 301
+#define IDC_SAFE_REMOVE_DEVICE_TREE 302
+#define IDC_SAFE_REMOVE_TEXT 303
+#define IDC_SAFE_REMOVE_PROPERTIES 304
+#define IDC_SAFE_REMOVE_STOP 305
+#define IDC_SAFE_REMOVE_DISPLAY_COMPONENTS 306
+
+#define IDD_CONFIRM_STOP_HARDWARE_DIALOG 310
/* Resource strings ids */
#define IDS_CPLNAME 1000
#define IDS_CPLDESCRIPTION 1001
-
-/* Control ids */
-#define IDC_CPLICON 10000
diff --git a/dll/cpl/hotplug/resources/1.ico b/dll/cpl/hotplug/resources/1.ico
new file mode 100644
index 00000000000..f615f0ebd3c
Binary files /dev/null and b/dll/cpl/hotplug/resources/1.ico differ