Don't assume WM_DESTROY is last message - listview sends notification after it. Confi...
[reactos.git] / reactos / dll / win32 / devmgr / hwpage.c
index ef7eb5e..57b52d2 100644 (file)
@@ -14,7 +14,7 @@
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 /* $Id$
  *
@@ -151,7 +151,7 @@ UpdateControlStates(IN PHARDWARE_PAGE_DATA hpd)
 {
     PHWDEVINFO HwDevInfo;
     HWND hBtnTroubleShoot, hBtnProperties;
-    
+
     hBtnTroubleShoot = GetDlgItem(hpd->hWnd,
                                   IDC_TROUBLESHOOT);
     hBtnProperties = GetDlgItem(hpd->hWnd,
@@ -181,7 +181,8 @@ UpdateControlStates(IN PHARDWARE_PAGE_DATA hpd)
         }
 
         /* get the location string */
-        if (GetDeviceLocationString(HwDevInfo->DevInfoData.DevInst,
+        if (GetDeviceLocationString(HwDevInfo->ClassDevInfo->hDevInfo,
+                                    &HwDevInfo->DevInfoData,
                                     0,
                                     szBuffer,
                                     sizeof(szBuffer) / sizeof(szBuffer[0])) &&
@@ -819,7 +820,7 @@ HardwareDlgProc(IN HWND hwndDlg,
                         case LVN_ITEMCHANGED:
                         {
                             LPNMLISTVIEW pnmv = (LPNMLISTVIEW)lParam;
-                            
+
                             if ((pnmv->uChanged & LVIF_STATE) &&
                                 ((pnmv->uOldState & (LVIS_FOCUSED | LVIS_SELECTED)) ||
                                  (pnmv->uNewState & (LVIS_FOCUSED | LVIS_SELECTED))))
@@ -862,7 +863,7 @@ HardwareDlgProc(IN HWND hwndDlg,
                 HardwareDlgResize(hpd,
                                   (INT)LOWORD(lParam),
                                   (INT)HIWORD(lParam));
-                break;            
+                break;
 
             case WM_SETTEXT:
             {
@@ -963,6 +964,9 @@ HardwareDlgProc(IN HWND hwndDlg,
 
             case WM_DESTROY:
             {
+               /* zero hpd pointer in window data, because it can be used later (WM_DESTROY has not to be last message) */
+               SetWindowLongPtr(hwndDlg, DWL_USER, (DWORD_PTR)NULL);
+                
                 /* free devices list */
                 FreeDevicesList(hpd);
 
@@ -1057,9 +1061,9 @@ DeviceCreateHardwarePageEx(IN HWND hWndParent,
 
         /* create the dialog */
         hWnd = CreateDialogParam(hDllInstance,
-                                 MAKEINTRESOURCE(IDD_HARDWARE), 
-                                 hWndParent, 
-                                 HardwareDlgProc, 
+                                 MAKEINTRESOURCE(IDD_HARDWARE),
+                                 hWndParent,
+                                 HardwareDlgProc,
                                  (LPARAM)hpd);
         if (hWnd != NULL)
         {