2 * Regedit main function
4 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
28 #define REGEDIT_DECLARE_FUNCTIONS
31 WCHAR g_pszDefaultValueName[64];
33 BOOL ProcessCmdLine(LPSTR lpCmdLine);
35 static const WCHAR hkey_local_machine[] = {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0};
36 static const WCHAR hkey_users[] = {'H','K','E','Y','_','U','S','E','R','S',0};
37 static const WCHAR hkey_classes_root[] = {'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0};
38 static const WCHAR hkey_current_config[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0};
39 static const WCHAR hkey_current_user[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0};
40 static const WCHAR hkey_dyn_data[] = {'H','K','E','Y','_','D','Y','N','_','D','A','T','A',0};
42 const WCHAR *reg_class_namesW[] = {hkey_local_machine, hkey_users,
43 hkey_classes_root, hkey_current_config,
44 hkey_current_user, hkey_dyn_data
47 /*******************************************************************************
55 HMENU hPopupMenus = 0;
56 UINT nClipboardFormat;
57 const WCHAR strClipboardFormat[] = {'T','O','D','O',':',' ','S','E','T',' ','C','O','R','R','E','C','T',' ','F','O','R','M','A','T',0};
60 #define MAX_LOADSTRING 100
61 WCHAR szTitle[MAX_LOADSTRING];
62 const WCHAR szFrameClass[] = {'R','E','G','E','D','I','T','_','F','R','A','M','E',0};
63 const WCHAR szChildClass[] = {'R','E','G','E','D','I','T',0};
65 static BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
68 WNDCLASSEXW wndclass = {0};
71 wndclass.cbSize = sizeof(WNDCLASSEXW);
72 wndclass.style = CS_HREDRAW | CS_VREDRAW;
73 wndclass.lpfnWndProc = FrameWndProc;
74 wndclass.hInstance = hInstance;
75 wndclass.hIcon = LoadIconW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT));
76 wndclass.hCursor = LoadCursorW(0, (LPCWSTR)IDC_ARROW);
77 wndclass.lpszClassName = szFrameClass;
78 wndclass.hIconSm = LoadImageW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT), IMAGE_ICON,
79 GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED);
80 RegisterClassExW(&wndclass);
83 wndclass.lpfnWndProc = ChildWndProc;
84 wndclass.cbWndExtra = sizeof(HANDLE);
85 wndclass.lpszClassName = szChildClass;
86 RegisterClassExW(&wndclass);
88 hMenuFrame = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDR_REGEDIT_MENU));
89 hPopupMenus = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDR_POPUP_MENUS));
91 /* Initialize the Windows Common Controls DLL */
94 /* register our hex editor control */
97 nClipboardFormat = RegisterClipboardFormatW(strClipboardFormat);
99 hFrameWnd = CreateWindowExW(0, szFrameClass, szTitle,
100 WS_OVERLAPPEDWINDOW | WS_EX_CLIENTEDGE,
101 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
102 NULL, hMenuFrame, hInstance, NULL/*lpParam*/);
108 /* Create the status bar */
109 hStatusBar = CreateStatusWindowW(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBT_NOBORDERS,
110 &empty, hFrameWnd, STATUS_WINDOW);
112 /* Create the status bar panes */
113 SetupStatusBar(hFrameWnd, FALSE);
114 CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_STATUSBAR, MF_BYCOMMAND|MF_CHECKED);
116 ShowWindow(hFrameWnd, nCmdShow);
117 UpdateWindow(hFrameWnd);
121 /******************************************************************************/
123 static void ExitInstance(void)
125 DestroyMenu(hMenuFrame);
128 static BOOL TranslateChildTabMessage(MSG *msg)
130 if (msg->message != WM_KEYDOWN) return FALSE;
131 if (msg->wParam != VK_TAB) return FALSE;
132 if (GetParent(msg->hwnd) != g_pChildWnd->hWnd) return FALSE;
133 PostMessageW(g_pChildWnd->hWnd, WM_COMMAND, ID_SWITCH_PANELS, 0);
137 int APIENTRY WinMain(HINSTANCE hInstance,
138 HINSTANCE hPrevInstance,
145 if (ProcessCmdLine(lpCmdLine)) {
149 /* Initialize global strings */
150 LoadStringW(hInstance, IDS_APP_TITLE, szTitle, COUNT_OF(szTitle));
151 LoadStringW(hInstance, IDS_REGISTRY_DEFAULT_VALUE, g_pszDefaultValueName, COUNT_OF(g_pszDefaultValueName));
153 /* Store instance handle in our global variable */
156 /* Perform application initialization */
157 if (!InitInstance(hInstance, nCmdShow)) {
160 hAccel = LoadAcceleratorsW(hInstance, MAKEINTRESOURCEW(IDC_REGEDIT));
162 /* Main message loop */
163 while (GetMessageW(&msg, NULL, 0, 0)) {
164 if (!TranslateAcceleratorW(hFrameWnd, hAccel, &msg)
165 && !TranslateChildTabMessage(&msg)) {
166 TranslateMessage(&msg);
167 DispatchMessageW(&msg);