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 */
29 #define REGEDIT_DECLARE_FUNCTIONS
32 TCHAR g_pszDefaultValueName[64];
33 WCHAR g_pszDefaultValueNameW[64];
35 BOOL ProcessCmdLine(LPSTR lpCmdLine);
37 static const WCHAR hkey_local_machine[] = {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0};
38 static const WCHAR hkey_users[] = {'H','K','E','Y','_','U','S','E','R','S',0};
39 static const WCHAR hkey_classes_root[] = {'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0};
40 static const WCHAR hkey_current_config[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0};
41 static const WCHAR hkey_current_user[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0};
42 static const WCHAR hkey_dyn_data[] = {'H','K','E','Y','_','D','Y','N','_','D','A','T','A',0};
44 const WCHAR *reg_class_namesW[] = {hkey_local_machine, hkey_users,
45 hkey_classes_root, hkey_current_config,
46 hkey_current_user, hkey_dyn_data
49 /*******************************************************************************
57 HMENU hPopupMenus = 0;
58 UINT nClipboardFormat;
59 LPCTSTR strClipboardFormat = _T("TODO: SET CORRECT FORMAT");
62 #define MAX_LOADSTRING 100
63 TCHAR szTitle[MAX_LOADSTRING];
64 const TCHAR szFrameClass[] = {'R','E','G','E','D','I','T','_','F','R','A','M','E',0};
65 const TCHAR szChildClass[] = {'R','E','G','E','D','I','T',0};
68 /*******************************************************************************
71 * FUNCTION: InitInstance(HANDLE, int)
73 * PURPOSE: Saves instance handle and creates main window
77 * In this function, we save the instance handle in a global variable and
78 * create and display the main program window.
81 static BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
84 WNDCLASSEX wcFrame = {
86 CS_HREDRAW | CS_VREDRAW/*style*/,
91 LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT)),
92 LoadCursor(0, IDC_ARROW),
96 (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON,
97 GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED)
99 ATOM hFrameWndClass = RegisterClassEx(&wcFrame); /* register frame window class */
101 WNDCLASSEX wcChild = {
103 CS_HREDRAW | CS_VREDRAW/*style*/,
106 sizeof(HANDLE)/*cbWndExtra*/,
108 LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT)),
109 LoadCursor(0, IDC_ARROW),
113 (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON,
114 GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED)
117 ATOM hChildWndClass = RegisterClassEx(&wcChild); /* register child windows class */
118 hChildWndClass = hChildWndClass; /* warning eater */
120 hMenuFrame = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDR_REGEDIT_MENU));
121 hPopupMenus = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDR_POPUP_MENUS));
123 /* Initialize the Windows Common Controls DLL */
124 InitCommonControls();
126 /* register our hex editor control */
129 nClipboardFormat = RegisterClipboardFormat(strClipboardFormat);
130 /* if (nClipboardFormat == 0) {
131 DWORD dwError = GetLastError();
134 hFrameWnd = CreateWindowEx(0, MAKEINTRESOURCE(hFrameWndClass), szTitle,
135 WS_OVERLAPPEDWINDOW | WS_EX_CLIENTEDGE,
136 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
137 NULL, hMenuFrame, hInstance, NULL/*lpParam*/);
143 /* Create the status bar */
144 hStatusBar = CreateStatusWindowW(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBT_NOBORDERS,
145 &empty, hFrameWnd, STATUS_WINDOW);
147 /* Create the status bar panes */
148 SetupStatusBar(hFrameWnd, FALSE);
149 CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_STATUSBAR, MF_BYCOMMAND|MF_CHECKED);
151 ShowWindow(hFrameWnd, nCmdShow);
152 UpdateWindow(hFrameWnd);
156 /******************************************************************************/
158 static void ExitInstance(void)
160 DestroyMenu(hMenuFrame);
163 static BOOL TranslateChildTabMessage(MSG *msg)
165 if (msg->message != WM_KEYDOWN) return FALSE;
166 if (msg->wParam != VK_TAB) return FALSE;
167 if (GetParent(msg->hwnd) != g_pChildWnd->hWnd) return FALSE;
168 PostMessage(g_pChildWnd->hWnd, WM_COMMAND, ID_SWITCH_PANELS, 0);
172 int APIENTRY WinMain(HINSTANCE hInstance,
173 HINSTANCE hPrevInstance,
180 if (ProcessCmdLine(lpCmdLine)) {
184 /* Initialize global strings */
185 LoadString(hInstance, IDS_APP_TITLE, szTitle, COUNT_OF(szTitle));
186 LoadString(hInstance, IDS_REGISTRY_DEFAULT_VALUE, g_pszDefaultValueName, COUNT_OF(g_pszDefaultValueName));
187 LoadStringW(hInstance, IDS_REGISTRY_DEFAULT_VALUE, g_pszDefaultValueNameW, COUNT_OF(g_pszDefaultValueNameW));
189 /* Store instance handle in our global variable */
192 /* Perform application initialization */
193 if (!InitInstance(hInstance, nCmdShow)) {
196 hAccel = LoadAccelerators(hInstance, (LPCTSTR)IDC_REGEDIT);
198 /* Main message loop */
199 while (GetMessage(&msg, NULL, 0, 0)) {
200 if (!TranslateAccelerator(hFrameWnd, hAccel, &msg)
201 && !TranslateChildTabMessage(&msg)) {
202 TranslateMessage(&msg);
203 DispatchMessage(&msg);