Initial implementation of the hardware page, based on a patch by G_siorek zebasoftis@reactos.org (bug #986) Added: trunk/reactos/lib/devmgr/En.rc Added: trunk/reactos/lib/devmgr/Pl.rc Modified: trunk/reactos/lib/devmgr/devmgr.c Deleted: trunk/reactos/lib/devmgr/devmgr.h Modified: trunk/reactos/lib/devmgr/devmgr.rc Modified: trunk/reactos/lib/devmgr/devmgr.xml Added: trunk/reactos/lib/devmgr/misc.c Added: trunk/reactos/lib/devmgr/precomp.h Modified: trunk/reactos/lib/devmgr/resource.h Modified: trunk/reactos/lib/devmgr/stubs.c _____
Added: trunk/reactos/lib/devmgr/En.rc --- trunk/reactos/lib/devmgr/En.rc 2005-11-25 14:15:46 UTC (rev 19550) +++ trunk/reactos/lib/devmgr/En.rc 2005-11-25 14:17:30 UTC (rev 19551) @@ -0,0 +1,28 @@
+// English language resource file (Sebastian Gasiorek, 2005-11-13) + +LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT + +STRINGTABLE +BEGIN + IDS_NAME "Name" + IDS_TYPE "Type" + IDS_MANUFACTURER "Manufacturer: %1" + IDS_LOCATION "Location: %1" + IDS_STATUS "Device Status: %1" +END + +IDD_HARDWARE DIALOG DISCARDABLE 0, 0, 300, 400 +STYLE DS_3DLOOK | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CAPTION | DS_SHELLFONT +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "&Devices:",IDC_DEVICES,7,6,196,10 + CONTROL "",IDC_LV_DEVICES,"SysListView32",LVS_REPORT | + LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | + LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,16,196,50 + GROUPBOX "Device Properties",IDC_PROPERTIESGROUP,7,76,196,105 + LTEXT "",IDC_MANUFACTURER,14,88,183,10,SS_ENDELLIPSIS + LTEXT "",IDC_LOCATION,14,100,183,10,SS_ENDELLIPSIS + LTEXT "",IDC_STATUS,14,112,183,30 + PUSHBUTTON "&Troubleshoot...",IDC_TROUBLESHOOT,85,140,54,14 + PUSHBUTTON "P&roperties",IDC_PROPERTIES,146,140,50,14 +END Property changes on: trunk/reactos/lib/devmgr/En.rc ___________________________________________________________________ Name: svn:keywords + author date revision Name: svn:eol-style + native _____
Added: trunk/reactos/lib/devmgr/Pl.rc --- trunk/reactos/lib/devmgr/Pl.rc 2005-11-25 14:15:46 UTC (rev 19550) +++ trunk/reactos/lib/devmgr/Pl.rc 2005-11-25 14:17:30 UTC (rev 19551) @@ -0,0 +1,28 @@
+// Polish language resource file (Sebastian Gasiorek, 2005-11-13) + +LANGUAGE LANG_POLISH, SUBLANG_DEFAULT + +STRINGTABLE +BEGIN +IDS_NAME "Nazwa" +IDS_TYPE "Typ" +IDS_MANUFACTURER "Producent: %1" +IDS_LOCATION "Lokalizacja: %1" +IDS_STATUS "Stan urz?dzenia: %1" +END + +IDD_HARDWARE DIALOG DISCARDABLE 0, 0, 300, 400 +STYLE DS_3DLOOK | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CAPTION | DS_SHELLFONT +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "&Urz?dzenia:",IDC_DEVICES,7,6,196,10 + CONTROL "",IDC_LV_DEVICES,"SysListView32",LVS_REPORT | + LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | + LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,16,196,50 + GROUPBOX "W?a£ciwo£ci urz?dzenia",IDC_PROPERTIESGROUP,7,76,196,105 + LTEXT "",IDC_MANUFACTURER,14,88,183,10,SS_ENDELLIPSIS + LTEXT "",IDC_LOCATION,14,100,183,10,SS_ENDELLIPSIS + LTEXT "",IDC_STATUS,14,112,183,30 + PUSHBUTTON "&Rozwi?zywanie problem¾w...",IDC_TROUBLESHOOT,85,140,54,14 + PUSHBUTTON "&W?a£ciwo£ci",IDC_PROPERTIES,146,140,50,14 +END Property changes on: trunk/reactos/lib/devmgr/Pl.rc ___________________________________________________________________ Name: svn:keywords + author date revision Name: svn:eol-style + native _____
Modified: trunk/reactos/lib/devmgr/devmgr.c --- trunk/reactos/lib/devmgr/devmgr.c 2005-11-25 14:15:46 UTC (rev 19550) +++ trunk/reactos/lib/devmgr/devmgr.c 2005-11-25 14:17:30 UTC (rev 19551) @@ -1,6 +1,6 @@
/* * ReactOS Device Manager Applet - * Copyright (C) 2004 ReactOS Team + * Copyright (C) 2004 - 2005 ReactOS Team * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -21,35 +21,807 @@ * PROJECT: ReactOS devmgr.dll * FILE: lib/devmgr/devmgr.c * PURPOSE: ReactOS Device Manager - * PROGRAMMER: Thomas Weidenmueller (w3seek@users.sourceforge.net) + * PROGRAMMER: Thomas Weidenmueller w3seek@reactos.com * UPDATE HISTORY: * 04-04-2004 Created */ -#include <windows.h> -#include "devmgr.h" -#include "resource.h" +#include <precomp.h>
-HINSTANCE hDllInstance; +#define NDEBUG +#include <debug.h>
+HINSTANCE hDllInstance = NULL;
-BOOL STDCALL -DllMain( - HINSTANCE hinstDLL, - DWORD dwReason, - LPVOID lpvReserved) +typedef VOID (WINAPI *PINITCOMMONCONTROLS)(VOID); + +typedef enum { - switch (dwReason) - { - case DLL_PROCESS_ATTACH: - hDllInstance = hinstDLL; - break; - case DLL_THREAD_ATTACH: - break; - case DLL_THREAD_DETACH: - break; - case DLL_PROCESS_DETACH: - break; - } - return TRUE; + HWPD_STANDARDLIST = 0, + HWPD_LARGELIST, + HWPD_MAX = HWPD_LARGELIST +} HWPAGE_DISPLAYMODE, *PHWPAGE_DISPLAYMODE; + +typedef struct _HWDEVINFO +{ + struct _HWCLASSDEVINFO *ClassDevInfo; + SP_DEVINFO_DATA DevInfoData; +} HWDEVINFO, *PHWDEVINFO; + +typedef struct _HWCLASSDEVINFO +{ + GUID Guid; + HDEVINFO hDevInfo; + INT ItemCount; + PHWDEVINFO HwDevInfo; +} HWCLASSDEVINFO, *PHWCLASSDEVINFO; + +typedef struct _HARDWARE_PAGE_DATA +{ + HWND hWnd; + HWND hWndDevList; + HINSTANCE hComCtl32; /* only save this to keep track of the references */ + SP_CLASSIMAGELIST_DATA ClassImageListData; + HWPAGE_DISPLAYMODE DisplayMode; + + /* parent window subclass info */ + WNDPROC ParentOldWndProc; + HWND hWndParent; + + UINT NumberOfGuids; + HWCLASSDEVINFO ClassDevInfo[1]; + /* struct may be dynamically expanded here! */ +} HARDWARE_PAGE_DATA, *PHARDWARE_PAGE_DATA; + +#define CX_TYPECOLUMN_WIDTH 80 + +static VOID +InitializeDevicesList(IN PHARDWARE_PAGE_DATA hpd) +{ + LVCOLUMN lvc; + RECT rcClient; + WCHAR szColName[255]; + int iCol = 0; + + /* set the list view style */ + ListView_SetExtendedListViewStyle(hpd->hWndDevList, + LVS_EX_FULLROWSELECT); + + /* set the list view image list */ + if (hpd->ClassImageListData.ImageList != NULL) + { + ListView_SetImageList(hpd->hWndDevList, + hpd->ClassImageListData.ImageList, + LVSIL_SMALL); + } + + GetClientRect(hpd->hWndDevList, + &rcClient); + + /* add the list view columns */ + lvc.mask = LVCF_TEXT | LVCF_WIDTH; + lvc.fmt = LVCFMT_LEFT; + lvc.pszText = szColName; + + if (LoadString(hDllInstance, + IDS_NAME, + szColName, + sizeof(szColName) / sizeof(szColName[0]))) + { + lvc.cx = rcClient.right - CX_TYPECOLUMN_WIDTH - + GetSystemMetrics(SM_CXVSCROLL); + ListView_InsertColumn(hpd->hWndDevList, + iCol++, + &lvc); + } + if (LoadString(hDllInstance, + IDS_TYPE, + szColName, + sizeof(szColName) / sizeof(szColName[0]))) + { + lvc.cx = CX_TYPECOLUMN_WIDTH; + ListView_InsertColumn(hpd->hWndDevList, + iCol++, + &lvc); + } }
+ +static VOID +UpdateControlStates(IN PHARDWARE_PAGE_DATA hpd) +{ + PHWDEVINFO HwDevInfo; + + HwDevInfo = (PHWDEVINFO)ListViewGetSelectedItemData(hpd->hWndDevList); + if (HwDevInfo != NULL) + { + /* FIXME - update static controls and enable buttons */ + } + else + { + /* FIXME - clear static controls and disable buttons */ + } +} + + +static VOID +FillDevicesList(IN PHARDWARE_PAGE_DATA hpd) +{ + PHWCLASSDEVINFO DevInfo, LastDevInfo; + SP_DEVINFO_DATA DevInfoData; + WCHAR szBuffer[255]; + INT ItemCount = 0; + + DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA); + + DevInfo = hpd->ClassDevInfo; + LastDevInfo = DevInfo + hpd->NumberOfGuids; + + while (DevInfo != LastDevInfo) + { + INT ImageIndex = -1; + + DevInfo->hDevInfo = SetupDiGetClassDevs(&DevInfo->Guid, + NULL, + hpd->hWnd, + DIGCF_PRESENT); + if (DevInfo->hDevInfo != INVALID_HANDLE_VALUE) + { + LVITEM li; + DWORD MemberIndex = 0; + + SetupDiGetClassImageIndex(&hpd->ClassImageListData, + &DevInfo->Guid, + &ImageIndex); + + while (SetupDiEnumDeviceInfo(DevInfo->hDevInfo, + MemberIndex++, + &DevInfoData)) + { + DWORD RegDataType; + INT iItem; + + if (DevInfo->HwDevInfo != NULL) + { + PHWDEVINFO HwNewDevInfo = HeapReAlloc(GetProcessHeap(), + 0, + DevInfo->HwDevInfo, + (DevInfo->ItemCount + 1) * + sizeof(HWDEVINFO)); + if (HwNewDevInfo != NULL) + { + DevInfo->HwDevInfo = HwNewDevInfo; + DevInfo->HwDevInfo[DevInfo->ItemCount].ClassDevInfo = DevInfo; + DevInfo->HwDevInfo[DevInfo->ItemCount++].DevInfoData = DevInfoData; + } + else + { + DPRINT1("Unable to allocate memory for %d SP_DEVINFO_DATA structures!\n", + DevInfo->ItemCount + 1); + break; + } + } + else + { + DevInfo->HwDevInfo = HeapAlloc(GetProcessHeap(), + 0, + sizeof(HWDEVINFO)); + if (DevInfo->HwDevInfo != NULL) + { + DevInfo->HwDevInfo[DevInfo->ItemCount].ClassDevInfo = DevInfo; + DevInfo->HwDevInfo[DevInfo->ItemCount++].DevInfoData = DevInfoData; + } + else + { + DPRINT1("Unable to allocate memory for a SP_DEVINFO_DATA structures!\n"); + break; + } + } + + if ((SetupDiGetDeviceRegistryProperty(DevInfo->hDevInfo, + &DevInfoData, + SPDRP_FRIENDLYNAME, + &RegDataType, + (PBYTE)szBuffer, + sizeof(szBuffer), + NULL) || + SetupDiGetDeviceRegistryProperty(DevInfo->hDevInfo, + &DevInfoData, + SPDRP_DEVICEDESC, + &RegDataType, + (PBYTE)szBuffer, + sizeof(szBuffer), + NULL)) && + RegDataType == REG_SZ) + { + /* FIXME - check string for NULL termination! */ + + li.mask = LVIF_PARAM | LVIF_STATE | LVIF_TEXT | LVIF_IMAGE; + li.iItem = ItemCount; + li.iSubItem = 0; + li.state = (ItemCount == 0 ? LVIS_SELECTED : 0); + li.stateMask = LVIS_SELECTED; + li.pszText = szBuffer; + li.iImage = ImageIndex; + li.lParam = (LPARAM)&DevInfo->HwDevInfo[DevInfo->ItemCount - 1]; + + iItem = ListView_InsertItem(hpd->hWndDevList, + &li); + if (iItem != -1) + { + ItemCount++; + + if (SetupDiGetClassDescription(&DevInfo->Guid, + szBuffer, + sizeof(szBuffer) / sizeof(szBuffer[0]), + NULL)) + { + li.mask = LVIF_TEXT; + li.iItem = iItem; + li.iSubItem = 1; + + ListView_SetItem(hpd->hWndDevList, + &li); + } + } + } + } + } + + DevInfo++; + } + + /* update the controls */ + UpdateControlStates(hpd); +} + + +static LRESULT +CALLBACK +ParentSubWndProc(IN HWND hwnd, + IN UINT uMsg, + IN WPARAM wParam, + IN LPARAM lParam) +{ + PHARDWARE_PAGE_DATA hpd; + + hpd = (PHARDWARE_PAGE_DATA)GetProp(hwnd, + L"DevMgrSubClassInfo"); + if (hpd != NULL) + { + if (uMsg == WM_SIZE) + { + /* resize the hardware page */ + SetWindowPos(hpd->hWnd, + NULL, + 0, + 0, + LOWORD(lParam), + HIWORD(lParam), + SWP_NOZORDER); + } + + /* pass the message the the old window proc */ + return CallWindowProc(hpd->ParentOldWndProc, + hwnd, + uMsg, + wParam, + lParam); + } + else + { + /* this is not a good idea if the subclassed window was an ansi + window, but we failed finding out the previous window proc + so we can't use CallWindowProc. This should rarely - if ever - + happen. */ + + return DefWindowProc(hwnd, + uMsg, + wParam, + lParam); + } +} + + +static VOID +HardwareDlgResize(IN PHARDWARE_PAGE_DATA hpd, + IN INT cx, + IN INT cy) +{ + HDWP dwp; + HWND hControl, hButton; + INT Width, x, y, TopBias = 0; + RECT rc, rcButton; + POINT pt = {0}; + POINT ptMargin = {0}; + POINT ptMarginGroup = {0}; + + /* use left margin of the IDC_DEVICES label as the right + margin of all controls outside the group box */ + hControl = GetDlgItem(hpd->hWnd, + IDC_DEVICES); + GetWindowRect(hControl, + &rc); + MapWindowPoints(hControl, + hpd->hWnd, + &ptMargin, + 1); + + Width = cx - (2 * ptMargin.x); + + if ((dwp = BeginDeferWindowPos(8))) + { + /* rc already has the window rect of IDC_DEVICES! */ + if (!(dwp = DeferWindowPos(dwp, + hControl, + NULL, + 0, + 0, + Width, + rc.bottom - rc.top, + SWP_NOMOVE | SWP_NOZORDER))) + { + return; + } + + /* resize the devices list view control */ + GetWindowRect(hpd->hWndDevList, + &rc); + MapWindowPoints(hpd->hWndDevList, + hpd->hWnd, + &pt, + 1); + if (hpd->DisplayMode == HWPD_LARGELIST) + { + /* increase the size of the list view control by 2/3 */ + TopBias = ((rc.bottom - rc.top) * 2) / 3; + } + y = pt.y + TopBias + rc.bottom - rc.top + ptMargin.y; + if (!(dwp = DeferWindowPos(dwp, + hpd->hWndDevList, + NULL, + 0, + 0, + Width, + rc.bottom - rc.top + TopBias, + SWP_NOMOVE | SWP_NOZORDER))) + { + return; + } + + /* resize the group box control */ + hControl = GetDlgItem(hpd->hWnd, + IDC_PROPERTIESGROUP); + GetWindowRect(hControl, + &rc); + if (!(dwp = DeferWindowPos(dwp, + hControl, + NULL, + ptMargin.x, + y, + Width, + cy - y - ptMargin.y, + SWP_NOZORDER))) + { + return; + } + + /* use left margin of the IDC_MANUFACTURER label as the right + margin of all controls inside the group box */ + hControl = GetDlgItem(hpd->hWnd, + IDC_MANUFACTURER); + GetWindowRect(hControl, + &rc); + MapWindowPoints(hControl, + hpd->hWnd, + &ptMarginGroup, + 1); + + ptMarginGroup.y = ptMargin.y * 2; + Width = cx - (2 * ptMarginGroup.x); + y += ptMarginGroup.y; + if (!(dwp = DeferWindowPos(dwp, + hControl, + NULL, + ptMarginGroup.x, + y, + Width, + rc.bottom - rc.top, + SWP_NOZORDER))) + { + return; + } + y += rc.bottom - rc.top + ptMargin.y; + + /* resize the IDC_LOCATION label */ + hControl = GetDlgItem(hpd->hWnd, + IDC_LOCATION); + GetWindowRect(hControl, + &rc); + if (!(dwp = DeferWindowPos(dwp, + hControl, + NULL, + ptMarginGroup.x, + y, + Width, + rc.bottom - rc.top, + SWP_NOZORDER))) + { + return; + } + y += rc.bottom - rc.top + ptMargin.y; + + /* measure the size of the buttons */ + hButton = GetDlgItem(hpd->hWnd, + IDC_PROPERTIES); + GetWindowRect(hButton, + &rcButton); + + /* resize the IDC_STATUS label */ + hControl = GetDlgItem(hpd->hWnd, + IDC_STATUS); + GetWindowRect(hControl, + &rc); + if (!(dwp = DeferWindowPos(dwp, + hControl, + NULL, + ptMarginGroup.x, + y, + Width, + cy - y - (3 * ptMargin.y) - + (rcButton.bottom - rcButton.top), + SWP_NOZORDER))) + { + return; + } + + /* move the IDC_PROPERTIES button */ + y = cy - (2 * ptMargin.y) - (rcButton.bottom - rcButton.top); + x = cx - ptMarginGroup.x - (rcButton.right - rcButton.left); + if (!(dwp = DeferWindowPos(dwp, + hButton, + NULL, + x, + y, + 0, + 0, + SWP_NOSIZE | SWP_NOZORDER))) + { + return; + } + + /* move the IDC_TROUBLESHOOT button */ + hButton = GetDlgItem(hpd->hWnd, + IDC_TROUBLESHOOT); + GetWindowRect(hButton, + &rcButton); + x -= ptMargin.x + (rcButton.right - rcButton.left); + if (!(dwp = DeferWindowPos(dwp, + hButton, + NULL, + x, + y, + 0, + 0, + SWP_NOSIZE | SWP_NOZORDER))) + { + return; + } + + EndDeferWindowPos(dwp); + } +} + + +static INT_PTR +CALLBACK +HardwareDlgProc(IN HWND hwndDlg, + IN UINT uMsg, + IN WPARAM wParam, + IN LPARAM lParam) +{ + PHARDWARE_PAGE_DATA hpd; + + hpd = (PHARDWARE_PAGE_DATA)GetWindowLongPtr(hwndDlg, + DWL_USER); + + if (hpd != NULL || uMsg == WM_INITDIALOG) + { + switch (uMsg) + { + case WM_NOTIFY: + { + NMHDR *pnmh = (NMHDR*)lParam; + if (pnmh->hwndFrom == hpd->hWndDevList) + { + switch (pnmh->code) + { + case LVN_ITEMCHANGED: + { + LPNMLISTVIEW pnmv = (LPNMLISTVIEW)lParam; + + if ((pnmv->uChanged & LVIF_STATE) && + ((pnmv->uOldState & (LVIS_FOCUSED | LVIS_SELECTED)) || + (pnmv->uNewState & (LVIS_FOCUSED | LVIS_SELECTED)))) + { + UpdateControlStates(hpd); + } + break; + } + } + } + break; + } + + case WM_SIZE: + HardwareDlgResize(hpd, + (INT)LOWORD(lParam), + (INT)HIWORD(lParam)); + break; + + case WM_INITDIALOG: + { + hpd = (PHARDWARE_PAGE_DATA)lParam; + if (hpd != NULL) + { + HWND hWndParent; + + hpd->hWnd = hwndDlg; + SetWindowLongPtr(hwndDlg, + DWL_USER, + (DWORD_PTR)hpd); + + hpd->ClassImageListData.cbSize = sizeof(SP_CLASSIMAGELIST_DATA); + + SetupDiGetClassImageList(&hpd->ClassImageListData); + + hpd->hWndDevList = GetDlgItem(hwndDlg, + IDC_LV_DEVICES); + + /* subclass the parent window */ + hWndParent = GetAncestor(hwndDlg, + GA_PARENT); + if (hWndParent != NULL) + { + RECT rcClient; + + if (GetClientRect(hWndParent, + &rcClient) && + SetWindowPos(hwndDlg, + NULL, + 0, + 0, + rcClient.right, + rcClient.bottom, + SWP_NOZORDER)) + { + /* subclass the parent window. This is not safe + if the parent window belongs to another thread! */ + hpd->ParentOldWndProc = (WNDPROC)SetWindowLongPtr(hWndParent, + GWLP_WNDPROC, + (LONG_PTR)ParentSubWndProc); + + if (hpd->ParentOldWndProc != NULL && + SetProp(hWndParent, + L"DevMgrSubClassInfo", + (HANDLE)hpd)) + { + hpd->hWndParent = hWndParent; + } + } + } + + /* initialize the devices list view control */ + InitializeDevicesList(hpd); + + /* fill the devices list view control */ + FillDevicesList(hpd); + } + break; + } + + case WM_DESTROY: + { + UINT i; + + /* free the device info set handles */ + for (i = 0; + i < hpd->NumberOfGuids; + i++) + { + SetupDiDestroyDeviceInfoList(hpd->ClassDevInfo[i].hDevInfo); + if (hpd->ClassDevInfo[i].HwDevInfo != NULL) + { + HeapFree(GetProcessHeap(), + 0, + hpd->ClassDevInfo[i].HwDevInfo); + } + } + + /* restore the old window proc of the subclassed parent window */ + if (hpd->hWndParent != NULL && hpd->ParentOldWndProc != NULL) + { + SetWindowLongPtr(hpd->hWndParent, + GWLP_WNDPROC, + (LONG_PTR)hpd->ParentOldWndProc); + } + + if (hpd->ClassImageListData.ImageList != NULL) + { + SetupDiDestroyClassImageList(&hpd->ClassImageListData); + } + + /* free the reference to comctl32 */ + FreeLibrary(hpd->hComCtl32); + hpd->hComCtl32 = NULL; + + /* free the allocated resources */ + HeapFree(GetProcessHeap(), + 0, + hpd); + break; + } + } + } + + return FALSE; +} + + +/********************************************************************** ***** + * NAME EXPORTED + * DeviceCreateHardwarePageEx + * + * DESCRIPTION + * Creates a hardware page + * + * ARGUMENTS + * hWndParent: Handle to the parent window + * lpGuids: An array of guids of devices that are to be listed + * uNumberOfGuids: Numbers of guids in the Guids array + * Unknown: Unknown parameter, see NOTEs + * + * RETURN VALUE + * Returns the handle of the hardware page window that has been created or + * NULL if it failed. + * + * REVISIONS + * 13-05-2005 first working version (Sebastian Gasiorek zebasoftis@gmail.com) + * + * NOTE + * uUnknown seems to be some kind of flag how the entries should be displayed, + * in Win it seems to be always 0x00000001 + * + * TODO + * missing: device icon in list view, Troubleshoot button, device properties, + * status description, + * devices should be visible afer PSN_SETACTIVE message + * + */ +HWND +WINAPI +DeviceCreateHardwarePageEx(IN HWND hWndParent, + IN LPGUID lpGuids, + IN UINT uNumberOfGuids, + IN HWPAGE_DISPLAYMODE DisplayMode) +{ + PHARDWARE_PAGE_DATA hpd; + PINITCOMMONCONTROLS pInitCommonControls; + + /* allocate the HARDWARE_PAGE_DATA structure. Make sure it is + zeroed because the initialization code assumes that in + failure cases! */ + hpd = HeapAlloc(GetProcessHeap(), + HEAP_ZERO_MEMORY, + FIELD_OFFSET(HARDWARE_PAGE_DATA, + ClassDevInfo) + + (uNumberOfGuids * sizeof(HWCLASSDEVINFO))); + if (hpd != NULL) + { + HWND hWnd; + UINT i; + + hpd->DisplayMode = ((DisplayMode > HWPD_MAX) ? HWPD_STANDARDLIST : DisplayMode); + + /* initialize the HARDWARE_PAGE_DATA structure */ + hpd->NumberOfGuids = uNumberOfGuids; + for (i = 0; + i < uNumberOfGuids; + i++) + { + hpd->ClassDevInfo[i].Guid = lpGuids[i]; + } + + /* load comctl32.dll dynamically */ + hpd->hComCtl32 = LoadLibrary(TEXT("comctl32.dll")); + if (hpd->hComCtl32 == NULL) + { + goto Cleanup; + } + + /* initialize the common controls */ + pInitCommonControls = (PINITCOMMONCONTROLS)GetProcAddress(hpd->hComCtl32, + "InitCommonControls"); + if (pInitCommonControls == NULL) + { + goto Cleanup; + } + pInitCommonControls(); + + /* create the dialog */ + hWnd = CreateDialogParam(hDllInstance, + MAKEINTRESOURCE(IDD_HARDWARE), + hWndParent, + HardwareDlgProc, + (LPARAM)hpd); + if (hWnd != NULL) + { + return hWnd; + } + else + { +Cleanup: + /* oops, something went wrong... */ + if (hpd->hComCtl32 != NULL) + { + FreeLibrary(hpd->hComCtl32); + } + + HeapFree(GetProcessHeap(), + 0, + hpd); + } + } + + return NULL; +} + + +/********************************************************************** ***** + * NAME EXPORTED + * DeviceCreateHardwarePage + * + * DESCRIPTION + * Creates a hardware page + * + * ARGUMENTS + * hWndParent: Handle to the parent window + * lpGuid: Guid of the device + * + * RETURN VALUE + * Returns the handle of the hardware page window that has been created or + * NULL if it failed. + * + * REVISIONS + * + * NOTE + * + */ + +HWND +WINAPI +DeviceCreateHardwarePage(IN HWND hWndParent, + IN LPGUID lpGuid) +{ + return DeviceCreateHardwarePageEx(hWndParent, + lpGuid, + 1, + HWPD_LARGELIST); +} + + +BOOL +STDCALL +DllMain(IN HINSTANCE hinstDLL, + IN DWORD dwReason, + IN LPVOID lpvReserved) +{ + switch (dwReason) + { + case DLL_PROCESS_ATTACH: + DisableThreadLibraryCalls(hinstDLL); + hDllInstance = hinstDLL; + break; + } + + return TRUE; +} _____
Deleted: trunk/reactos/lib/devmgr/devmgr.h --- trunk/reactos/lib/devmgr/devmgr.h 2005-11-25 14:15:46 UTC (rev 19550) +++ trunk/reactos/lib/devmgr/devmgr.h 2005-11-25 14:17:30 UTC (rev 19551) @@ -1,155 +0,0 @@
-#ifndef __DEVMGR_H -#define __DEVMGR_H - -extern HINSTANCE hDllInstance; - -WINBOOL -WINAPI -DeviceManager_ExecuteA(HWND hWndParent, - HINSTANCE hInst, - LPCSTR lpMachineName, - int nCmdShow); - -WINBOOL -WINAPI -DeviceManager_ExecuteW(HWND hWndParent, - HINSTANCE hInst, - LPCWSTR lpMachineName, - int nCmdShow); - -VOID -WINAPI -DeviceProperties_RunDLLA(HWND hWndParent, - HINSTANCE hInst, - LPCWSTR lpDeviceCmd, - int nCmdShow); - -VOID -WINAPI -DeviceProperties_RunDLLW(HWND hWndParent, - HINSTANCE hInst, - LPCSTR lpDeviceCmd, - int nCmdShow); - -int -WINAPI -DevicePropertiesA(HWND hWndParent, - HINSTANCE hInst, - LPCSTR lpMachineName, - LPCSTR lpDeviceID, - DWORD Unknown); - -int -WINAPI -DevicePropertiesW(HWND hWndParent, - HINSTANCE hInst, - LPCWSTR lpMachineName, - LPCWSTR lpDeviceID, - DWORD Unknown); - -UINT -WINAPI -DeviceProblemTextA(PVOID Unknown1, - PVOID Unknown2, - UINT uProblemId, - LPSTR lpString, - UINT uMaxString); - -UINT -WINAPI -DeviceProblemTextW(PVOID Unknown1, - PVOID Unknown2, - UINT uProblemId, - LPWSTR lpString, - UINT uMaxString); - -WINBOOL -WINAPI -DeviceProblemWizardA(HWND hWndParent, - LPCSTR lpMachineName, - LPCSTR lpDeviceID); - - -WINBOOL -WINAPI [truncated at 1000 lines; 605 more skipped]