[ros-diffs] [gedmurphy] 24297: - fix the treeview so it displays parent and child devices - display the device icons for each item - other bits and bats I'm too lazy to list - it still load slowly due to multiple calls to SetupDiGetClassDevs. Need to think of a better way of gathering the info. For now though, it works.

gedmurphy at svn.reactos.org gedmurphy at svn.reactos.org
Fri Sep 29 18:38:39 CEST 2006


Author: gedmurphy
Date: Fri Sep 29 20:38:38 2006
New Revision: 24297

URL: http://svn.reactos.org/svn/reactos?rev=24297&view=rev
Log:
- fix the treeview so it displays parent and child devices
- display the device icons for each item
- other bits and bats I'm too lazy to list
- it still load slowly due to multiple calls to SetupDiGetClassDevs. Need to think of a better way of gathering the info. For now though, it works.

Modified:
    trunk/reactos/base/applications/devmgmt/En.rc
    trunk/reactos/base/applications/devmgmt/devmgmt.c
    trunk/reactos/base/applications/devmgmt/enumdevices.c
    trunk/reactos/base/applications/devmgmt/mainwnd.c
    trunk/reactos/base/applications/devmgmt/manifest.xml
    trunk/reactos/base/applications/devmgmt/misc.c
    trunk/reactos/base/applications/devmgmt/precomp.h
    trunk/reactos/base/applications/devmgmt/resource.h

Modified: trunk/reactos/base/applications/devmgmt/En.rc
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/devmgmt/En.rc?rev=24297&r1=24296&r2=24297&view=diff
==============================================================================
--- trunk/reactos/base/applications/devmgmt/En.rc (original)
+++ trunk/reactos/base/applications/devmgmt/En.rc Fri Sep 29 20:38:38 2006
@@ -2,20 +2,27 @@
 BEGIN
   POPUP "&File"
   BEGIN
-    MENUITEM "E&xit",           IDC_EXIT
+    MENUITEM "E&xit",                   IDC_EXIT
   END
   POPUP "Action"
   BEGIN
-    MENUITEM "Print",           IDC_PRINT, GRAYED
+    MENUITEM "Print",                   IDC_PRINT, GRAYED
     MENUITEM SEPARATOR
-    MENUITEM "Properties...",   IDC_PROP
+    MENUITEM "Properties...",           IDC_PROP
     MENUITEM SEPARATOR
-    MENUITEM "Help",            IDC_PROGHELP, GRAYED
+    MENUITEM "Help",                    IDC_PROGHELP, GRAYED
+  END
+  POPUP "View"
+  BEGIN
+    MENUITEM "Devices by type",         IDC_STATIC
+    MENUITEM "Devices by connection",   IDC_STATIC, GRAYED
+    MENUITEM "Resources by type",       IDC_STATIC, GRAYED
+    MENUITEM "Resources by connection", IDC_STATIC, GRAYED
   END
   POPUP "Help"
   BEGIN
-    MENUITEM "Help",            IDC_PROGHELP
-    MENUITEM "About",           IDC_ABOUT
+    MENUITEM "Help",                    IDC_PROGHELP
+    MENUITEM "About",                   IDC_ABOUT
   END
 END
 
@@ -23,9 +30,9 @@
 BEGIN
   POPUP "popup"
   BEGIN
-    MENUITEM "Properties...",   IDC_PROP, GRAYED
+    MENUITEM "Properties...",           IDC_PROP, GRAYED
     MENUITEM SEPARATOR
-    MENUITEM "Help",            IDC_PROGHELP
+    MENUITEM "Help",                    IDC_PROGHELP
   END
 END
 

Modified: trunk/reactos/base/applications/devmgmt/devmgmt.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/devmgmt/devmgmt.c?rev=24297&r1=24296&r2=24297&view=diff
==============================================================================
--- trunk/reactos/base/applications/devmgmt/devmgmt.c (original)
+++ trunk/reactos/base/applications/devmgmt/devmgmt.c Fri Sep 29 20:38:38 2006
@@ -38,6 +38,9 @@
         return 1;
     }
 
