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 WCHAR g_pszDefaultValueName
[64];
34 BOOL
ProcessCmdLine(LPSTR lpCmdLine
);
36 static const WCHAR hkey_local_machine
[] = {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0};
37 static const WCHAR hkey_users
[] = {'H','K','E','Y','_','U','S','E','R','S',0};
38 static const WCHAR hkey_classes_root
[] = {'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0};
39 static const WCHAR hkey_current_config
[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0};
40 static const WCHAR hkey_current_user
[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0};
41 static const WCHAR hkey_dyn_data
[] = {'H','K','E','Y','_','D','Y','N','_','D','A','T','A',0};
43 const WCHAR
*reg_class_namesW
[] = {hkey_local_machine
, hkey_users
,
44 hkey_classes_root
, hkey_current_config
,
45 hkey_current_user
, hkey_dyn_data
48 /*******************************************************************************
56 HMENU hPopupMenus
= 0;
57 UINT nClipboardFormat
;
58 LPCTSTR strClipboardFormat
= _T("TODO: SET CORRECT FORMAT");
61 #define MAX_LOADSTRING 100
62 TCHAR szTitle
[MAX_LOADSTRING
];
63 const TCHAR szFrameClass
[] = {'R','E','G','E','D','I','T','_','F','R','A','M','E',0};
64 const TCHAR szChildClass
[] = {'R','E','G','E','D','I','T',0};
67 /*******************************************************************************
70 * FUNCTION: InitInstance(HANDLE, int)
72 * PURPOSE: Saves instance handle and creates main window
76 * In this function, we save the instance handle in a global variable and
77 * create and display the main program window.
80 static BOOL
InitInstance(HINSTANCE hInstance
, int nCmdShow
)
83 WNDCLASSEX wcFrame
= {
85 CS_HREDRAW
| CS_VREDRAW
/*style*/,
90 LoadIcon(hInstance
, MAKEINTRESOURCE(IDI_REGEDIT
)),
91 LoadCursor(0, IDC_ARROW
),
95 LoadImage(hInstance
, MAKEINTRESOURCE(IDI_REGEDIT
), IMAGE_ICON
,
96 GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
), LR_SHARED
)
98 ATOM hFrameWndClass
= RegisterClassEx(&wcFrame
); /* register frame window class */
100 WNDCLASSEX wcChild
= {
102 CS_HREDRAW
| CS_VREDRAW
/*style*/,
105 sizeof(HANDLE
)/*cbWndExtra*/,
107 LoadIcon(hInstance
, MAKEINTRESOURCE(IDI_REGEDIT
)),
108 LoadCursor(0, IDC_ARROW
),
112 LoadImage(hInstance
, MAKEINTRESOURCE(IDI_REGEDIT
), IMAGE_ICON
,
113 GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
), LR_SHARED
)
116 ATOM hChildWndClass
= RegisterClassEx(&wcChild
); /* register child windows class */
117 hChildWndClass
= hChildWndClass
; /* warning eater */
119 hMenuFrame
= LoadMenuW(hInstance
, MAKEINTRESOURCEW(IDR_REGEDIT_MENU
));
120 hPopupMenus
= LoadMenuW(hInstance
, MAKEINTRESOURCEW(IDR_POPUP_MENUS
));
122 /* Initialize the Windows Common Controls DLL */
123 InitCommonControls();
125 /* register our hex editor control */
128 nClipboardFormat
= RegisterClipboardFormat(strClipboardFormat
);
129 /* if (nClipboardFormat == 0) {
130 DWORD dwError = GetLastError();
133 hFrameWnd
= CreateWindowEx(0, MAKEINTRESOURCE(hFrameWndClass
), szTitle
,
134 WS_OVERLAPPEDWINDOW
| WS_EX_CLIENTEDGE
,
135 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
136 NULL
, hMenuFrame
, hInstance
, NULL
/*lpParam*/);
142 /* Create the status bar */
143 hStatusBar
= CreateStatusWindowW(WS_VISIBLE
|WS_CHILD
|WS_CLIPSIBLINGS
|SBT_NOBORDERS
,
144 &empty
, hFrameWnd
, STATUS_WINDOW
);
146 /* Create the status bar panes */
147 SetupStatusBar(hFrameWnd
, FALSE
);
148 CheckMenuItem(GetSubMenu(hMenuFrame
, ID_VIEW_MENU
), ID_VIEW_STATUSBAR
, MF_BYCOMMAND
|MF_CHECKED
);
150 ShowWindow(hFrameWnd
, nCmdShow
);
151 UpdateWindow(hFrameWnd
);
155 /******************************************************************************/
157 static void ExitInstance(void)
159 DestroyMenu(hMenuFrame
);
162 static BOOL
TranslateChildTabMessage(MSG
*msg
)
164 if (msg
->message
!= WM_KEYDOWN
) return FALSE
;
165 if (msg
->wParam
!= VK_TAB
) return FALSE
;
166 if (GetParent(msg
->hwnd
) != g_pChildWnd
->hWnd
) return FALSE
;
167 PostMessage(g_pChildWnd
->hWnd
, WM_COMMAND
, ID_SWITCH_PANELS
, 0);
171 int APIENTRY
WinMain(HINSTANCE hInstance
,
172 HINSTANCE hPrevInstance
,
179 if (ProcessCmdLine(lpCmdLine
)) {
183 /* Initialize global strings */
184 LoadString(hInstance
, IDS_APP_TITLE
, szTitle
, COUNT_OF(szTitle
));
185 LoadStringW(hInstance
, IDS_REGISTRY_DEFAULT_VALUE
, g_pszDefaultValueName
, COUNT_OF(g_pszDefaultValueName
));
187 /* Store instance handle in our global variable */
190 /* Perform application initialization */
191 if (!InitInstance(hInstance
, nCmdShow
)) {
194 hAccel
= LoadAccelerators(hInstance
, (LPCTSTR
)IDC_REGEDIT
);
196 /* Main message loop */
197 while (GetMessage(&msg
, NULL
, 0, 0)) {
198 if (!TranslateAccelerator(hFrameWnd
, hAccel
, &msg
)
199 && !TranslateChildTabMessage(&msg
)) {
200 TranslateMessage(&msg
);
201 DispatchMessage(&msg
);