[PSDK][REACTOS] Fix definitions and usage of DWLP_MSGRESULT, DWLP_DLGPROC, and DWLP_USER
[reactos.git] / dll / win32 / shell32 / dialogs / drvdefext.cpp
index d24fcb8..ef4c2c6 100644 (file)
@@ -58,7 +58,7 @@ GetDriveNameWithLetter(LPWSTR pwszText, UINT cchTextMax, LPCWSTR pwszDrive)
         }
     }
 
-    StringCchPrintfW(pwszText + cchText, cchTextMax - cchText, L" (%c)", pwszDrive[0]);
+    StringCchPrintfW(pwszText + cchText, cchTextMax - cchText, L" (%c:)", pwszDrive[0]);
 }
 
 static VOID
@@ -211,45 +211,66 @@ CDrvDefExt::PaintStaticControls(HWND hwndDlg, LPDRAWITEMSTRUCT pDrawItem)
     {
         HBRUSH hBlueBrush = CreateSolidBrush(RGB(0, 0, 255));
         HBRUSH hMagBrush = CreateSolidBrush(RGB(255, 0, 255));
+        HBRUSH hbrOld;
         HPEN hDarkBluePen = CreatePen(PS_SOLID, 1, RGB(0, 0, 128));
         HPEN hDarkMagPen = CreatePen(PS_SOLID, 1, RGB(128, 0, 128));
-
-        INT xCenter = (pDrawItem->rcItem.left + pDrawItem->rcItem.right)/2;
-        INT yCenter = (pDrawItem->rcItem.top + pDrawItem->rcItem.bottom - 10)/2;
+        HPEN hOldPen = (HPEN)SelectObject(pDrawItem->hDC, hDarkMagPen);
+        INT xCenter = (pDrawItem->rcItem.left + pDrawItem->rcItem.right) / 2;
+        INT yCenter = (pDrawItem->rcItem.top + pDrawItem->rcItem.bottom - 10) / 2;
         INT cx = pDrawItem->rcItem.right - pDrawItem->rcItem.left;
         INT cy = pDrawItem->rcItem.bottom - pDrawItem->rcItem.top - 10;
-        TRACE("FreeSpace %u a %f cx %d\n", m_FreeSpacePerc, M_PI+m_FreeSpacePerc/100.0f*M_PI*2.0f, cx);
-
-        HBRUSH hbrOld = (HBRUSH)SelectObject(pDrawItem->hDC, hMagBrush);
-        INT xRadial = xCenter + (INT)(cos(M_PI+m_FreeSpacePerc/100.0f*M_PI*2.0f)*cx/2);
-        INT yRadial = yCenter - (INT)(sin(M_PI+m_FreeSpacePerc/100.0f*M_PI*2.0f)*cy/2);
-        Pie(pDrawItem->hDC,
-            pDrawItem->rcItem.left, pDrawItem->rcItem.top,
-            pDrawItem->rcItem.right, pDrawItem->rcItem.bottom - 10,
-            pDrawItem->rcItem.left, yCenter,
-            xRadial, yRadial);
-
-        SelectObject(pDrawItem->hDC, hBlueBrush);
-        Pie(pDrawItem->hDC,
-            pDrawItem->rcItem.left, pDrawItem->rcItem.top,
-            pDrawItem->rcItem.right, pDrawItem->rcItem.bottom - 10,
-            xRadial, yRadial,
-            pDrawItem->rcItem.left, yCenter);
-        SelectObject(pDrawItem->hDC, hbrOld);
+        INT xRadial = xCenter + (INT)(cos(M_PI + m_FreeSpacePerc / 100.0f * M_PI * 2.0f) * cx / 2);
+        INT yRadial = yCenter - (INT)(sin(M_PI + m_FreeSpacePerc / 100.0f * M_PI * 2.0f) * cy / 2);
+
+        TRACE("FreeSpace %u a %f cx %d\n", m_FreeSpacePerc, M_PI+m_FreeSpacePerc / 100.0f * M_PI * 2.0f, cx);
 
-        HPEN hOldPen = (HPEN)SelectObject(pDrawItem->hDC, hDarkMagPen);
         for (INT x = pDrawItem->rcItem.left; x < pDrawItem->rcItem.right; ++x)
         {
+            double cos_val = (x - xCenter) * 2.0f / cx;
+            INT y = yCenter + (INT)(sin(acos(cos_val)) * cy / 2) - 1;
+
             if (m_FreeSpacePerc < 50 && x == xRadial)
                 SelectObject(pDrawItem->hDC, hDarkBluePen);
 
-            double cos_val = (x - xCenter)*2.0f/cx;
-            INT y = yCenter+(INT)(sin(acos(cos_val))*cy/2);
             MoveToEx(pDrawItem->hDC, x, y, NULL);
             LineTo(pDrawItem->hDC, x, y + 10);
         }
+
         SelectObject(pDrawItem->hDC, hOldPen);
 
+        if (m_FreeSpacePerc > 50)
+        {
+            hbrOld = (HBRUSH)SelectObject(pDrawItem->hDC, hMagBrush);
+
+            Ellipse(pDrawItem->hDC, pDrawItem->rcItem.left, pDrawItem->rcItem.top,
+                    pDrawItem->rcItem.right, pDrawItem->rcItem.bottom - 10);
+
+            SelectObject(pDrawItem->hDC, hBlueBrush);
+
+            if (m_FreeSpacePerc < 100)
+            {
+                Pie(pDrawItem->hDC, pDrawItem->rcItem.left, pDrawItem->rcItem.top, pDrawItem->rcItem.right,
+                    pDrawItem->rcItem.bottom - 10, xRadial, yRadial, pDrawItem->rcItem.left, yCenter);
+            }
+        }
+        else
+        {
+            hbrOld = (HBRUSH)SelectObject(pDrawItem->hDC, hBlueBrush);
+
+            Ellipse(pDrawItem->hDC, pDrawItem->rcItem.left, pDrawItem->rcItem.top,
+                    pDrawItem->rcItem.right, pDrawItem->rcItem.bottom - 10);
+
+            SelectObject(pDrawItem->hDC, hMagBrush);
+            
+            if (m_FreeSpacePerc > 0)
+            {
+                Pie(pDrawItem->hDC, pDrawItem->rcItem.left, pDrawItem->rcItem.top, pDrawItem->rcItem.right,
+                    pDrawItem->rcItem.bottom - 10, pDrawItem->rcItem.left, yCenter, xRadial, yRadial);
+            }
+        }
+
+        SelectObject(pDrawItem->hDC, hbrOld);
+
         DeleteObject(hBlueBrush);
         DeleteObject(hMagBrush);
         DeleteObject(hDarkBluePen);
@@ -272,17 +293,36 @@ CDrvDefExt::InitGeneralPage(HWND hwndDlg)
         SetDlgItemTextW(hwndDlg, 14000, wszVolumeName);
         SetDlgItemTextW(hwndDlg, 14002, wszFileSystem);
     }
+    else
+    {
+        LoadStringW(shell32_hInstance, IDS_FS_UNKNOWN, wszFileSystem, _countof(wszFileSystem));
+        SetDlgItemTextW(hwndDlg, 14002, wszFileSystem);
+    }
 
     /* Set drive type and icon */
     UINT DriveType = GetDriveTypeW(m_wszDrive);
     UINT IconId, TypeStrId = 0;
     switch (DriveType)
     {
+        case DRIVE_REMOVABLE: IconId = IDI_SHELL_3_14_FLOPPY; break;
         case DRIVE_CDROM: IconId = IDI_SHELL_CDROM; TypeStrId = IDS_DRIVE_CDROM; break;
-        case DRIVE_REMOVABLE: IconId = IDI_SHELL_FLOPPY; break;
+        case DRIVE_REMOTE: IconId = IDI_SHELL_NETDRIVE; TypeStrId = IDS_DRIVE_NETWORK; break;
         case DRIVE_RAMDISK: IconId = IDI_SHELL_RAMDISK; break;
         default: IconId = IDI_SHELL_DRIVE; TypeStrId = IDS_DRIVE_FIXED;
     }
+
+    if (DriveType == DRIVE_CDROM || DriveType == DRIVE_REMOTE)
+    {
+        /* volume label textbox */
+        SendMessage(GetDlgItem(hwndDlg, 14000), EM_SETREADONLY, TRUE, 0);
+        
+        /* disk compression */
+        ShowWindow(GetDlgItem(hwndDlg, 14011), FALSE);
+
+        /* index */
+        ShowWindow(GetDlgItem(hwndDlg, 14012), FALSE);
+    }
+    
     HICON hIcon = (HICON)LoadImage(shell32_hInstance, MAKEINTRESOURCE(IconId), IMAGE_ICON, 32, 32, LR_SHARED);
     if (hIcon)
         SendDlgItemMessageW(hwndDlg, 14016, STM_SETICON, (WPARAM)hIcon, 0);
