mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
- 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. svn path=/trunk/; revision=24297
This commit is contained in:
parent
4da7594216
commit
91b9b125db
8 changed files with 80 additions and 47 deletions
|
@ -2,20 +2,27 @@ IDR_MAINMENU MENU
|
|||
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 @@ IDR_POPUP MENU
|
|||
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
|
||||
|
||||
|
|
|
@ -38,6 +38,9 @@ WinMain(HINSTANCE hThisInstance,
|
|||
return 1;
|
||||
}
|
||||
|
||||
// FreeConsole();
|
||||
// AllocConsole();
|
||||
|
||||
if (InitMainWindowImpl())
|
||||
{
|
||||
hMainWnd = CreateMainWindow(lpAppName,
|
||||
|
|
|
@ -31,7 +31,7 @@ InsertIntoTreeView(HWND hTV,
|
|||
tvi.iSelectedImage = DevImage;
|
||||
|
||||
tvins.item = tvi;
|
||||
tvins.hInsertAfter = hRoot;
|
||||
tvins.hParent = hRoot;
|
||||
|
||||
return TreeView_InsertItem(hTV, &tvins);
|
||||
}
|
||||
|
@ -39,23 +39,23 @@ InsertIntoTreeView(HWND hTV,
|
|||
|
||||
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 @@ EnumDeviceClasses(INT ClassIndex,
|
|||
RequiredSize,
|
||||
&RequiredSize))
|
||||
{
|
||||
lstrcpy(DeviceClassName, ClassName);
|
||||
lstrcpy(DevClassName, ClassName);
|
||||
}
|
||||
else
|
||||
{
|
||||
*DeviceClassName = _T('\0');
|
||||
*DevClassName = _T('\0');
|
||||
}
|
||||
|
||||
if (!SetupDiGetClassImageIndex(&ImageListData,
|
||||
|
@ -88,13 +88,14 @@ EnumDeviceClasses(INT ClassIndex,
|
|||
*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 @@ EnumDeviceClasses(INT ClassIndex,
|
|||
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 @@ EnumDeviceClasses(INT ClassIndex,
|
|||
return -3;
|
||||
}
|
||||
|
||||
/* FIXME: Can we call this earlier, or see above? */
|
||||
SetupDiDestroyDeviceInfoList(hDevInfo);
|
||||
/* FIXME: see above?
|
||||
SetupDiDestroyDeviceInfoList(hDevInfo); */
|
||||
|
||||
*DevicePresent = TRUE;
|
||||
*DevPresent = TRUE;
|
||||
|
||||
RegCloseKey(KeyClass);
|
||||
|
||||
|
@ -143,16 +145,16 @@ EnumDevices(INT index,
|
|||
*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 @@ EnumDevices(INT index,
|
|||
}
|
||||
}
|
||||
|
||||
//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 @@ InitTreeView(PMAIN_WND_INFO Info)
|
|||
TCHAR ComputerName[MAX_PATH];
|
||||
DWORD dwSize = MAX_PATH;
|
||||
INT RootImage;
|
||||
//COLORREF Mask = RGB(255, 0, 128);
|
||||
|
||||
TreeView_DeleteAllItems(Info->hTreeView);
|
||||
|
||||
|
@ -337,8 +339,10 @@ InitTreeView(PMAIN_WND_INFO Info)
|
|||
hComp,
|
||||
NULL);
|
||||
|
||||
DeleteObject(hComp);
|
||||
|
||||
TreeView_SetImageList(Info->hTreeView,
|
||||
&ImageListData.ImageList,
|
||||
ImageListData.ImageList,
|
||||
TVSIL_NORMAL);
|
||||
|
||||
if (!GetComputerName(ComputerName,
|
||||
|
@ -349,6 +353,7 @@ InitTreeView(PMAIN_WND_INFO Info)
|
|||
|
||||
RootImage = ImageList_GetImageCount(ImageListData.ImageList) - 1;
|
||||
|
||||
/* insert the root item into the tree */
|
||||
hRoot = InsertIntoTreeView(Info->hTreeView,
|
||||
NULL,
|
||||
ComputerName,
|
||||
|
|
|
@ -248,23 +248,30 @@ MainWndCommand(PMAIN_WND_INFO Info,
|
|||
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;
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -259,3 +259,20 @@ VOID DisplayString(PTCHAR Msg)
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -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,15 +15,8 @@
|
|||
#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
|
||||
{
|
||||
HWND hMainWnd;
|
||||
|
@ -89,14 +82,16 @@ INT GetTextFromEdit(OUT LPTSTR lpString,
|
|||
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 */
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#define IDC_STATIC -1
|
||||
|
||||
#define IDC_STATIC -1
|
||||
|
||||
#define IDI_MAIN_ICON 50
|
||||
#define IDB_ROOT_IMAGE 51
|
||||
|
|
Loading…
Reference in a new issue