ReactOS  0.4.14-dev-614-gbfd8a84
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 
23 BOOL ProcessCmdLine(LPWSTR lpCmdLine);
24 
25 /*******************************************************************************
26  * Global Variables:
27  */
28 
35 LPCWSTR strClipboardFormat = L"TODO: SET CORRECT FORMAT";
36 
37 #define MAX_LOADSTRING 100
41 
42 
43 /*******************************************************************************
44  *
45  *
46  * FUNCTION: InitInstance(HANDLE, int)
47  *
48  * PURPOSE: Saves instance handle and creates main window
49  *
50  * COMMENTS:
51  *
52  * In this function, we save the instance handle in a global variable and
53  * create and display the main program window.
54  */
55 
57 {
58  BOOL AclUiAvailable;
59  HMENU hEditMenu;
60 
61  WNDCLASSEXW wcFrame;
62  WNDCLASSEXW wcChild;
63  ATOM hFrameWndClass;
64 
65  ZeroMemory(&wcFrame, sizeof(WNDCLASSEXW));
66  wcFrame.cbSize = sizeof(WNDCLASSEXW);
67  wcFrame.lpfnWndProc = FrameWndProc;
68  wcFrame.hInstance = hInstance;
73  wcFrame.hCursor = LoadCursorW(NULL, IDC_ARROW);
74  wcFrame.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
75  wcFrame.lpszClassName = szFrameClass;
76 
77  hFrameWndClass = RegisterClassExW(&wcFrame); /* register frame window class */
78 
79  ZeroMemory(&wcChild, sizeof(WNDCLASSEXW));
80  wcChild.cbSize = sizeof(WNDCLASSEXW);
81  wcChild.lpfnWndProc = ChildWndProc;
82  wcChild.cbWndExtra = sizeof(HANDLE);
83  wcChild.hInstance = hInstance;
85  wcChild.hCursor = LoadCursorW(NULL, IDC_ARROW);
86  wcChild.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
87  wcChild.lpszClassName = szChildClass;
91 
92  RegisterClassExW(&wcChild); /* register child windows class */
93 
95 
98 
99  /* Initialize the Windows Common Controls DLL */
100  // TODO: Replace this call by InitCommonControlsEx(_something_)
102 
103  hEditMenu = GetSubMenu(hMenuFrame, 1);
104 
105  AclUiAvailable = InitializeAclUiDll();
106  if(!AclUiAvailable)
107  {
108  /* hide the Edit/Permissions... menu entry */
109  if(hEditMenu != NULL)
110  {
112  /* remove the separator after the menu item */
113  RemoveMenu(hEditMenu, 4, MF_BYPOSITION);
114  }
115  }
116 
117  if(hEditMenu != NULL)
119 
121  /* if (nClipboardFormat == 0) {
122  DWORD dwError = GetLastError();
123  } */
124 
128  NULL, hMenuFrame, hInstance, NULL/*lpParam*/);
129 
130  if (!hFrameWnd)
131  {
132  return FALSE;
133  }
134 
135  /* Create the status bar */
138  if (hStatusBar)
139  {
140  /* Create the status bar panes */
143  }
144 
145  LoadSettings();
147  return TRUE;
148 }
149 
150 /******************************************************************************/
151 
152 /*
153  * We need to destroy the main menu before destroying the main window
154  * to avoid a memory leak.
155  */
156 
158 {
160 }
161 
162 /******************************************************************************/
163 
165 {
167 
169  UnloadAclUiDll();
170 }
171 
173 {
174  if (msg->message != WM_KEYDOWN) return FALSE;
175 
176  /* Allow Ctrl+A on address bar */
177  if ((msg->hwnd == g_pChildWnd->hAddressBarWnd) &&
178  (msg->message == WM_KEYDOWN) &&
179  (msg->wParam == L'A') && (GetKeyState(VK_CONTROL) < 0))
180  {
181  SendMessageW(msg->hwnd, EM_SETSEL, 0, -1);
182  return TRUE;
183  }
184 
185  if (msg->wParam != VK_TAB) return FALSE;
186  if (GetParent(msg->hwnd) != g_pChildWnd->hWnd) return FALSE;
188  return TRUE;
189 }
190 
192  HINSTANCE hPrevInstance,
193  LPWSTR lpCmdLine,
194  int nCmdShow)
195 {
196  MSG msg;
197  HACCEL hAccel;
198 
199  UNREFERENCED_PARAMETER(hPrevInstance);
200 
201  /* Initialize global strings */
205 
206  if (ProcessCmdLine(lpCmdLine))
207  {
208  return 0;
209  }
210 
211  switch (GetUserDefaultUILanguage())
212  {
215  break;
216 
217  default:
218  break;
219  }
220  /* Store instance handle in our global variable */
221  hInst = hInstance;
222 
223  /* Perform application initialization */
224  if (!InitInstance(hInstance, nCmdShow))
225  {
226  return 0;
227  }
229 
230  /* Main message loop */
231  while (GetMessageW(&msg, NULL, 0, 0))
232  {
235  {
238  }
239  }
240 
242  return (int)msg.wParam;
243 }
244 
245 /* EOF */
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define ID_SWITCH_PANELS
Definition: resource.h:152
LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: childwnd.c:385
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
#define MAX_LOADSTRING
Definition: main.c:37
LANGID WINAPI GetUserDefaultUILanguage(void)
Definition: lang.c:806
BOOL WINAPI TranslateMessage(_In_ const MSG *)
static HICON
Definition: imagelist.c:84
#define IDI_REGEDIT
Definition: resource.h:35
void SetupStatusBar(HWND hWnd, BOOL bResize)
Definition: framewnd.c:167
#define TRUE
Definition: types.h:120
#define LR_SHARED
Definition: winuser.h:1090
void ExitInstance(HINSTANCE hInstance)
Definition: main.c:164
#define IMAGE_ICON
Definition: winuser.h:212
ChildWnd * g_pChildWnd
Definition: childwnd.c:23
#define MF_BYCOMMAND
Definition: winuser.h:202
int cbWndExtra
Definition: winuser.h:3195
#define LAYOUT_RTL
Definition: wingdi.h:1370
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
WORD ATOM
Definition: dimm.idl:113
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
UINT WINAPI RegisterClipboardFormatW(_In_ LPCWSTR)
BOOL InitializeAclUiDll(VOID)
Definition: security.c:811
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define SUBLANG_DEFAULT
Definition: nls.h:168
WCHAR szTitle[MAX_LOADSTRING]
Definition: main.c:38
BOOL WINAPI UpdateWindow(_In_ HWND)
BOOL WINAPI UnregisterHexEditorClass(HINSTANCE hInstance)
Definition: hexedit.c:90
#define ZeroMemory
Definition: winbase.h:1642
#define SM_CYSMICON
Definition: winuser.h:1003
HICON hIcon
Definition: winuser.h:3197
#define VK_TAB
Definition: winuser.h:2174
#define WS_CHILD
Definition: pedump.c:617
struct _WNDCLASSEXW WNDCLASSEXW
#define WS_CLIPCHILDREN
Definition: pedump.c:619
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define LANG_HEBREW
Definition: nls.h:67
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
HINSTANCE hInst
Definition: main.c:29
#define ID_VIEW_STATUSBAR
Definition: resource.h:57
#define COLOR_3DFACE
Definition: winuser.h:919
void LoadSettings(void)
Definition: settings.c:53
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
HACCEL hAccel
Definition: main.c:47
unsigned int BOOL
Definition: ntddk_ex.h:94
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2172
#define MF_BYPOSITION
Definition: winuser.h:203
HWND WINAPI CreateStatusWindowW(LONG style, LPCWSTR text, HWND parent, UINT wid)
Definition: commctrl.c:795
#define CW_USEDEFAULT
Definition: winuser.h:225
#define ID_EDIT_PERMISSIONS
Definition: resource.h:153
HACCEL WINAPI LoadAcceleratorsW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
smooth NULL
Definition: ftsmooth.c:416
#define WM_KEYDOWN
Definition: winuser.h:1697
static HANDLE(WINAPI *pGetProcessHandleFromHwnd)(HWND)
HWND hStatusBar
Definition: main.c:31
#define UlongToPtr(u)
Definition: config.h:106
LPCWSTR lpszClassName
Definition: winuser.h:3201
SHORT WINAPI GetKeyState(_In_ int)
BOOL WINAPI SetProcessDefaultLayout(DWORD dwDefaultLayout)
Definition: window.c:1716
#define MF_CHECKED
Definition: winuser.h:132
#define COUNT_OF(a)
Definition: main.h:33
WCHAR szFrameClass[MAX_LOADSTRING]
Definition: main.c:39
__wchar_t WCHAR
Definition: xmlstorage.h:180
HBRUSH hbrBackground
Definition: winuser.h:3199
UINT cbSize
Definition: winuser.h:3191
HMENU hPopupMenus
Definition: main.c:33
void DestroyMainMenu()
Definition: main.c:157
HWND hWnd
Definition: main.h:59
#define EM_SETSEL
Definition: winuser.h:2000
#define IDR_REGEDIT_MENU
Definition: resource.h:41
int WINAPI GetSystemMetrics(_In_ int)
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
#define IDC_REGEDIT
Definition: resource.h:39
HINSTANCE hInstance
Definition: main.c:36
#define IDC_REGEDIT_FRAME
Definition: resource.h:40
BOOL TranslateChildTabMessage(PMSG msg)
Definition: main.c:172
HINSTANCE hInstance
Definition: winuser.h:3196
#define SM_CXSMICON
Definition: winuser.h:1002
int WINAPI TranslateAcceleratorW(_In_ HWND, _In_ HACCEL, _In_ LPMSG)
static const WCHAR L[]
Definition: oid.c:1250
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 ID_VIEW_MENU
Definition: resource.h:25
WCHAR szChildClass[MAX_LOADSTRING]
Definition: main.c:40
HCURSOR hCursor
Definition: winuser.h:3198
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define WM_COMMAND
Definition: winuser.h:1722
#define STATUS_WINDOW
Definition: main.h:26
WNDPROC lpfnWndProc
Definition: winuser.h:3193
BOOL WINAPI DestroyMenu(_In_ HMENU)
ATOM WINAPI RegisterHexEditorClass(HINSTANCE hInstance)
Definition: hexedit.c:69
BOOL ProcessCmdLine(LPWSTR lpCmdLine)
Definition: regedit.c:281
#define ID_EDIT_MODIFY
Definition: resource.h:65
HWND hFrameWnd
Definition: main.c:30
HWND WINAPI GetParent(_In_ HWND)
#define IDR_POPUP_MENUS
Definition: resource.h:48
HMENU hMenuFrame
Definition: main.c:32
LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: framewnd.c:1304
BOOL WINAPI RemoveMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
unsigned int UINT
Definition: ndis.h:50
#define IDS_APP_TITLE
Definition: resource.h:10
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
BOOL WINAPI SetMenuDefaultItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define VK_CONTROL
Definition: winuser.h:2178
HICON hIconSm
Definition: winuser.h:3202
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
HWND hAddressBarWnd
Definition: main.h:62
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
Definition: main.c:56
#define ID_ACCEL
Definition: resources.h:13
HMENU WINAPI LoadMenuW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define MAKELANGID(p, s)
Definition: nls.h:15
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
int WINAPI wWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPWSTR cmdline, int cmdshow)
Definition: main.c:420
VOID WINAPI InitCommonControls(void)
Definition: commctrl.c:863
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
VOID UnloadAclUiDll(VOID)
Definition: security.c:830
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define WS_VISIBLE
Definition: pedump.c:620
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define SBT_NOBORDERS
Definition: commctrl.h:1967
UINT nClipboardFormat
Definition: main.c:34
#define APIENTRY
Definition: api.h:79
LPCWSTR strClipboardFormat
Definition: main.c:35