Patch by Christoph v.W.:

- speed-up adding items to ListView
- fix resource leak (GetDC without ReleaseDC)
(Bug #870)

svn path=/trunk/; revision=18296
This commit is contained in:
Gregor Anich 2005-10-06 15:02:50 +00:00
parent 23dc71c784
commit 611d7cf177

View file

@ -93,6 +93,8 @@ void ListByClass()
long Size; long Size;
long rc; long rc;
SendMessage(hwndListView, WM_SETREDRAW, FALSE, 0);
ListView_DeleteAllItems(hwndListView); ListView_DeleteAllItems(hwndListView);
while (1) while (1)
{ {
@ -187,6 +189,7 @@ void ListByClass()
} }
SetupDiDestroyDeviceInfoList(hDevInfo); SetupDiDestroyDeviceInfoList(hDevInfo);
} }
SendMessage(hwndListView, WM_SETREDRAW, TRUE, 0);
} }
CONFIGRET GetDeviceName(DEVINST DevInst, LPTSTR Buffer, DWORD BufferLength) CONFIGRET GetDeviceName(DEVINST DevInst, LPTSTR Buffer, DWORD BufferLength)
@ -271,8 +274,9 @@ int ListByConnection()
_tprintf(_T("CM_Locate_DevNode() failed, cr= 0x%lx\n"), cr); _tprintf(_T("CM_Locate_DevNode() failed, cr= 0x%lx\n"), cr);
return 1; return 1;
} }
SendMessage(hwndListView, WM_SETREDRAW, FALSE, 0);
cr = ListSubNodes(root, 0); cr = ListSubNodes(root, 0);
SendMessage(hwndListView, WM_SETREDRAW, TRUE, 0);
if (cr != CR_SUCCESS) if (cr != CR_SUCCESS)
return 2; return 2;
return 0; return 0;
@ -304,6 +308,7 @@ int ListByInterface(const GUID* guid)
i = 0; i = 0;
DeviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); DeviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
SendMessage(hwndListView, WM_SETREDRAW, FALSE, 0);
while (TRUE) while (TRUE)
{ {
if (!SetupDiEnumDeviceInterfaces( if (!SetupDiEnumDeviceInterfaces(
@ -332,6 +337,7 @@ int ListByInterface(const GUID* guid)
} }
} }
SendMessage(hwndListView, WM_SETREDRAW, TRUE, 0);
SetupDiDestroyDeviceInfoList(hDevInfo); SetupDiDestroyDeviceInfoList(hDevInfo);
return 0; return 0;
} }
@ -484,6 +490,7 @@ switch (uMessage)
ResizeListView(hWnd); ResizeListView(hWnd);
break; break;
case WM_DESTROY: case WM_DESTROY:
ReleaseDC(hWnd, hDC);
PostQuitMessage(0); PostQuitMessage(0);
break; break;
case WM_COMMAND: case WM_COMMAND: