[REGEDIT] Only set a registry path if the root node is not selected, adjust checks
[reactos.git] / reactos / base / applications / regedit / framewnd.c
index a0ea7cb..9f42346 100644 (file)
@@ -15,7 +15,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
  */
 
 #include <regedit.h>
@@ -87,7 +87,7 @@ static void OnInitMenu(HWND hWnd)
         while(RemoveMenu(hMenu, s_nFavoriteMenuSubPos, MF_BYPOSITION))
             ;
     }
-    
+
     lResult = RegOpenKey(HKEY_CURRENT_USER, s_szFavoritesRegKey, &hKey);
     if (lResult != ERROR_SUCCESS)
         goto done;
@@ -356,11 +356,11 @@ static UINT_PTR CALLBACK ExportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, W
 
         hwndExportAll = GetDlgItem(hdlg, IDC_EXPORT_ALL);
         if (hwndExportAll)
-                       SendMessage(hwndExportAll, BM_SETCHECK, pszSelectedKey[0] ? BST_UNCHECKED : BST_CHECKED, 0);
+            SendMessage(hwndExportAll, BM_SETCHECK, pszSelectedKey ? BST_UNCHECKED : BST_CHECKED, 0);
 
         hwndExportBranch = GetDlgItem(hdlg, IDC_EXPORT_BRANCH);
         if (hwndExportBranch)
-            SendMessage(hwndExportBranch, BM_SETCHECK, pszSelectedKey[0] ? BST_CHECKED : BST_UNCHECKED, 0);
+            SendMessage(hwndExportBranch, BM_SETCHECK, pszSelectedKey ? BST_CHECKED : BST_UNCHECKED, 0);
 
         hwndExportBranchText = GetDlgItem(hdlg, IDC_EXPORT_BRANCH_TEXT);
         if (hwndExportBranchText)
@@ -406,7 +406,12 @@ BOOL ExportRegistryFile(HWND hWnd)
     InitOpenFileName(hWnd, &ofn);
     LoadString(hInst, IDS_EXPORT_REG_FILE, Caption, sizeof(Caption)/sizeof(TCHAR));
     ofn.lpstrTitle = Caption;
-    ofn.lCustData = (LPARAM) ExportKeyPath;
+
+    /* Only set the path if a key (not the root node) is selected */
+    if (hKeyRoot != 0)
+    {
+        ofn.lCustData = (LPARAM) ExportKeyPath;
+    }
     ofn.Flags = OFN_ENABLETEMPLATE | OFN_EXPLORER | OFN_ENABLEHOOK;
     ofn.lpfnHook = ExportRegistryFile_OFNHookProc;
     ofn.lpTemplateName = MAKEINTRESOURCE(IDD_EXPORTRANGE);
@@ -590,7 +595,7 @@ static BOOL CreateNewValue(HKEY hRootKey, LPCTSTR pszKeyPath, DWORD dwType)
     LVFINDINFO lvfi;
 
     if (RegOpenKey(hRootKey, pszKeyPath, &hKey) != ERROR_SUCCESS)
-        return FALSE;    
+        return FALSE;
 
     LoadString(hInst, IDS_NEW_VALUE, szNewValueFormat, sizeof(szNewValueFormat)
         / sizeof(szNewValueFormat[0]));
@@ -805,7 +810,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
         IDsObjectPicker *ObjectPicker;
         TCHAR szComputerName[MAX_COMPUTERNAME_LENGTH + 1];
         HRESULT hRet;
-        
+
         hRet = CoInitialize(NULL);
         if (SUCCEEDED(hRet))
         {
@@ -941,12 +946,12 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
               }
             }
           }
-        } else 
+        } else
         if (GetFocus() == g_pChildWnd->hTreeWnd)
         {
           if (keyPath == 0 || *keyPath == 0)
           {
-             MessageBeep(MB_ICONHAND); 
+             MessageBeep(MB_ICONHAND);
           } else
           if (DeleteKey(hWnd, hKeyRoot, keyPath))
           {
@@ -1060,7 +1065,7 @@ LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
             return DefWindowProc(hWnd, message, wParam, lParam);
         break;
     case WM_ACTIVATE:
-        if (LOWORD(hWnd)) 
+        if (LOWORD(hWnd))
             SetFocus(g_pChildWnd->hWnd);
         break;
     case WM_SIZE: