[CRT] crtdefs.h: Wrap localeinfo_struct in ifdef
[reactos.git] / base / applications / regedit / main.c
index acb8a7b..c762d65 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include <regedit.h>
+#include "regedit.h"
 
-BOOL ProcessCmdLine(LPWSTR lpCmdLine);
+BOOL ProcessCmdLine(WCHAR *cmdline);
 
+const WCHAR *reg_class_namesW[] = {L"HKEY_LOCAL_MACHINE", L"HKEY_USERS",
+                                   L"HKEY_CLASSES_ROOT", L"HKEY_CURRENT_CONFIG",
+                                   L"HKEY_CURRENT_USER", L"HKEY_DYN_DATA"
+                                  };
 
 /*******************************************************************************
  * Global Variables:
@@ -58,7 +62,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
 {
     BOOL AclUiAvailable;
     HMENU hEditMenu;
-
+    INITCOMMONCONTROLSEX icce;
     WNDCLASSEXW wcFrame;
     WNDCLASSEXW wcChild;
     ATOM hFrameWndClass;
@@ -72,6 +76,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
                                         IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),
                                         GetSystemMetrics(SM_CYSMICON), LR_SHARED);
     wcFrame.hCursor = LoadCursorW(NULL, IDC_ARROW);
+    wcFrame.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
     wcFrame.lpszClassName = szFrameClass;
 
     hFrameWndClass = RegisterClassExW(&wcFrame); /* register frame window class */
@@ -83,6 +88,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
     wcChild.hInstance = hInstance;
     wcChild.hIcon = LoadIconW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT));
     wcChild.hCursor = LoadCursorW(NULL, IDC_ARROW);
+    wcChild.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
     wcChild.lpszClassName = szChildClass;
     wcChild.hIconSm = (HICON)LoadImageW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT),
                                         IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),
@@ -96,8 +102,10 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
     hPopupMenus = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDR_POPUP_MENUS));
 
     /* Initialize the Windows Common Controls DLL */
-    // TODO: Replace this call by InitCommonControlsEx(_something_)
-    InitCommonControls();
+    /* NOTE: Windows sets 0xFFFF to icce.dwICC but we use better value. */
+    icce.dwSize = sizeof(icce);
+    icce.dwICC = ICC_WIN95_CLASSES | ICC_STANDARD_CLASSES | ICC_USEREX_CLASSES;
+    InitCommonControlsEx(&icce);
 
     hEditMenu = GetSubMenu(hMenuFrame, 1);
 
@@ -183,11 +191,11 @@ BOOL TranslateChildTabMessage(PMSG msg)
 
     if (msg->wParam != VK_TAB) return FALSE;
     if (GetParent(msg->hwnd) != g_pChildWnd->hWnd) return FALSE;
-    PostMessageW(g_pChildWnd->hWnd, WM_COMMAND, ID_SWITCH_PANELS, 0);
+    PostMessageW(hFrameWnd, WM_COMMAND, ID_SWITCH_PANELS, 0);
     return TRUE;
 }
 
-int APIENTRY wWinMain(HINSTANCE hInstance,
+int WINAPI wWinMain(HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPWSTR    lpCmdLine,
                       int       nCmdShow)
@@ -197,23 +205,32 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
 
     UNREFERENCED_PARAMETER(hPrevInstance);
 
-    if (ProcessCmdLine(lpCmdLine))
+    /* Initialize global strings */
+    LoadStringW(hInstance, IDS_APP_TITLE, szTitle, ARRAY_SIZE(szTitle));
+    LoadStringW(hInstance, IDC_REGEDIT_FRAME, szFrameClass, ARRAY_SIZE(szFrameClass));
+    LoadStringW(hInstance, IDC_REGEDIT, szChildClass, ARRAY_SIZE(szChildClass));
+
+    if (ProcessCmdLine(GetCommandLineW()))
     {
         return 0;
     }
 
-    /* Initialize global strings */
-    LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
-    LoadStringW(hInstance, IDC_REGEDIT_FRAME, szFrameClass, MAX_LOADSTRING);
-    LoadStringW(hInstance, IDC_REGEDIT, szChildClass, MAX_LOADSTRING);
+    switch (GetUserDefaultUILanguage())
+    {
+        case MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT):
+            SetProcessDefaultLayout(LAYOUT_RTL);
+            break;
 
+        default:
+            break;
+    }
     /* Store instance handle in our global variable */
     hInst = hInstance;
 
     /* Perform application initialization */
     if (!InitInstance(hInstance, nCmdShow))
     {
-        return FALSE;
+        return 0;
     }
     hAccel = LoadAcceleratorsW(hInstance, MAKEINTRESOURCEW(ID_ACCEL));