[DEVMGMT]
authorEric Kohl <eric.kohl@reactos.org>
Tue, 20 Mar 2012 22:11:51 +0000 (22:11 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Tue, 20 Mar 2012 22:11:51 +0000 (22:11 +0000)
Implement the 'View/Devices by Connection' feature. It runs very well on windows XP but fails on ReactOS. Needs to be investigated.

svn path=/trunk/; revision=56197

24 files changed:
reactos/base/applications/mscutils/devmgmt/enumdevices.c
reactos/base/applications/mscutils/devmgmt/lang/bg-BG.rc
reactos/base/applications/mscutils/devmgmt/lang/cs-CZ.rc
reactos/base/applications/mscutils/devmgmt/lang/de-DE.rc
reactos/base/applications/mscutils/devmgmt/lang/el-GR.rc
reactos/base/applications/mscutils/devmgmt/lang/en-US.rc
reactos/base/applications/mscutils/devmgmt/lang/es-ES.rc
reactos/base/applications/mscutils/devmgmt/lang/fr-FR.rc
reactos/base/applications/mscutils/devmgmt/lang/id-ID.rc
reactos/base/applications/mscutils/devmgmt/lang/it-IT.rc
reactos/base/applications/mscutils/devmgmt/lang/ja-JP.rc
reactos/base/applications/mscutils/devmgmt/lang/ko-KR.rc
reactos/base/applications/mscutils/devmgmt/lang/no-NO.rc
reactos/base/applications/mscutils/devmgmt/lang/pl-PL.rc
reactos/base/applications/mscutils/devmgmt/lang/ro-RO.rc
reactos/base/applications/mscutils/devmgmt/lang/ru-RU.rc
reactos/base/applications/mscutils/devmgmt/lang/sk-SK.rc
reactos/base/applications/mscutils/devmgmt/lang/sv-SE.rc
reactos/base/applications/mscutils/devmgmt/lang/th-TH.rc
reactos/base/applications/mscutils/devmgmt/lang/uk-UA.rc
reactos/base/applications/mscutils/devmgmt/lang/zh-CN.rc
reactos/base/applications/mscutils/devmgmt/mainwnd.c
reactos/base/applications/mscutils/devmgmt/precomp.h
reactos/base/applications/mscutils/devmgmt/resource.h

index b7b24d1..51c07f7 100644 (file)
@@ -421,6 +421,165 @@ ListDevicesByType(HWND hTreeView,
 }
 
 
+static HTREEITEM
+AddDeviceToTree(HWND hTreeView,
+                HTREEITEM hRoot,
+                DEVINST dnDevInst)
+{
+    TCHAR DevName[MAX_DEV_LEN];
+    TCHAR FriendlyName[MAX_DEV_LEN];
+    TCHAR ClassGuidString[MAX_GUID_STRING_LEN];
+    GUID ClassGuid;
+    ULONG ulLength;
+    LPTSTR DeviceID;
+    INT ClassImage = 24;
+    CONFIGRET cr;
+
+    cr = CM_Get_Device_ID(dnDevInst,
+                          DevName,
+                          MAX_DEV_LEN,
+                          0);
+    if (cr != CR_SUCCESS)
+        return NULL;
+
+    ulLength = MAX_DEV_LEN * sizeof(TCHAR);
+    cr = CM_Get_DevNode_Registry_Property(dnDevInst,
+                                          CM_DRP_FRIENDLYNAME,
+                                          NULL,
+                                          FriendlyName,
+                                          &ulLength,
+                                          0);
+    if (cr != CR_SUCCESS)
+    {
+        ulLength = MAX_DEV_LEN * sizeof(TCHAR);
+        cr = CM_Get_DevNode_Registry_Property(dnDevInst,
+                                              CM_DRP_DEVICEDESC,
+                                              NULL,
+                                              FriendlyName,
+                                              &ulLength,
+                                              0);
+        if (cr != CR_SUCCESS)
+            return NULL;
+    }
+
+    ulLength = MAX_GUID_STRING_LEN * sizeof(TCHAR);
+    cr = CM_Get_DevNode_Registry_Property(dnDevInst,
+                                          CM_DRP_CLASSGUID,
+                                          NULL,
+                                          ClassGuidString,
+                                          &ulLength,
+                                          0);
+    if (cr == CR_SUCCESS)
+    {
+        pSetupGuidFromString(ClassGuidString, &ClassGuid);
+
+        if (!SetupDiGetClassImageIndex(&ImageListData,
+                                       &ClassGuid,
+                                       &ClassImage))
+        {
+            /* FIXME: can we do this?
+             * Set the blank icon: IDI_SETUPAPI_BLANK = 41
+             * it'll be image 24 in the imagelist */
+            ClassImage = 24;
+        }
+    }
+
+    if (DevName != NULL)
+    {
+        DeviceID = HeapAlloc(GetProcessHeap(),
+                             0,
+                             (lstrlen(DevName) + 1) * sizeof(TCHAR));
+        if (DeviceID == NULL)
+        {
+            return NULL;
+        }
+
+        lstrcpy(DeviceID, DevName);
+    }
+
+    return InsertIntoTreeView(hTreeView,
+                              hRoot,
+                              FriendlyName,
+                              DeviceID,
+                              ClassImage,
+                              0);
+}
+
+
+static VOID
+EnumChildDevices(HWND hTreeView,
+                 HTREEITEM hRoot,
+                 DEVINST dnParentDevInst)
+{
+    HTREEITEM hDevItem;
+    DEVINST dnDevInst;
+    CONFIGRET cr;
+
+    cr = CM_Get_Child(&dnDevInst,
+                      dnParentDevInst,
+                      0);
+    if (cr != CR_SUCCESS)
+        return;
+
+    hDevItem = AddDeviceToTree(hTreeView,
+                               hRoot,
+                               dnDevInst);
+    if (hDevItem == NULL)
+        return;
+
+    EnumChildDevices(hTreeView,
+                     hDevItem,
+                     dnDevInst);
+
+    while (cr == CR_SUCCESS)
+    {
+        cr = CM_Get_Sibling(&dnDevInst,
+                            dnDevInst,
+                            0);
+        if (cr != CR_SUCCESS)
+            break;
+
+        hDevItem = AddDeviceToTree(hTreeView,
+                                   hRoot,
+                                   dnDevInst);
+        if (hDevItem == NULL)
+            break;
+
+        EnumChildDevices(hTreeView,
+                         hDevItem,
+                         dnDevInst);
+    }
+
+    (void)TreeView_SortChildren(hTreeView,
+                                hRoot,
+                                0);
+}
+
+
+VOID
+ListDevicesByConnection(HWND hTreeView,
+                        HTREEITEM hRoot)
+{
+    DEVINST devInst;
+    CONFIGRET cr;
+
+    cr = CM_Locate_DevNode(&devInst,
+                           NULL,
+                           CM_LOCATE_DEVNODE_NORMAL);
+    if (cr == CR_SUCCESS)
+        EnumChildDevices(hTreeView,
+                         hRoot,
+                         devInst);
+
+    (void)TreeView_Expand(hTreeView,
+                          hRoot,
+                          TVE_EXPAND);
+
+    (void)TreeView_SelectItem(hTreeView,
+                              hRoot);
+}
+
+
 HTREEITEM
 InitTreeView(HWND hTreeView)
 {
index 994e84f..dd7feb6 100644 (file)
@@ -1,4 +1,4 @@
-LANGUAGE LANG_BULGARIAN, SUBLANG_DEFAULT
+LANGUAGE LANG_BULGARIAN, SUBLANG_DEFAULT
 
 IDR_MAINMENU MENU
 BEGIN
@@ -16,10 +16,10 @@ BEGIN
   END
   POPUP "Изглед"
   BEGIN
-    MENUITEM "Устройствата според вид",         IDC_DEVBYTYPE, CHECKED
-    MENUITEM "Устройствата според свързването",   IDC_STATIC, GRAYED
-    MENUITEM "Средствата според вида",       IDC_STATIC, GRAYED
-    MENUITEM "Средствата според свързването", IDC_STATIC, GRAYED
+    MENUITEM "Устройствата според вид",         IDC_DEVBYTYPE
+    MENUITEM "Устройствата според свързването",   IDC_DEVBYCONN
+    MENUITEM "Средствата според вида",       IDC_RESBYTYPE, GRAYED
+    MENUITEM "Средствата според свързването", IDC_RESBYCONN, GRAYED
   END
   POPUP "Помощ"
   BEGIN
index fff45b9..c1661ed 100644 (file)
@@ -16,10 +16,10 @@ BEGIN
   END
   POPUP "&Zobrazení"
   BEGIN
-    MENUITEM "Zařízení podle typu",        IDC_DEVBYTYPE, CHECKED
-    MENUITEM "Zařízení podle připojení",   IDC_STATIC, GRAYED
-    MENUITEM "Prostředky podle typu",      IDC_STATIC, GRAYED
-    MENUITEM "Prostředky podle připojení", IDC_STATIC, GRAYED
+    MENUITEM "Zařízení podle typu",        IDC_DEVBYTYPE
+    MENUITEM "Zařízení podle připojení",   IDC_DEVBYCONN
+    MENUITEM "Prostředky podle typu",      IDC_RESBYTYPE, GRAYED
+    MENUITEM "Prostředky podle připojení", IDC_RESBYCONN, GRAYED
   END
   POPUP "Nápověda"
   BEGIN
index b4b8cf5..599597a 100644 (file)
@@ -4,27 +4,27 @@ IDR_MAINMENU MENU
 BEGIN
   POPUP "&Datei"
   BEGIN
-    MENUITEM "&Beenden",                   IDC_EXIT
+    MENUITEM "&Beenden",                  IDC_EXIT
   END
   POPUP "Aktion"
   BEGIN
     MENUITEM "Drucken",                   IDC_PRINT, GRAYED
     MENUITEM SEPARATOR
-    MENUITEM "Eigenschaften",              IDC_PROP, GRAYED
+    MENUITEM "Eigenschaften",             IDC_PROP, GRAYED
     MENUITEM SEPARATOR
-    MENUITEM "Hilfe",                    IDC_PROGHELP, GRAYED
+    MENUITEM "Hilfe",                     IDC_PROGHELP, GRAYED
   END
   POPUP "Ansicht"
   BEGIN
-    MENUITEM "Geräte nach Typ",         IDC_DEVBYTYPE, CHECKED
-    MENUITEM "Geräte nach Verbindung",   IDC_STATIC, GRAYED
-    MENUITEM "Resourcen nach Typ",       IDC_STATIC, GRAYED
-    MENUITEM "Resourcen nach Verbindung", IDC_STATIC, GRAYED
+    MENUITEM "Geräte nach Typ",           IDC_DEVBYTYPE
+    MENUITEM "Geräte nach Verbindung",    IDC_DEVBYCONN
+    MENUITEM "Resourcen nach Typ",        IDC_RESBYTYPE, GRAYED
+    MENUITEM "Resourcen nach Verbindung", IDC_RESBYCONN, GRAYED
   END
   POPUP "&?"
   BEGIN
-    MENUITEM "Hilfe",                    IDC_PROGHELP
-    MENUITEM "Info",                   IDC_ABOUT
+    MENUITEM "Hilfe",                     IDC_PROGHELP
+    MENUITEM "Info",                      IDC_ABOUT
   END
 END
 
@@ -32,9 +32,9 @@ IDR_POPUP MENU
 BEGIN
   POPUP "popup"
   BEGIN
-    MENUITEM "Eigenschaften",              IDC_PROP, GRAYED
+    MENUITEM "Eigenschaften",             IDC_PROP, GRAYED
     MENUITEM SEPARATOR
-    MENUITEM "Hilfe",                    IDC_PROGHELP
+    MENUITEM "Hilfe",                     IDC_PROGHELP
   END
 END
 
index 10464a9..97ea1b2 100644 (file)
@@ -1,4 +1,4 @@
-LANGUAGE LANG_GREEK, SUBLANG_DEFAULT
+LANGUAGE LANG_GREEK, SUBLANG_DEFAULT
 
 IDR_MAINMENU MENU
 BEGIN
@@ -16,10 +16,10 @@ BEGIN
   END
   POPUP "Εμφάνιση"
   BEGIN
-    MENUITEM "Συσκευές ανά τύπο",    IDC_DEVBYTYPE, CHECKED
-    MENUITEM "Συσκευές ανά σύνδεση", IDC_STATIC, GRAYED
-    MENUITEM "Πηγές ανά τύπο",       IDC_STATIC, GRAYED
-    MENUITEM "Πηγές ανά σύνδεση",    IDC_STATIC, GRAYED
+    MENUITEM "Συσκευές ανά τύπο",    IDC_DEVBYTYPE
+    MENUITEM "Συσκευές ανά σύνδεση", IDC_DEVBYCONN
+    MENUITEM "Πηγές ανά τύπο",       IDC_RESBYTYPE, GRAYED
+    MENUITEM "Πηγές ανά σύνδεση",    IDC_RESBYCONN, GRAYED
   END
   POPUP "Βοήθεια"
   BEGIN
index 19f6474..dad497e 100644 (file)
@@ -16,10 +16,10 @@ BEGIN
   END
   POPUP "View"
   BEGIN
-    MENUITEM "Devices by type",         IDC_DEVBYTYPE, CHECKED
-    MENUITEM "Devices by connection",   IDC_STATIC, GRAYED
-    MENUITEM "Resources by type",       IDC_STATIC, GRAYED
-    MENUITEM "Resources by connection", IDC_STATIC, GRAYED
+    MENUITEM "Devices by type",         IDC_DEVBYTYPE
+    MENUITEM "Devices by connection",   IDC_DEVBYCONN
+    MENUITEM "Resources by type",       IDC_RESBYTYPE, GRAYED
+    MENUITEM "Resources by connection", IDC_RESBYCONN, GRAYED
   END
   POPUP "Help"
   BEGIN
index 33b4b0a..e524027 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/*
  * Spanish Language resource file
  * Traducido por: Javier Remacha 2007-12-21
  */
@@ -21,10 +21,10 @@ BEGIN
   END
   POPUP "Ver"
   BEGIN
-    MENUITEM "Dispositivos por tipo",         IDC_DEVBYTYPE, CHECKED
-    MENUITEM "Dispositivos por conexión",   IDC_STATIC, GRAYED
-    MENUITEM "Recursos por tipo",       IDC_STATIC, GRAYED
-    MENUITEM "Recursos por conexión", IDC_STATIC, GRAYED
+    MENUITEM "Dispositivos por tipo",     IDC_DEVBYTYPE
+    MENUITEM "Dispositivos por conexión", IDC_DEVBYCONN
+    MENUITEM "Recursos por tipo",         IDC_RESBYTYPE, GRAYED
+    MENUITEM "Recursos por conexión",     IDC_RESBYCONN, GRAYED
   END
   POPUP "Ayuda"
   BEGIN
index 42c6ffa..c3130eb 100644 (file)
@@ -1,4 +1,4 @@
-LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL
+LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL
 
 IDR_MAINMENU MENU
 BEGIN
@@ -16,10 +16,10 @@ BEGIN
   END
   POPUP "Affichage"
   BEGIN
-    MENUITEM "Périphériques par type",         IDC_DEVBYTYPE, CHECKED
-    MENUITEM "Périphériques par connexion",   IDC_STATIC, GRAYED
-    MENUITEM "Ressources par type",       IDC_STATIC, GRAYED
-    MENUITEM "Ressources par connexion", IDC_STATIC, GRAYED
+    MENUITEM "Périphériques par type",      IDC_DEVBYTYPE
+    MENUITEM "Périphériques par connexion", IDC_DEVBYCONN
+    MENUITEM "Ressources par type",         IDC_RESBYTYPE, GRAYED
+    MENUITEM "Ressources par connexion",    IDC_RESBYCONN, GRAYED
   END
   POPUP "Aide"
   BEGIN
index 7fca658..ce2e89e 100644 (file)
@@ -16,10 +16,10 @@ BEGIN
   END
   POPUP "Lihat"
   BEGIN
-    MENUITEM "Device dengan tipe",      IDC_DEVBYTYPE, CHECKED
-    MENUITEM "Device dengan koneksi",   IDC_STATIC, GRAYED
-    MENUITEM "Resource dengan tipe",    IDC_STATIC, GRAYED
-    MENUITEM "Resource dengan koneksi", IDC_STATIC, GRAYED
+    MENUITEM "Device dengan tipe",      IDC_DEVBYTYPE
+    MENUITEM "Device dengan koneksi",   IDC_DEVBYCONN
+    MENUITEM "Resource dengan tipe",    IDC_RESBYTYPE, GRAYED
+    MENUITEM "Resource dengan koneksi", IDC_RESBYCONN, GRAYED
   END
   POPUP "Bantuan"
   BEGIN
index 0f20fd4..4124e97 100644 (file)
@@ -1,4 +1,4 @@
-LANGUAGE LANG_ITALIAN, SUBLANG_NEUTRAL
+LANGUAGE LANG_ITALIAN, SUBLANG_NEUTRAL
 
 IDR_MAINMENU MENU
 BEGIN
@@ -16,10 +16,10 @@ BEGIN
   END
   POPUP "Visualizza"
   BEGIN
-    MENUITEM "Dispositivi per tipo",        IDC_DEVBYTYPE, CHECKED
-    MENUITEM "Dispositivi per connessione", IDC_STATIC, GRAYED
-    MENUITEM "Risorse per tipo",            IDC_STATIC, GRAYED
-    MENUITEM "Risorse per connessione",     IDC_STATIC, GRAYED
+    MENUITEM "Dispositivi per tipo",        IDC_DEVBYTYPE
+    MENUITEM "Dispositivi per connessione", IDC_DEVBYCONN
+    MENUITEM "Risorse per tipo",            IDC_RESBYTYPE, GRAYED
+    MENUITEM "Risorse per connessione",     IDC_RESBYCONN, GRAYED
   END
   POPUP "Aiuto"
   BEGIN
index 651955b..0c67d9d 100644 (file)
@@ -1,4 +1,4 @@
-LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT
+LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT
 
 IDR_MAINMENU MENU
 BEGIN
@@ -16,10 +16,10 @@ BEGIN
   END
   POPUP "表 示"
   BEGIN
-    MENUITEM "デバイス (種類別)",       IDC_DEVBYTYPE, CHECKED
-    MENUITEM "デバイス (接続別)",       IDC_STATIC, GRAYED
-    MENUITEM "リソ ース (種類別)",      IDC_STATIC, GRAYED
-    MENUITEM "リソ ース (接続別)",      IDC_STATIC, GRAYED
+    MENUITEM "デバイス (種類別)",       IDC_DEVBYTYPE
+    MENUITEM "デバイス (接続別)",       IDC_DEVBYCONN
+    MENUITEM "リソ ース (種類別)",      IDC_RESBYTYPE, GRAYED
+    MENUITEM "リソ ース (接続別)",      IDC_RESBYCONN, GRAYED
   END
   POPUP "ヘルプ"
   BEGIN
index 9ab08c0..c661fcf 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/*
  * Korean translation by manatails007(www.manatails007.org)
  */
 
@@ -20,10 +20,10 @@ BEGIN
   END
   POPUP "보기"
   BEGIN
-    MENUITEM "Devices by type",         IDC_DEVBYTYPE, CHECKED
-    MENUITEM "Devices by connection",   IDC_STATIC, GRAYED
-    MENUITEM "Resources by type",       IDC_STATIC, GRAYED
-    MENUITEM "Resources by connection", IDC_STATIC, GRAYED
+    MENUITEM "Devices by type",         IDC_DEVBYTYPE
+    MENUITEM "Devices by connection",   IDC_DEVBYCONN
+    MENUITEM "Resources by type",       IDC_RESBYTYPE, GRAYED
+    MENUITEM "Resources by connection", IDC_RESBYCONN, GRAYED
   END
   POPUP "도움말"
   BEGIN
index f580528..2fd1fff 100644 (file)
@@ -1,4 +1,4 @@
-LANGUAGE LANG_NORWEGIAN, SUBLANG_NEUTRAL
+LANGUAGE LANG_NORWEGIAN, SUBLANG_NEUTRAL
 
 IDR_MAINMENU MENU
 BEGIN
@@ -16,10 +16,10 @@ BEGIN
   END
   POPUP "Vis"
   BEGIN
-    MENUITEM "Enheter etter type",         IDC_DEVBYTYPE, CHECKED
-    MENUITEM "Enheter etter tilkobling",   IDC_STATIC, GRAYED
-    MENUITEM "Ressurser etter type",       IDC_STATIC, GRAYED
-    MENUITEM "Ressurser etter tilkobling", IDC_STATIC, GRAYED
+    MENUITEM "Enheter etter type",         IDC_DEVBYTYPE
+    MENUITEM "Enheter etter tilkobling",   IDC_DEVBYCONN
+    MENUITEM "Ressurser etter type",       IDC_RESBYTYPE, GRAYED
+    MENUITEM "Ressurser etter tilkobling", IDC_RESBYCONN, GRAYED
   END
   POPUP "Hjelp"
   BEGIN
index b7b2f8b..b0dbdf9 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/*
  *         translated by xrogers
  *         xxrogers@users.sourceforge.net
  *         https://sourceforge.net/projects/reactospl
@@ -23,10 +23,10 @@ BEGIN
   END
   POPUP "&Widok"
   BEGIN
-    MENUITEM "Urządzenia w&edług typu",         IDC_DEVBYTYPE, CHECKED
-    MENUITEM "Ur&ządzenia według połączenia",   IDC_STATIC, GRAYED
-    MENUITEM "Zaso&by według typu",       IDC_STATIC, GRAYED
-    MENUITEM "Za&soby według połączenia", IDC_STATIC, GRAYED
+    MENUITEM "Urządzenia w&edług typu",       IDC_DEVBYTYPE
+    MENUITEM "Ur&ządzenia według połączenia", IDC_DEVBYCONN
+    MENUITEM "Zaso&by według typu",           IDC_RESBYTYPE, GRAYED
+    MENUITEM "Za&soby według połączenia",     IDC_RESBYCONN, GRAYED
   END
   POPUP "Pomo&c"
   BEGIN
index 2bd7e04..59bc162 100644 (file)
@@ -1,4 +1,4 @@
-//2011.10.19 - Fulea Ștefan: minor changes
+//2011.10.19 - Fulea Ștefan: minor changes
 LANGUAGE LANG_ROMANIAN, SUBLANG_NEUTRAL
 
 IDR_MAINMENU MENU
@@ -17,10 +17,10 @@ BEGIN
   END
   POPUP "&Afișare"
   BEGIN
-    MENUITEM "Dispozitive după &tip",         IDC_DEVBYTYPE, CHECKED
-    MENUITEM "Dispozitive după &conexiune",   IDC_STATIC, GRAYED
-    MENUITEM "Resurse după t&ip",             IDC_STATIC, GRAYED
-    MENUITEM "Resurse după c&onexiune",       IDC_STATIC, GRAYED
+    MENUITEM "Dispozitive după &tip",         IDC_DEVBYTYPE
+    MENUITEM "Dispozitive după &conexiune",   IDC_DEVBYCONN
+    MENUITEM "Resurse după t&ip",             IDC_RESBYTYPE, GRAYED
+    MENUITEM "Resurse după c&onexiune",       IDC_RESBYCONN, GRAYED
   END
   POPUP "&?"
   BEGIN
index d3c0d0b..a820b2d 100644 (file)
@@ -1,4 +1,4 @@
-// Russian language resource file (Dmitry Chapyshev, 2007-06-10)
+// Russian language resource file (Dmitry Chapyshev, 2007-06-10)
 
 LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
 
@@ -18,10 +18,10 @@ BEGIN
   END
   POPUP "Вид"
   BEGIN
-    MENUITEM "Устройства по типу",         IDC_DEVBYTYPE, CHECKED
-    MENUITEM "Устройства по подключению",   IDC_STATIC, GRAYED
-    MENUITEM "Ресурсы по типу",       IDC_STATIC, GRAYED
-    MENUITEM "Ресурсы по подключению", IDC_STATIC, GRAYED
+    MENUITEM "Устройства по типу",        IDC_DEVBYTYPE
+    MENUITEM "Устройства по подключению", IDC_DEVBYCONN
+    MENUITEM "Ресурсы по типу",           IDC_RESBYTYPE, GRAYED
+    MENUITEM "Ресурсы по подключению",    IDC_RESBYCONN, GRAYED
   END
   POPUP "Справка"
   BEGIN
index c6a4cde..3ad03e8 100644 (file)
@@ -1,4 +1,4 @@
-/* TRANSLATOR:   Mário Kačmár /Mario Kacmar/ aka Kario (kario@szm.sk)
+/* TRANSLATOR:   Mário Kačmár /Mario Kacmar/ aka Kario (kario@szm.sk)
  * DATE OF TR.:  14-02-2008
  * LAST CHANGE:  29-08-2008
  */
@@ -21,10 +21,10 @@ BEGIN
   END
   POPUP "Zobraziť"
   BEGIN
-    MENUITEM "Zariadenia podľa typu",         IDC_DEVBYTYPE, CHECKED
-    MENUITEM "Zariadenia podľa pripojenia",   IDC_STATIC, GRAYED
-    MENUITEM "Prostriedky podľa typu",       IDC_STATIC, GRAYED
-    MENUITEM "Prostriedky podľa pripojenia", IDC_STATIC, GRAYED
+    MENUITEM "Zariadenia podľa typu",        IDC_DEVBYTYPE
+    MENUITEM "Zariadenia podľa pripojenia",  IDC_DEVBYCONN
+    MENUITEM "Prostriedky podľa typu",       IDC_RESBYTYPE, GRAYED
+    MENUITEM "Prostriedky podľa pripojenia", IDC_RESBYCONN, GRAYED
   END
   POPUP "Pomocník"
   BEGIN
index f0585f1..e92c6ab 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/*
  * PROJECT:      ReactOS MSCUTILS
  * FILE:         base\applications\mscutils\devmgmt\lang\sv-SE.rc
  * PURPOSE:      Swedish resource file
@@ -23,10 +23,10 @@ BEGIN
   END
   POPUP "Visa"
   BEGIN
-    MENUITEM "Enheter efter typ",         IDC_DEVBYTYPE, CHECKED
-    MENUITEM "Enheter efter koppling",   IDC_STATIC, GRAYED
-    MENUITEM "Resurcer efter typ",       IDC_STATIC, GRAYED
-    MENUITEM "Resurcer efter koppling", IDC_STATIC, GRAYED
+    MENUITEM "Enheter efter typ",       IDC_DEVBYTYPE
+    MENUITEM "Enheter efter koppling",  IDC_DEVBYCONN
+    MENUITEM "Resurcer efter typ",      IDC_RESBYTYPE, GRAYED
+    MENUITEM "Resurcer efter koppling", IDC_RESBYCONN, GRAYED
   END
   POPUP "Hjälp"
   BEGIN
index 3244788..afcc06f 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/*
  * PROJECT:     ReactOS Device Management
  * LICENSE:     GPL - See COPYING in the top level directory
  * FILE:        base/applications/devmgmt/lang/th-TH.rc
@@ -24,10 +24,10 @@ BEGIN
   END
   POPUP "มุมมอง"
   BEGIN
-    MENUITEM "อุปกรณ์แบ่งตามประเภท",         IDC_DEVBYTYPE, CHECKED
-    MENUITEM "อุปกรณ์แบ่งตามการเชื่อมต่อ",   IDC_STATIC, GRAYED
-    MENUITEM "แหล่งข้อมูลตามประเภท",         IDC_STATIC, GRAYED
-    MENUITEM "แหล่งข้อมูลตามการเชื่อมต่อ",   IDC_STATIC, GRAYED
+    MENUITEM "อุปกรณ์แบ่งตามประเภท",         IDC_DEVBYTYPE
+    MENUITEM "อุปกรณ์แบ่งตามการเชื่อมต่อ",   IDC_DEVBYCONN
+    MENUITEM "แหล่งข้อมูลตามประเภท",         IDC_RESBYTYPE, GRAYED
+    MENUITEM "แหล่งข้อมูลตามการเชื่อมต่อ",   IDC_RESBYCONN, GRAYED
   END
   POPUP "ช่วยเหลือ"
   BEGIN
index aa0c1e1..1a5f1e7 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/*
  * PROJECT:     ReactOS Device Management
  * LICENSE:     GPL - See COPYING in the top level directory
  * FILE:        base/applications/devmgmt/lang/uk-UA.rc
@@ -24,10 +24,10 @@ BEGIN
   END
   POPUP "Вигляд"
   BEGIN
-    MENUITEM "Пристрої за типом",       IDC_DEVBYTYPE, CHECKED
-    MENUITEM "Пристрої за підключенням",   IDC_STATIC, GRAYED
-    MENUITEM "Ресурси за типом",        IDC_STATIC, GRAYED
-    MENUITEM "Ресурси за підключенням", IDC_STATIC, GRAYED
+    MENUITEM "Пристрої за типом",        IDC_DEVBYTYPE
+    MENUITEM "Пристрої за підключенням", IDC_DEVBYCONN
+    MENUITEM "Ресурси за типом",         IDC_RESBYTYPE, GRAYED
+    MENUITEM "Ресурси за підключенням",  IDC_RESBYCONN, GRAYED
   END
   POPUP "Довідка"
   BEGIN
index 4235d8d..71b508a 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/*
  * Translated by Song Fuchang (0xfc) <sfc_0@yahoo.com.cn>
  */
 
@@ -20,10 +20,10 @@ BEGIN
   END
   POPUP "查看"
   BEGIN
-    MENUITEM "设备,按类型",              IDC_DEVBYTYPE, CHECKED
-    MENUITEM "设备,按连接",              IDC_STATIC, GRAYED
-    MENUITEM "资源,按类型",              IDC_STATIC, GRAYED
-    MENUITEM "资源,按连接",              IDC_STATIC, GRAYED
+    MENUITEM "设备,按类型",              IDC_DEVBYTYPE
+    MENUITEM "设备,按连接",              IDC_DEVBYCONN
+    MENUITEM "资源,按类型",              IDC_RESBYTYPE, GRAYED
+    MENUITEM "资源,按连接",              IDC_RESBYCONN, GRAYED
   END
   POPUP "帮助"
   BEGIN
index 79af9f5..f6a5313 100644 (file)
@@ -203,18 +203,30 @@ CreateStatusBar(PMAIN_WND_INFO Info)
 static DWORD WINAPI
 DeviceEnumThread(LPVOID lpParameter)
 {
+    PMAIN_WND_INFO Info;
     HTREEITEM hRoot;
-    HWND *hTreeView;
 
-    hTreeView = (HWND *)lpParameter;
+    Info = (PMAIN_WND_INFO)lpParameter;
 
-    if (*hTreeView)
-        FreeDeviceStrings(*hTreeView);
+    if (Info->hTreeView)
+        FreeDeviceStrings(Info->hTreeView);
 
-    hRoot = InitTreeView(*hTreeView);
+    hRoot = InitTreeView(Info->hTreeView);
     if (hRoot)
     {
-        ListDevicesByType(*hTreeView, hRoot);
+        switch (Info->Display)
+        {
+            case DevicesByType:
+                ListDevicesByType(Info->hTreeView, hRoot);
+                break;
+
+            case DevicesByConnection:
+                ListDevicesByConnection(Info->hTreeView, hRoot);
+                break;
+
+            default:
+                break;
+        }
         return 0;
     }
 
@@ -222,6 +234,35 @@ DeviceEnumThread(LPVOID lpParameter)
 }
 
 
+static VOID
+UpdateViewMenu(PMAIN_WND_INFO Info)
+{
+    UINT id = IDC_DEVBYTYPE;
+
+    switch (Info->Display)
+    {
+        case DevicesByType:
+            id = IDC_DEVBYTYPE;
+            break;
+        case DevicesByConnection:
+            id = IDC_DEVBYCONN;
+            break;
+        case RessourcesByType:
+            id = IDC_RESBYTYPE;
+            break;
+        case RessourcesByConnection:
+            id = IDC_RESBYCONN;
+            break;
+    }
+
+    CheckMenuRadioItem(GetMenu(Info->hMainWnd),
+                       IDC_DEVBYTYPE,
+                       IDC_RESBYCONN,
+                       id,
+                       MF_BYCOMMAND);
+}
+
+
 static BOOL
 InitMainWnd(PMAIN_WND_INFO Info)
 {
@@ -240,6 +281,8 @@ InitMainWnd(PMAIN_WND_INFO Info)
     if (!CreateStatusBar(Info))
         DisplayString(_T("error creating status bar"));
 
+    UpdateViewMenu(Info);
+
     /* make 'properties' bold */
     hMenu = GetMenu(Info->hMainWnd);
     hMenu = GetSubMenu(hMenu, 1);
@@ -256,7 +299,7 @@ InitMainWnd(PMAIN_WND_INFO Info)
     DevEnumThread = CreateThread(NULL,
                                  0,
                                  DeviceEnumThread,
-                                 &Info->hTreeView,
+                                 Info,
                                  0,
                                  NULL);
     if (!DevEnumThread)
@@ -303,11 +346,12 @@ OnContext(PMAIN_WND_INFO Info,
 }
 
 
-static VOID
+static LRESULT
 OnNotify(PMAIN_WND_INFO Info,
          LPARAM lParam)
 {
     LPNMHDR pnmhdr = (LPNMHDR)lParam;
+    LRESULT ret = 0;
 
     switch (pnmhdr->code)
     {
@@ -315,26 +359,52 @@ OnNotify(PMAIN_WND_INFO Info,
         {
             LPNM_TREEVIEW pnmtv = (LPNM_TREEVIEW)lParam;
 
-            if (!TreeView_GetChild(Info->hTreeView,
-                                   pnmtv->itemNew.hItem))
+            if (Info->Display == DevicesByType)
             {
-                SendMessage(Info->hTool,
-                            TB_SETSTATE,
-                            IDC_PROP,
-                            (LPARAM)MAKELONG(TBSTATE_ENABLED, 0));
+                if (!TreeView_GetChild(Info->hTreeView,
+                                       pnmtv->itemNew.hItem))
+                {
+                    SendMessage(Info->hTool,
+                                TB_SETSTATE,
+                                IDC_PROP,
+                                (LPARAM)MAKELONG(TBSTATE_ENABLED, 0));
+
+                    EnableMenuItem(GetMenu(Info->hMainWnd), IDC_PROP, MF_ENABLED);
+                    EnableMenuItem(Info->hShortcutMenu, IDC_PROP, MF_ENABLED);
+                }
+                else
+                {
+                    SendMessage(Info->hTool,
+                                TB_SETSTATE,
+                                IDC_PROP,
+                                (LPARAM)MAKELONG(TBSTATE_INDETERMINATE, 0));
 
-                EnableMenuItem(GetMenu(Info->hMainWnd), IDC_PROP, MF_ENABLED);
-                EnableMenuItem(Info->hShortcutMenu, IDC_PROP, MF_ENABLED);
+                    EnableMenuItem(GetMenu(Info->hMainWnd), IDC_PROP, MF_GRAYED);
+                    EnableMenuItem(Info->hShortcutMenu, IDC_PROP, MF_GRAYED);
+                }
             }
-            else
+            else if (Info->Display == DevicesByConnection)
             {
-                SendMessage(Info->hTool,
-                            TB_SETSTATE,
-                            IDC_PROP,
-                            (LPARAM)MAKELONG(TBSTATE_INDETERMINATE, 0));
+                if (pnmtv->itemNew.hItem == TreeView_GetRoot(Info->hTreeView))
+                {
+                    SendMessage(Info->hTool,
+                                TB_SETSTATE,
+                                IDC_PROP,
+                                (LPARAM)MAKELONG(TBSTATE_INDETERMINATE, 0));
+
+                    EnableMenuItem(GetMenu(Info->hMainWnd), IDC_PROP, MF_GRAYED);
+                    EnableMenuItem(Info->hShortcutMenu, IDC_PROP, MF_GRAYED);
+                }
+                else
+                {
+                    SendMessage(Info->hTool,
+                                TB_SETSTATE,
+                                IDC_PROP,
+                                (LPARAM)MAKELONG(TBSTATE_ENABLED, 0));
 
-                EnableMenuItem(GetMenu(Info->hMainWnd), IDC_PROP, MF_GRAYED);
-                EnableMenuItem(Info->hShortcutMenu, IDC_PROP, MF_GRAYED);
+                    EnableMenuItem(GetMenu(Info->hMainWnd), IDC_PROP, MF_ENABLED);
+                    EnableMenuItem(Info->hShortcutMenu, IDC_PROP, MF_ENABLED);
+                }
             }
         }
         break;
@@ -344,17 +414,42 @@ OnNotify(PMAIN_WND_INFO Info,
             HTREEITEM hSelected = TreeView_GetSelection(Info->hTreeView);
             TV_HITTESTINFO HitTest;
 
-            if (!TreeView_GetChild(Info->hTreeView,
-                                   hSelected))
+            if (Info->Display == DevicesByType)
+            {
+                if (!TreeView_GetChild(Info->hTreeView,
+                                       hSelected))
+                {
+                    if (GetCursorPos(&HitTest.pt) &&
+                        ScreenToClient(Info->hTreeView, &HitTest.pt))
+                    {
+                        if (TreeView_HitTest(Info->hTreeView, &HitTest))
+                        {
+                            if (HitTest.hItem == hSelected)
+                            {
+                                OpenPropSheet(Info->hTreeView,
+                                              hSelected);
+                                ret = TRUE;
+                            }
+                        }
+                    }
+                }
+            }
+            else if (Info->Display == DevicesByConnection)
             {
-                if (GetCursorPos(&HitTest.pt) &&
-                    ScreenToClient(Info->hTreeView, &HitTest.pt))
+                if (hSelected != TreeView_GetRoot(Info->hTreeView))
                 {
-                    if (TreeView_HitTest(Info->hTreeView, &HitTest))
+                    if (GetCursorPos(&HitTest.pt) &&
+                        ScreenToClient(Info->hTreeView, &HitTest.pt))
                     {
-                        if (HitTest.hItem == hSelected)
-                            OpenPropSheet(Info->hTreeView,
-                                          hSelected);
+                        if (TreeView_HitTest(Info->hTreeView, &HitTest))
+                        {
+                            if (HitTest.hItem == hSelected)
+                            {
+                                OpenPropSheet(Info->hTreeView,
+                                              hSelected);
+                                ret = TRUE;
+                            }
+                        }
                     }
                 }
             }
@@ -403,6 +498,38 @@ OnNotify(PMAIN_WND_INFO Info,
         }
         break;
     }
+
+    return ret;
+}
+
+
+static VOID
+OnRefresh(PMAIN_WND_INFO Info)
+{
+    HANDLE DevEnumThread;
+
+    SendMessage(Info->hTool,
+                TB_SETSTATE,
+                IDC_PROP,
+                (LPARAM)MAKELONG(TBSTATE_INDETERMINATE, 0));
+
+    EnableMenuItem(GetMenu(Info->hMainWnd), IDC_PROP, MF_GRAYED);
+    EnableMenuItem(Info->hShortcutMenu, IDC_PROP, MF_GRAYED);
+
+    /* create seperate thread to emum devices */
+    DevEnumThread = CreateThread(NULL,
+                                 0,
+                                 DeviceEnumThread,
+                                 Info,
+                                 0,
+                                 NULL);
+    if (!DevEnumThread)
+    {
+        DisplayString(_T("Failed to enumerate devices"));
+        return;
+    }
+
+    CloseHandle(DevEnumThread);
 }
 
 
@@ -425,30 +552,7 @@ MainWndCommand(PMAIN_WND_INFO Info,
 
         case IDC_REFRESH:
         {
-            HANDLE DevEnumThread;
-
-            SendMessage(Info->hTool,
-                        TB_SETSTATE,
-                        IDC_PROP,
-                        (LPARAM)MAKELONG(TBSTATE_INDETERMINATE, 0));
-
-            EnableMenuItem(GetMenu(Info->hMainWnd), IDC_PROP, MF_GRAYED);
-            EnableMenuItem(Info->hShortcutMenu, IDC_PROP, MF_GRAYED);
-
-            /* create seperate thread to emum devices */
-            DevEnumThread = CreateThread(NULL,
-                                         0,
-                                         DeviceEnumThread,
-                                         &Info->hTreeView,
-                                         0,
-                                         NULL);
-            if (!DevEnumThread)
-            {
-                DisplayString(_T("Failed to enumerate devices"));
-                break;
-            }
-
-            CloseHandle(DevEnumThread);
+            OnRefresh(Info);
         }
         break;
 
@@ -479,6 +583,21 @@ MainWndCommand(PMAIN_WND_INFO Info,
         }
         break;
 
+        case IDC_DEVBYTYPE:
+        {
+            Info->Display = DevicesByType;
+            UpdateViewMenu(Info);
+            OnRefresh(Info);
+        }
+        break;
+
+        case IDC_DEVBYCONN:
+        {
+            Info->Display = DevicesByConnection;
+            UpdateViewMenu(Info);
+            OnRefresh(Info);
+        }
+        break;
     }
 }
 
@@ -570,7 +689,7 @@ MainWndProc(HWND hwnd,
 
         case WM_NOTIFY:
         {
-            OnNotify(Info, lParam);
+            Ret = OnNotify(Info, lParam);
         }
         break;
 
@@ -674,6 +793,7 @@ CreateMainWindow(LPCTSTR lpCaption,
     if (Info != NULL)
     {
         Info->nCmdShow = nCmdShow;
+        Info->Display = DevicesByType;
 
         hMainWnd = CreateWindowEx(WS_EX_WINDOWEDGE,
                                   szMainWndClass,
index d9bdd42..143f1bd 100644 (file)
 
 #define MAX_DEV_LEN 256
 
+typedef enum
+{
+    DevicesByType,
+    DevicesByConnection,
+    RessourcesByType,
+    RessourcesByConnection
+} DISPLAY_TYPE;
+
 typedef struct _MAIN_WND_INFO
 {
     HWND  hMainWnd;
@@ -28,6 +36,8 @@ typedef struct _MAIN_WND_INFO
     HMENU hShortcutMenu;
     int   nCmdShow;
 
+    DISPLAY_TYPE Display;
+
     /* status flags */
     UINT InMenuLoop : 1;
 
@@ -59,6 +69,7 @@ VOID FreeDeviceStrings(HWND hTreeView);
 VOID OpenPropSheet(HWND hTreeView, HTREEITEM hItem);
 HTREEITEM InitTreeView(HWND hTreeView);
 VOID ListDevicesByType(HWND hTreeView, HTREEITEM hRoot);
+VOID ListDevicesByConnection(HWND hTreeView, HTREEITEM hRoot);
 
 
 /* misc.c */
index 4bf47ae..2f67d6c 100644 (file)
@@ -20,6 +20,9 @@
 #define IDR_MAINMENU        102
 #define IDR_POPUP           103
 #define IDC_DEVBYTYPE       104
+#define IDC_DEVBYCONN       105
+#define IDC_RESBYTYPE       106
+#define IDC_RESBYCONN       107
 
 /* tooltips */
 #define IDS_TOOLTIP_PROP    6000