@@ -316,12 +356,32 @@ CDrvDefExt::InitGeneralPage(HWND hwndDlg)
         if (StrFormatByteSizeW(TotalNumberOfBytes.QuadPart, wszBuf, _countof(wszBuf)))
             SetDlgItemTextW(hwndDlg, 14008, wszBuf);
     }
+    else
+    {
+        m_FreeSpacePerc = 0;
+
+        if (SH_FormatByteSize(0, wszBuf, _countof(wszBuf)))
+        {
+            SetDlgItemTextW(hwndDlg, 14003, wszBuf);
+            SetDlgItemTextW(hwndDlg, 14005, wszBuf);
+            SetDlgItemTextW(hwndDlg, 14007, wszBuf);
+        }
+        if (StrFormatByteSizeW(0, wszBuf, _countof(wszBuf)))
+        {
+            SetDlgItemTextW(hwndDlg, 14004, wszBuf);
+            SetDlgItemTextW(hwndDlg, 14006, wszBuf);
+            SetDlgItemTextW(hwndDlg, 14008, wszBuf);
+        }
+    }
 
     /* Set drive description */
     WCHAR wszFormat[50];
     GetDlgItemTextW(hwndDlg, 14009, wszFormat, _countof(wszFormat));
     swprintf(wszBuf, wszFormat, m_wszDrive[0]);
     SetDlgItemTextW(hwndDlg, 14009, wszBuf);
+    
+    /* show disk cleanup button only for fixed drives */
+    ShowWindow(GetDlgItem(hwndDlg, 14010), DriveType == DRIVE_FIXED);
 }
 
 INT_PTR CALLBACK
@@ -366,12 +426,12 @@ CDrvDefExt::GeneralPageProc(
                 DWORD cbBuf = sizeof(wszBuf);
 
                 if (RegGetValueW(HKEY_LOCAL_MACHINE,
-                                     L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MyComputer\\CleanupPath",
-                                     NULL,
-                                     RRF_RT_REG_SZ,
-                                     NULL,
-                                     (PVOID)wszBuf,
-                                     &cbBuf) == ERROR_SUCCESS)
+                                 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MyComputer\\CleanupPath",
+                                 NULL,
+                                 RRF_RT_REG_SZ,
+                                 NULL,
+                                 (PVOID)wszBuf,
+                                 &cbBuf) == ERROR_SUCCESS)
                 {
                     WCHAR wszCmd[MAX_PATH];
 
@@ -400,7 +460,7 @@ CDrvDefExt::GeneralPageProc(
 
                     if (GetDlgItemTextW(hwndDlg, 14000, wszBuf, _countof(wszBuf)))
                         SetVolumeLabelW(pDrvDefExt->m_wszDrive, wszBuf);
-                    SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, PSNRET_NOERROR);
+                    SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_NOERROR);
                     return TRUE;
                 }
             }
@@ -460,7 +520,7 @@ CDrvDefExt::ExtraPageProc(
                     if (RegGetValueW(HKEY_LOCAL_MACHINE,
                                      L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MyComputer\\BackupPath",
                                      NULL,
-                                     RRF_RT_REG_EXPAND_SZ,
+                                     RRF_RT_REG_SZ,
                                      NULL,
                                      (PVOID)wszBuf,
                                      &cbBuf) == ERROR_SUCCESS)