+//    FreeConsole();
+//    AllocConsole();
+
     if (InitMainWindowImpl())
     {
         hMainWnd = CreateMainWindow(lpAppName,

Modified: trunk/reactos/base/applications/devmgmt/enumdevices.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/devmgmt/enumdevices.c?rev=24297&r1=24296&r2=24297&view=diff
==============================================================================
--- trunk/reactos/base/applications/devmgmt/enumdevices.c (original)
+++ trunk/reactos/base/applications/devmgmt/enumdevices.c Fri Sep 29 20:38:38 2006
@@ -31,7 +31,7 @@
     tvi.iSelectedImage = DevImage;
 
     tvins.item = tvi;
-    tvins.hInsertAfter = hRoot;
+    tvins.hParent = hRoot;
 
     return TreeView_InsertItem(hTV, &tvins);
 }
@@ -39,23 +39,23 @@
 
 static INT
 EnumDeviceClasses(INT ClassIndex,
-                  TCHAR *DeviceClassName,
-                  TCHAR *DeviceClassDesc,
-                  BOOL *DevicePresent,
+                  LPTSTR DevClassName,
+                  LPTSTR DevClassDesc,
+                  BOOL *DevPresent,
                   INT *ClassImage)
 {
     GUID ClassGuid;
     HKEY KeyClass;
-    HDEVINFO hDevInfo;
     TCHAR ClassName[MAX_CLASS_NAME_LEN];
     DWORD RequiredSize = MAX_CLASS_NAME_LEN;
     UINT Ret;
 
-    *DevicePresent = FALSE;
+    *DevPresent = FALSE;
 
     Ret = CM_Enumerate_Classes(ClassIndex,
                                &ClassGuid,
                                0);
+
     if (Ret != CR_SUCCESS)
     {
         /* all classes enumerated */
@@ -73,11 +73,11 @@
                                  RequiredSize,
                                  &RequiredSize))
     {
-        lstrcpy(DeviceClassName, ClassName);
+        lstrcpy(DevClassName, ClassName);
     }
     else
     {
-        *DeviceClassName = _T('\0');
+        *DevClassName = _T('\0');
     }
 
     if (!SetupDiGetClassImageIndex(&ImageListData,
@@ -88,13 +88,14 @@
         *ClassImage = 41;
     }
 
-    /* FIXME: why are we calling this here? */
+    /* FIXME: do we need this?
     hDevInfo = SetupDiGetClassDevs(&ClassGuid,
                                    0,
                                    NULL,
                                    DIGCF_PRESENT);
     if (hDevInfo == INVALID_HANDLE_VALUE)
-        return -2;
+        return 0;
+    */
 
     KeyClass = SetupDiOpenClassRegKeyEx(&ClassGuid,
                                         MAXIMUM_ALLOWED,
@@ -103,14 +104,15 @@
                                         0);
     if (KeyClass != INVALID_HANDLE_VALUE)
     {
+
         DWORD dwSize = MAX_CLASS_NAME_LEN;
 
         if (RegQueryValue(KeyClass,
                           NULL,
-                          DeviceClassDesc,
+                          DevClassDesc,
                           &dwSize) != ERROR_SUCCESS)
         {
-            *DeviceClassDesc = _T('\0');
+            *DevClassDesc = _T('\0');
         }
     }
     else
@@ -118,10 +120,10 @@
         return -3;
     }
 
-    /* FIXME: Can we call this earlier, or see above? */
-    SetupDiDestroyDeviceInfoList(hDevInfo);
-
-    *DevicePresent = TRUE;
+    /* FIXME: see above?
+    SetupDiDestroyDeviceInfoList(hDevInfo); */
+
+    *DevPresent = TRUE;
 
     RegCloseKey(KeyClass);
 
@@ -143,16 +145,16 @@
     *DeviceName = _T('\0');
 
     bRet = SetupDiClassGuidsFromName(DeviceClassName,
-                                    NULL,
-                                    RequiredSize,
-                                    &RequiredSize);
+                                     NULL,
+                                     RequiredSize,
+                                     &RequiredSize);
     if (RequiredSize == 0)
         return -2;
 
     if (!bRet)
     {
-        guids = HeapAlloc(GetProcessHeap(), 
-                          0, 
+        guids = HeapAlloc(GetProcessHeap(),
+                          0,
                           RequiredSize * sizeof(GUID));
         if (guids == NULL)
             return -1;
@@ -170,12 +172,13 @@
         }
     }
 
+//TimerInfo(_T("IN"));
     /* get device info set for our device class */
     hDevInfo = SetupDiGetClassDevs(guids,
                                    0,
                                    NULL,
                                    DIGCF_PRESENT);
-
+//TimerInfo(_T("OUT"));
     HeapFree(GetProcessHeap(), 0, guids);
     if(hDevInfo == INVALID_HANDLE_VALUE)
     {
@@ -322,7 +325,6 @@
     TCHAR ComputerName[MAX_PATH];
     DWORD dwSize = MAX_PATH;
     INT RootImage;
-    //COLORREF Mask = RGB(255, 0, 128);
 
     TreeView_DeleteAllItems(Info->hTreeView);
 
@@ -337,8 +339,10 @@
                   hComp,
                   NULL);
 
