Author: dchapyshev
Date: Fri Jan 16 10:53:32 2009
New Revision: 38795
URL:
http://svn.reactos.org/svn/reactos?rev=38795&view=rev
Log:
- Fix bug with addition of duplicates to the devices list
- Other small changes
Modified:
trunk/reactos/dll/cpl/hdwwiz/hdwwiz.c
Modified: trunk/reactos/dll/cpl/hdwwiz/hdwwiz.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/hdwwiz/hdwwiz.c?re…
==============================================================================
--- trunk/reactos/dll/cpl/hdwwiz/hdwwiz.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/hdwwiz/hdwwiz.c [iso-8859-1] Fri Jan 16 10:53:32 2009
@@ -310,12 +310,10 @@
LoadString(hApplet, IDS_ADDNEWDEVICE, szBuffer, sizeof(szBuffer) / sizeof(WCHAR));
Item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
- Item.pszText = (LPTSTR) szBuffer;
- Item.iItem = 0;
+ Item.pszText = (LPWSTR) szBuffer;
+ Item.iItem = (INT) ListView_GetItemCount(hList);
Item.iImage = -1;
(VOID) ListView_InsertItem(hList, &Item);
-
- (VOID) ListView_SetExtendedListViewStyle(hList, LVS_EX_FULLROWSELECT);
hDevInfo = SetupDiGetClassDevsEx(NULL, NULL, NULL, DIGCF_ALLCLASSES | DIGCF_PRESENT,
NULL, NULL, 0);
@@ -328,6 +326,8 @@
DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
for (Index = 0; TRUE; Index++)
{
+ szBuffer[0] = L'\0';
+
if (!SetupDiEnumDeviceInfo(hDevInfo, Index, &DevInfoData)) break;
if (CM_Get_DevNode_Status_Ex(&ulStatus, &ulProblemNumber,
DevInfoData.DevInst, 0, NULL) == CR_SUCCESS)
@@ -378,17 +378,21 @@
pstrStatusText = (PWSTR)HeapAlloc(hProcessHeap, 0, sizeof(szStatusText));
lstrcpy(pstrStatusText, szStatusText);
- /* Set device name */
- Item.pszText = (LPWSTR) szBuffer;
- Item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
- Item.lParam = (LPARAM) pstrStatusText;
- Item.iItem = (INT) ListView_GetItemCount(hList);
- (VOID) ListView_InsertItem(hList, &Item);
+ if (szBuffer[0] != L'\0')
+ {
+ /* Set device name */
+ Item.pszText = (LPWSTR) szBuffer;
+ Item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
+ Item.lParam = (LPARAM) pstrStatusText;
+ Item.iItem = (INT) ListView_GetItemCount(hList);
+ (VOID) ListView_InsertItem(hList, &Item);
+ }
DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
}
(VOID) ListView_SetImageList(hList, ImageListData.ImageList, LVSIL_SMALL);
+ (VOID) ListView_SetExtendedListViewStyle(hList, LVS_EX_FULLROWSELECT);
SetupDiDestroyDeviceInfoList(hDevInfo);
}
@@ -406,12 +410,6 @@
}
break;
- case WM_COMMAND:
- {
-
- }
- break;
-
case WM_NOTIFY:
{
LPNMHDR lpnm = (LPNMHDR)lParam;
@@ -420,43 +418,32 @@
{
case PSN_SETACTIVE:
{
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK);
+ PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK |
PSWIZB_NEXT);
}
break;
- case NM_CLICK:
+ case PSN_WIZNEXT:
{
Index = (INT) SendMessage(GetDlgItem(hwndDlg, IDC_PROBELIST),
LVM_GETNEXTITEM, -1, LVNI_FOCUSED);
- if (Index != -1)
+ if (Index == -1) Index = 0;
+
+ if (Index == 0)
{
- PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK |
PSWIZB_NEXT);
+ SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_SELECTWAYPAGE);
}
- }
- break;
-
- case PSN_WIZNEXT:
- {
- Index = (INT) SendMessage(GetDlgItem(hwndDlg, IDC_PROBELIST),
LVM_GETNEXTITEM, -1, LVNI_FOCUSED);
- if (Index != -1)
+ else
{
- if (Index == 0)
- {
- SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_SELECTWAYPAGE);
- }
- else
- {
- LVITEM Item;
- PWSTR pts;
-
- ZeroMemory(&Item, sizeof(LV_ITEM));
- Item.mask = LVIF_PARAM;
- Item.iItem = Index;
- (VOID) ListView_GetItem(GetDlgItem(hwndDlg, IDC_PROBELIST),
&Item);
- pts = (PWSTR) Item.lParam;
- wcscpy(pDeviceStatusText, pts);
-
- SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_HWSTATUSPAGE);
- }
+ LVITEM Item;
+ PWSTR pts;
+
+ ZeroMemory(&Item, sizeof(LV_ITEM));
+ Item.mask = LVIF_PARAM;
+ Item.iItem = Index;
+ (VOID) ListView_GetItem(GetDlgItem(hwndDlg, IDC_PROBELIST),
&Item);
+ pts = (PWSTR) Item.lParam;
+ wcscpy(pDeviceStatusText, pts);
+
+ SetWindowLong(hwndDlg, DWL_MSGRESULT, IDD_HWSTATUSPAGE);
}
return TRUE;
}
@@ -535,8 +522,6 @@
{
/* Set title font */
SendDlgItemMessage(hwndDlg, IDC_FINISHTITLE, WM_SETFONT, (WPARAM)hTitleFont,
(LPARAM)TRUE);
- /* Set status text */
- SetWindowText(GetDlgItem(hwndDlg, IDC_HWSTATUSEDIT), pDeviceStatusText);
}
break;
@@ -548,6 +533,9 @@
{
case PSN_SETACTIVE:
{
+ /* Set status text */
+ SetWindowText(GetDlgItem(hwndDlg, IDC_HWSTATUSEDIT),
pDeviceStatusText);
+
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_FINISH |
PSWIZB_BACK);
}
break;