ReactOS 0.4.15-dev-5667-ged97270
main.c
Go to the documentation of this file.
1/*
2 * Regedit main function
3 *
4 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
5 *
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.
10 *
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.
15 *
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 Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include "regedit.h"
22
24
25const WCHAR *reg_class_namesW[] = {L"HKEY_LOCAL_MACHINE", L"HKEY_USERS",
26 L"HKEY_CLASSES_ROOT", L"HKEY_CURRENT_CONFIG",
27 L"HKEY_CURRENT_USER", L"HKEY_DYN_DATA"
28 };
29
30/*******************************************************************************
31 * Global Variables:
32 */
33
40LPCWSTR strClipboardFormat = L"TODO: SET CORRECT FORMAT";
41
42#define MAX_LOADSTRING 100
46
47
48/*******************************************************************************
49 *
50 *
51 * FUNCTION: InitInstance(HANDLE, int)
52 *
53 * PURPOSE: Saves instance handle and creates main window
54 *
55 * COMMENTS:
56 *
57 * In this function, we save the instance handle in a global variable and
58 * create and display the main program window.
59 */
60
62{
63 BOOL AclUiAvailable;
64 HMENU hEditMenu;
66 WNDCLASSEXW wcFrame;
67 WNDCLASSEXW wcChild;
68 ATOM hFrameWndClass;
69
70 ZeroMemory(&wcFrame, sizeof(WNDCLASSEXW));
71 wcFrame.cbSize = sizeof(WNDCLASSEXW);
72 wcFrame.lpfnWndProc = FrameWndProc;
73 wcFrame.hInstance = hInstance;
79 wcFrame.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
81
82 hFrameWndClass = RegisterClassExW(&wcFrame); /* register frame window class */
83
84 ZeroMemory(&wcChild, sizeof(WNDCLASSEXW));
85 wcChild.cbSize = sizeof(WNDCLASSEXW);
86 wcChild.lpfnWndProc = ChildWndProc;
87 wcChild.cbWndExtra = sizeof(HANDLE);
88 wcChild.hInstance = hInstance;
91 wcChild.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
96
97 RegisterClassExW(&wcChild); /* register child windows class */
98
100
103
104 /* Initialize the Windows Common Controls DLL */
105 /* NOTE: Windows sets 0xFFFF to icce.dwICC but we use better value. */
106 icce.dwSize = sizeof(icce);
109
110 hEditMenu = GetSubMenu(hMenuFrame, 1);
111
112 AclUiAvailable = InitializeAclUiDll();
113 if(!AclUiAvailable)
114 {
115 /* hide the Edit/Permissions... menu entry */
116 if(hEditMenu != NULL)
117 {
119 /* remove the separator after the menu item */
120 RemoveMenu(hEditMenu, 4, MF_BYPOSITION);
121 }
122 }
123
124 if(hEditMenu != NULL)
126
128 /* if (nClipboardFormat == 0) {
129 DWORD dwError = GetLastError();
130 } */
131
135 NULL, hMenuFrame, hInstance, NULL/*lpParam*/);
136
137 if (!hFrameWnd)
138 {
139 return FALSE;
140 }
141
142 /* Create the status bar */
145 if (hStatusBar)
146 {
147 /* Create the status bar panes */
150 }
151
152 LoadSettings();
154 return TRUE;
155}
156
157/******************************************************************************/
158
159/*
160 * We need to destroy the main menu before destroying the main window
161 * to avoid a memory leak.
162 */
163
165{
167}
168
169/******************************************************************************/
170
172{
174
177}
178
180{
181 if (msg->message != WM_KEYDOWN) return FALSE;
182
183 /* Allow Ctrl+A on address bar */
184 if ((msg->hwnd == g_pChildWnd->hAddressBarWnd) &&
185 (msg->message == WM_KEYDOWN) &&
186 (msg->wParam == L'A') && (GetKeyState(VK_CONTROL) < 0))
187 {
188 SendMessageW(msg->hwnd, EM_SETSEL, 0, -1);
189 return TRUE;
190 }
191
192 if (msg->wParam != VK_TAB) return FALSE;
193 if (GetParent(msg->hwnd) != g_pChildWnd->hWnd) return FALSE;
195 return TRUE;
196}
197
199 HINSTANCE hPrevInstance,
200 LPWSTR lpCmdLine,
201 int nCmdShow)
202{
203 MSG msg;
204 HACCEL hAccel;
205
206 UNREFERENCED_PARAMETER(hPrevInstance);
207
208 /* Initialize global strings */
212
214 {
215 return 0;
216 }
217
218 switch (GetUserDefaultUILanguage())
219 {
222 break;
223
224 default:
225 break;
226 }
227 /* Store instance handle in our global variable */
229
230 /* Perform application initialization */
231 if (!InitInstance(hInstance, nCmdShow))
232 {
233 return 0;
234 }
236
237 /* Main message loop */
238 while (GetMessageW(&msg, NULL, 0, 0))
239 {
242 {
245 }
246 }
247
249 return (int)msg.wParam;
250}
251
252/* EOF */
#define msg(x)
Definition: auth_time.c:54
void LoadSettings(void)
Definition: settings.c:53
#define ID_ACCEL
Definition: resources.h:13
int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPWSTR cmdline, int cmdshow)
Definition: main.c:419
#define IDS_APP_TITLE
Definition: resource.h:10
#define ARRAY_SIZE(a)
Definition: main.h:24
LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: childwnd.c:301
ChildWnd * g_pChildWnd
Definition: childwnd.c:23
void SetupStatusBar(HWND hWnd, BOOL bResize)
Definition: framewnd.c:161
LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: framewnd.c:1352
#define MAX_LOADSTRING
Definition: main.c:42
HMENU hPopupMenus
Definition: main.c:38
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
Definition: main.c:61
const WCHAR * reg_class_namesW[]
Definition: main.c:25
HWND hFrameWnd
Definition: main.c:35
UINT nClipboardFormat
Definition: main.c:39
BOOL TranslateChildTabMessage(PMSG msg)
Definition: main.c:179
void DestroyMainMenu()
Definition: main.c:164
WCHAR szFrameClass[MAX_LOADSTRING]
Definition: main.c:44
HMENU hMenuFrame
Definition: main.c:37
LPCWSTR strClipboardFormat
Definition: main.c:40
BOOL ProcessCmdLine(WCHAR *cmdline)
Definition: regedit.c:188
WCHAR szTitle[MAX_LOADSTRING]
Definition: main.c:43
WCHAR szChildClass[MAX_LOADSTRING]
Definition: main.c:45
HWND hStatusBar
Definition: main.c:36
#define STATUS_WINDOW
Definition: main.h:26
#define IDI_REGEDIT
Definition: resource.h:35
#define IDC_REGEDIT
Definition: resource.h:39
#define IDR_REGEDIT_MENU
Definition: resource.h:41
#define ID_EDIT_MODIFY
Definition: resource.h:62
#define ID_VIEW_STATUSBAR
Definition: resource.h:54
#define IDR_POPUP_MENUS
Definition: resource.h:45
#define IDC_REGEDIT_FRAME
Definition: resource.h:40
#define ID_SWITCH_PANELS
Definition: resource.h:149
#define ID_VIEW_MENU
Definition: resource.h:25
#define ID_EDIT_PERMISSIONS
Definition: resource.h:150
BOOL InitializeAclUiDll(VOID)
Definition: security.c:811
VOID UnloadAclUiDll(VOID)
Definition: security.c:830
HINSTANCE hInstance
Definition: charmap.c:19
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:893
HWND WINAPI CreateStatusWindowW(LONG style, LPCWSTR text, HWND parent, UINT wid)
Definition: commctrl.c:795
WORD ATOM
Definition: dimm.idl:113
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LPWSTR WINAPI GetCommandLineW(VOID)
Definition: proc.c:2013
#define UlongToPtr(u)
Definition: config.h:106
HINSTANCE hInst
Definition: dxdiag.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
ATOM WINAPI RegisterHexEditorClass(HINSTANCE hInstance)
Definition: hexedit.c:69
BOOL WINAPI UnregisterHexEditorClass(HINSTANCE hInstance)
Definition: hexedit.c:90
LANGID WINAPI GetUserDefaultUILanguage(void)
Definition: lang.c:810
void ExitInstance(void)
Definition: main.c:213
HACCEL hAccel
Definition: main.c:47
static HICON
Definition: imagelist.c:84
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
unsigned int UINT
Definition: ndis.h:50
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define L(x)
Definition: ntvdm.h:50
#define WS_CHILD
Definition: pedump.c:617
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_VISIBLE
Definition: pedump.c:620
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define WS_CLIPCHILDREN
Definition: pedump.c:619
#define ICC_USEREX_CLASSES
Definition: commctrl.h:68
#define SBT_NOBORDERS
Definition: commctrl.h:1971
#define ICC_STANDARD_CLASSES
Definition: commctrl.h:73
#define ICC_WIN95_CLASSES
Definition: commctrl.h:66
#define MAKELANGID(p, s)
Definition: nls.h:15
#define LANG_HEBREW
Definition: nls.h:67
#define SUBLANG_DEFAULT
Definition: nls.h:168
TCHAR * cmdline
Definition: stretchblt.cpp:32
HWND hAddressBarWnd
Definition: main.h:65
HWND hWnd
Definition: main.h:62
LPCWSTR lpszClassName
Definition: winuser.h:3216
HBRUSH hbrBackground
Definition: winuser.h:3214
WNDPROC lpfnWndProc
Definition: winuser.h:3208
UINT cbSize
Definition: winuser.h:3206
int cbWndExtra
Definition: winuser.h:3210
HCURSOR hCursor
Definition: winuser.h:3213
HICON hIconSm
Definition: winuser.h:3217
HINSTANCE hInstance
Definition: winuser.h:3211
HICON hIcon
Definition: winuser.h:3212
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
PVOID HANDLE
Definition: typedefs.h:73
BOOL WINAPI SetProcessDefaultLayout(DWORD dwDefaultLayout)
Definition: window.c:1720
#define ZeroMemory
Definition: winbase.h:1670
#define WINAPI
Definition: msvc.h:6
#define LAYOUT_RTL
Definition: wingdi.h:1371
#define MF_BYCOMMAND
Definition: winuser.h:202
#define VK_TAB
Definition: winuser.h:2189
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI SetMenuDefaultItem(_In_ HMENU, _In_ UINT, _In_ UINT)
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IMAGE_ICON
Definition: winuser.h:212
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define WM_COMMAND
Definition: winuser.h:1730
#define IDC_ARROW
Definition: winuser.h:682
#define VK_CONTROL
Definition: winuser.h:2193
UINT WINAPI RegisterClipboardFormatW(_In_ LPCWSTR)
#define SM_CYSMICON
Definition: winuser.h:1007
#define MF_CHECKED
Definition: winuser.h:132
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define SM_CXSMICON
Definition: winuser.h:1006
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define MF_BYPOSITION
Definition: winuser.h:203
BOOL WINAPI RemoveMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
BOOL WINAPI UpdateWindow(_In_ HWND)
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
#define EM_SETSEL
Definition: winuser.h:2008
#define LR_SHARED
Definition: winuser.h:1094
#define CW_USEDEFAULT
Definition: winuser.h:225
HWND WINAPI GetParent(_In_ HWND)
HACCEL WINAPI LoadAcceleratorsW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
BOOL WINAPI DestroyMenu(_In_ HMENU)
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
int WINAPI TranslateAcceleratorW(_In_ HWND, _In_ HACCEL, _In_ LPMSG)
struct _WNDCLASSEXW WNDCLASSEXW
#define WM_KEYDOWN
Definition: winuser.h:1705
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HMENU WINAPI LoadMenuW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
int WINAPI GetSystemMetrics(_In_ int)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
SHORT WINAPI GetKeyState(_In_ int)
#define COLOR_3DFACE
Definition: winuser.h:923
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185