+    DeleteObject(hComp);
+
     TreeView_SetImageList(Info->hTreeView,
-                          &ImageListData.ImageList,
+                          ImageListData.ImageList,
                           TVSIL_NORMAL);
 
     if (!GetComputerName(ComputerName,
@@ -349,6 +353,7 @@
 
     RootImage = ImageList_GetImageCount(ImageListData.ImageList) - 1;
 
+    /* insert the root item into the tree */
     hRoot = InsertIntoTreeView(Info->hTreeView,
                                NULL,
                                ComputerName,

Modified: trunk/reactos/base/applications/devmgmt/mainwnd.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/devmgmt/mainwnd.c?rev=24297&r1=24296&r2=24297&view=diff
==============================================================================
--- trunk/reactos/base/applications/devmgmt/mainwnd.c (original)
+++ trunk/reactos/base/applications/devmgmt/mainwnd.c Fri Sep 29 20:38:38 2006
@@ -248,23 +248,30 @@
         break;
 
         case IDC_PROGHELP:
+        {
             DisplayString(_T("Help is not yet implemented\n"));
             SetFocus(Info->hTreeView);
+        }
         break;
 
         case IDC_EXIT:
+        {
             PostMessage(Info->hMainWnd,
                         WM_CLOSE,
                         0,
                         0);
+        }
         break;
 
         case IDC_ABOUT:
+        {
             DialogBox(hInstance,
                       MAKEINTRESOURCE(IDD_ABOUTBOX),
                       Info->hMainWnd,
                       (DLGPROC)AboutDialogProc);
+
             SetFocus(Info->hTreeView);
+        }
         break;
 
     }

Modified: trunk/reactos/base/applications/devmgmt/manifest.xml
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/devmgmt/manifest.xml?rev=24297&r1=24296&r2=24297&view=diff
==============================================================================
--- trunk/reactos/base/applications/devmgmt/manifest.xml (original)
+++ trunk/reactos/base/applications/devmgmt/manifest.xml Fri Sep 29 20:38:38 2006
@@ -7,7 +7,7 @@
     processorArchitecture="x86"
     version="1.0.0.0"
     type="win32"/>
-<description>ReactOS Service Manager</description>
+<description>ReactOS Device Manager</description>
 <dependency>
     <dependentAssembly>
         <assemblyIdentity

Modified: trunk/reactos/base/applications/devmgmt/misc.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/devmgmt/misc.c?rev=24297&r1=24296&r2=24297&view=diff
==============================================================================
--- trunk/reactos/base/applications/devmgmt/misc.c (original)
+++ trunk/reactos/base/applications/devmgmt/misc.c Fri Sep 29 20:38:38 2006
@@ -259,3 +259,20 @@
     MessageBox(NULL, Msg, _T("Note!"), MB_ICONEXCLAMATION|MB_OK);
 }
 
+
+VOID TimerInfo(LPTSTR text)
+{
+    static HANDLE hOut = NULL;
+    DWORD Count;
+    TCHAR buf[256];
+    static DWORD start = 0;
+
+    if (!start) start = GetTickCount();
+
+    if (!hOut) hOut = GetStdHandle(STD_ERROR_HANDLE);
+
+    if (text) _sntprintf(buf, 256, _T("%s\ttime : %d\n"), text, GetTickCount() - start);
+    else _sntprintf(buf, 256, _T("time : %d\n"), GetTickCount() - start);
+
+    WriteConsole(hOut, buf, lstrlen(buf)+1, &Count, NULL);
+}

Modified: trunk/reactos/base/applications/devmgmt/precomp.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/devmgmt/precomp.h?rev=24297&r1=24296&r2=24297&view=diff
==============================================================================
--- trunk/reactos/base/applications/devmgmt/precomp.h (original)
+++ trunk/reactos/base/applications/devmgmt/precomp.h Fri Sep 29 20:38:38 2006
@@ -1,9 +1,9 @@
 #ifndef __DEVMGMT_PRECOMP_H
 #define __DEVMGMT_PRECOMP_H
 
-//#define WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
-#include <windowsx.h> /* GET_X/Y_LPARAM */
+#include <windowsx.h>
 #include <stdio.h>
 #include <tchar.h>
 #include <setupapi.h>
@@ -15,14 +15,7 @@
 #pragma warning(disable : 4100)
 #endif
 
-#ifndef SB_SIMPLEID
-#define SB_SIMPLEID 0xFF
-#endif
-
-#define NO_ITEM_SELECTED -1
-#define MAX_KEY_LENGTH 256
 #define MAX_DEV_LEN 1000
-
 
 typedef struct _MAIN_WND_INFO
 {
@@ -89,14 +82,16 @@
                     IN HWND hDlg,
                     IN UINT Res);
 
-VOID GetError(VOID);
-
-VOID DisplayString(PTCHAR);
-
 HIMAGELIST InitImageList(UINT NumButtons,
                          UINT StartResource,
                          UINT Width,
                          UINT Height);
 
+VOID GetError(VOID);
+
+VOID DisplayString(PTCHAR);
+
+VOID TimerInfo(LPTSTR);
+
 
 #endif /* __DEVMGMT_PRECOMP_H */

Modified: trunk/reactos/base/applications/devmgmt/resource.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/devmgmt/resource.h?rev=24297&r1=24296&r2=24297&view=diff
==============================================================================
--- trunk/reactos/base/applications/devmgmt/resource.h (original)
+++ trunk/reactos/base/applications/devmgmt/resource.h Fri Sep 29 20:38:38 2006
@@ -1,5 +1,4 @@
-#define IDC_STATIC -1
-
+#define IDC_STATIC          -1
 
 #define IDI_MAIN_ICON       50
 #define IDB_ROOT_IMAGE      51




More information about the Ros-diffs mailing list