2002-07-14 17:59:36 +00:00
|
|
|
/*
|
2003-08-22 05:55:14 +00:00
|
|
|
* Regedit main function
|
2002-07-14 17:59:36 +00:00
|
|
|
*
|
2003-08-22 05:55:14 +00:00
|
|
|
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
|
2002-07-14 17:59:36 +00:00
|
|
|
*
|
2002-11-12 15:25:15 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2002-07-14 17:59:36 +00:00
|
|
|
*
|
2002-11-12 15:25:15 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2002-07-14 17:59:36 +00:00
|
|
|
*
|
2002-11-12 15:25:15 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2009-10-27 10:34:16 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2002-07-14 17:59:36 +00:00
|
|
|
*/
|
|
|
|
|
2013-01-24 23:00:42 +00:00
|
|
|
#include "regedit.h"
|
2002-07-14 17:59:36 +00:00
|
|
|
|
2010-09-29 21:43:39 +00:00
|
|
|
BOOL ProcessCmdLine(LPWSTR lpCmdLine);
|
2002-08-29 18:42:38 +00:00
|
|
|
|
|
|
|
|
2003-08-22 05:55:14 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
* Global Variables:
|
|
|
|
*/
|
2002-07-14 20:38:52 +00:00
|
|
|
|
2002-07-14 17:59:36 +00:00
|
|
|
HINSTANCE hInst;
|
2002-07-14 20:38:52 +00:00
|
|
|
HWND hFrameWnd;
|
2002-07-14 17:59:36 +00:00
|
|
|
HWND hStatusBar;
|
2002-07-14 20:38:52 +00:00
|
|
|
HMENU hMenuFrame;
|
2004-01-01 17:47:48 +00:00
|
|
|
HMENU hPopupMenus = 0;
|
2003-01-07 18:06:16 +00:00
|
|
|
UINT nClipboardFormat;
|
2012-10-03 22:42:34 +00:00
|
|
|
LPCWSTR strClipboardFormat = L"TODO: SET CORRECT FORMAT";
|
2002-07-14 17:59:36 +00:00
|
|
|
|
2004-01-01 15:12:11 +00:00
|
|
|
#define MAX_LOADSTRING 100
|
2012-10-03 22:42:34 +00:00
|
|
|
WCHAR szTitle[MAX_LOADSTRING];
|
|
|
|
WCHAR szFrameClass[MAX_LOADSTRING];
|
|
|
|
WCHAR szChildClass[MAX_LOADSTRING];
|
2002-07-14 17:59:36 +00:00
|
|
|
|
|
|
|
|
2003-08-22 05:55:14 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* FUNCTION: InitInstance(HANDLE, int)
|
|
|
|
*
|
|
|
|
* PURPOSE: Saves instance handle and creates main window
|
|
|
|
*
|
|
|
|
* COMMENTS:
|
|
|
|
*
|
|
|
|
* In this function, we save the instance handle in a global variable and
|
|
|
|
* create and display the main program window.
|
|
|
|
*/
|
2002-07-14 20:38:52 +00:00
|
|
|
|
2002-07-14 17:59:36 +00:00
|
|
|
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
|
|
|
{
|
2004-07-10 23:25:17 +00:00
|
|
|
BOOL AclUiAvailable;
|
2005-10-01 15:11:31 +00:00
|
|
|
HMENU hEditMenu;
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2012-10-03 22:42:34 +00:00
|
|
|
WNDCLASSEXW wcFrame;
|
|
|
|
WNDCLASSEXW wcChild;
|
2006-07-06 16:25:42 +00:00
|
|
|
ATOM hFrameWndClass;
|
|
|
|
|
2012-10-03 22:42:34 +00:00
|
|
|
ZeroMemory(&wcFrame, sizeof(WNDCLASSEXW));
|
|
|
|
wcFrame.cbSize = sizeof(WNDCLASSEXW);
|
2006-07-06 16:25:42 +00:00
|
|
|
wcFrame.lpfnWndProc = FrameWndProc;
|
|
|
|
wcFrame.hInstance = hInstance;
|
2012-10-03 22:42:34 +00:00
|
|
|
wcFrame.hIcon = LoadIconW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT));
|
|
|
|
wcFrame.hIconSm = (HICON)LoadImageW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT),
|
|
|
|
IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),
|
|
|
|
GetSystemMetrics(SM_CYSMICON), LR_SHARED);
|
|
|
|
wcFrame.hCursor = LoadCursorW(NULL, IDC_ARROW);
|
2006-07-06 16:25:42 +00:00
|
|
|
wcFrame.lpszClassName = szFrameClass;
|
|
|
|
|
2012-10-03 22:42:34 +00:00
|
|
|
hFrameWndClass = RegisterClassExW(&wcFrame); /* register frame window class */
|
2006-07-06 16:25:42 +00:00
|
|
|
|
2012-10-03 22:42:34 +00:00
|
|
|
ZeroMemory(&wcChild, sizeof(WNDCLASSEXW));
|
|
|
|
wcChild.cbSize = sizeof(WNDCLASSEXW);
|
2006-07-06 16:25:42 +00:00
|
|
|
wcChild.lpfnWndProc = ChildWndProc;
|
|
|
|
wcChild.cbWndExtra = sizeof(HANDLE);
|
|
|
|
wcChild.hInstance = hInstance;
|
2012-10-03 22:42:34 +00:00
|
|
|
wcChild.hIcon = LoadIconW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT));
|
|
|
|
wcChild.hCursor = LoadCursorW(NULL, IDC_ARROW);
|
2012-07-12 19:10:48 +00:00
|
|
|
wcChild.lpszClassName = szChildClass;
|
2012-10-03 22:42:34 +00:00
|
|
|
wcChild.hIconSm = (HICON)LoadImageW(hInstance, MAKEINTRESOURCEW(IDI_REGEDIT),
|
|
|
|
IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),
|
|
|
|
GetSystemMetrics(SM_CYSMICON), LR_SHARED);
|
2006-07-06 16:25:42 +00:00
|
|
|
|
2012-10-03 22:42:34 +00:00
|
|
|
RegisterClassExW(&wcChild); /* register child windows class */
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2004-06-20 12:21:47 +00:00
|
|
|
RegisterHexEditorClass(hInstance);
|
2002-07-14 20:38:52 +00:00
|
|
|
|
2012-10-03 22:42:34 +00:00
|
|
|
hMenuFrame = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDR_REGEDIT_MENU));
|
|
|
|
hPopupMenus = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDR_POPUP_MENUS));
|
2002-07-14 17:59:36 +00:00
|
|
|
|
2003-08-22 05:55:14 +00:00
|
|
|
/* Initialize the Windows Common Controls DLL */
|
2012-10-03 22:42:34 +00:00
|
|
|
// TODO: Replace this call by InitCommonControlsEx(_something_)
|
2002-07-14 17:59:36 +00:00
|
|
|
InitCommonControls();
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2005-09-29 03:33:28 +00:00
|
|
|
hEditMenu = GetSubMenu(hMenuFrame, 1);
|
|
|
|
|
2004-07-10 23:25:17 +00:00
|
|
|
AclUiAvailable = InitializeAclUiDll();
|
|
|
|
if(!AclUiAvailable)
|
|
|
|
{
|
2010-12-07 21:49:25 +00:00
|
|
|
/* hide the Edit/Permissions... menu entry */
|
|
|
|
if(hEditMenu != NULL)
|
|
|
|
{
|
|
|
|
RemoveMenu(hEditMenu, ID_EDIT_PERMISSIONS, MF_BYCOMMAND);
|
|
|
|
/* remove the separator after the menu item */
|
|
|
|
RemoveMenu(hEditMenu, 4, MF_BYPOSITION);
|
|
|
|
}
|
2004-07-10 23:25:17 +00:00
|
|
|
}
|
2002-07-14 17:59:36 +00:00
|
|
|
|
2005-09-29 03:33:28 +00:00
|
|
|
if(hEditMenu != NULL)
|
|
|
|
SetMenuDefaultItem(hEditMenu, ID_EDIT_MODIFY, MF_BYCOMMAND);
|
|
|
|
|
2012-10-03 22:42:34 +00:00
|
|
|
nClipboardFormat = RegisterClipboardFormatW(strClipboardFormat);
|
2003-08-22 05:55:14 +00:00
|
|
|
/* if (nClipboardFormat == 0) {
|
2003-01-07 18:06:16 +00:00
|
|
|
DWORD dwError = GetLastError();
|
2003-08-22 05:55:14 +00:00
|
|
|
} */
|
2003-01-07 18:06:16 +00:00
|
|
|
|
2012-10-03 22:42:34 +00:00
|
|
|
hFrameWnd = CreateWindowExW(WS_EX_WINDOWEDGE, (LPCWSTR)(UlongToPtr(hFrameWndClass)), szTitle,
|
|
|
|
WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
NULL, hMenuFrame, hInstance, NULL/*lpParam*/);
|
2002-07-14 20:38:52 +00:00
|
|
|
|
2010-12-07 21:49:25 +00:00
|
|
|
if (!hFrameWnd)
|
|
|
|
{
|
2002-07-14 17:59:36 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-08-22 05:55:14 +00:00
|
|
|
/* Create the status bar */
|
2012-10-03 22:42:34 +00:00
|
|
|
hStatusBar = CreateStatusWindowW(WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | SBT_NOBORDERS,
|
|
|
|
L"", hFrameWnd, STATUS_WINDOW);
|
2010-12-07 21:49:25 +00:00
|
|
|
if (hStatusBar)
|
|
|
|
{
|
2003-08-22 05:55:14 +00:00
|
|
|
/* Create the status bar panes */
|
2002-07-18 18:16:42 +00:00
|
|
|
SetupStatusBar(hFrameWnd, FALSE);
|
2012-10-03 22:42:34 +00:00
|
|
|
CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_STATUSBAR, MF_BYCOMMAND | MF_CHECKED);
|
2002-07-14 20:38:52 +00:00
|
|
|
}
|
2005-10-05 13:25:14 +00:00
|
|
|
|
2012-03-28 08:23:15 +00:00
|
|
|
LoadSettings();
|
2002-07-14 20:38:52 +00:00
|
|
|
UpdateWindow(hFrameWnd);
|
2002-07-14 17:59:36 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-08-22 05:55:14 +00:00
|
|
|
/******************************************************************************/
|
2002-07-14 17:59:36 +00:00
|
|
|
|
2012-10-03 22:42:34 +00:00
|
|
|
/*
|
|
|
|
* We need to destroy the main menu before destroying the main window
|
|
|
|
* to avoid a memory leak.
|
|
|
|
*/
|
2005-10-28 00:14:27 +00:00
|
|
|
|
2010-12-07 21:49:25 +00:00
|
|
|
void DestroyMainMenu()
|
|
|
|
{
|
|
|
|
DestroyMenu(hMenuFrame);
|
2005-10-28 00:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
2004-06-20 12:21:47 +00:00
|
|
|
void ExitInstance(HINSTANCE hInstance)
|
2002-07-14 17:59:36 +00:00
|
|
|
{
|
2004-06-20 12:21:47 +00:00
|
|
|
UnregisterHexEditorClass(hInstance);
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2005-09-26 16:07:23 +00:00
|
|
|
DestroyMenu(hPopupMenus);
|
2004-07-10 23:25:17 +00:00
|
|
|
UnloadAclUiDll();
|
2002-07-14 17:59:36 +00:00
|
|
|
}
|
|
|
|
|
2012-10-03 22:42:34 +00:00
|
|
|
BOOL TranslateChildTabMessage(PMSG msg)
|
2004-06-21 10:24:52 +00:00
|
|
|
{
|
2010-12-07 21:49:25 +00:00
|
|
|
if (msg->message != WM_KEYDOWN) return FALSE;
|
2012-03-28 08:06:21 +00:00
|
|
|
|
|
|
|
/* Allow Ctrl+A on address bar */
|
|
|
|
if ((msg->hwnd == g_pChildWnd->hAddressBarWnd) &&
|
|
|
|
(msg->message == WM_KEYDOWN) &&
|
2012-10-03 22:42:34 +00:00
|
|
|
(msg->wParam == L'A') && (GetKeyState(VK_CONTROL) < 0))
|
2012-03-28 08:06:21 +00:00
|
|
|
{
|
2012-10-03 22:42:34 +00:00
|
|
|
SendMessageW(msg->hwnd, EM_SETSEL, 0, -1);
|
2012-03-28 08:06:21 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-12-07 21:49:25 +00:00
|
|
|
if (msg->wParam != VK_TAB) return FALSE;
|
|
|
|
if (GetParent(msg->hwnd) != g_pChildWnd->hWnd) return FALSE;
|
2012-10-03 22:42:34 +00:00
|
|
|
PostMessageW(g_pChildWnd->hWnd, WM_COMMAND, ID_SWITCH_PANELS, 0);
|
2010-12-07 21:49:25 +00:00
|
|
|
return TRUE;
|
2004-06-21 10:24:52 +00:00
|
|
|
}
|
|
|
|
|
2010-09-29 21:43:39 +00:00
|
|
|
int APIENTRY wWinMain(HINSTANCE hInstance,
|
|
|
|
HINSTANCE hPrevInstance,
|
|
|
|
LPWSTR lpCmdLine,
|
|
|
|
int nCmdShow)
|
2002-07-14 17:59:36 +00:00
|
|
|
{
|
|
|
|
MSG msg;
|
|
|
|
HACCEL hAccel;
|
2005-09-30 23:32:24 +00:00
|
|
|
|
2006-07-06 16:25:42 +00:00
|
|
|
UNREFERENCED_PARAMETER(hPrevInstance);
|
|
|
|
|
2010-12-07 21:49:25 +00:00
|
|
|
if (ProcessCmdLine(lpCmdLine))
|
|
|
|
{
|
2003-08-22 05:55:14 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize global strings */
|
2012-10-03 22:42:34 +00:00
|
|
|
LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
|
|
|
|
LoadStringW(hInstance, IDC_REGEDIT_FRAME, szFrameClass, MAX_LOADSTRING);
|
|
|
|
LoadStringW(hInstance, IDC_REGEDIT, szChildClass, MAX_LOADSTRING);
|
2003-08-22 05:55:14 +00:00
|
|
|
|
2013-06-16 22:04:48 +00:00
|
|
|
|
|
|
|
switch (GetUserDefaultUILanguage())
|
|
|
|
{
|
|
|
|
case MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT):
|
|
|
|
SetProcessDefaultLayout(LAYOUT_RTL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2003-08-22 05:55:14 +00:00
|
|
|
/* Store instance handle in our global variable */
|
2002-07-14 17:59:36 +00:00
|
|
|
hInst = hInstance;
|
|
|
|
|
2003-08-22 05:55:14 +00:00
|
|
|
/* Perform application initialization */
|
2010-12-07 21:49:25 +00:00
|
|
|
if (!InitInstance(hInstance, nCmdShow))
|
|
|
|
{
|
2012-11-28 11:20:13 +00:00
|
|
|
return 0;
|
2002-07-14 17:59:36 +00:00
|
|
|
}
|
2012-10-03 22:42:34 +00:00
|
|
|
hAccel = LoadAcceleratorsW(hInstance, MAKEINTRESOURCEW(ID_ACCEL));
|
2002-07-14 17:59:36 +00:00
|
|
|
|
2003-08-22 05:55:14 +00:00
|
|
|
/* Main message loop */
|
2012-10-03 22:42:34 +00:00
|
|
|
while (GetMessageW(&msg, NULL, 0, 0))
|
2010-12-07 21:49:25 +00:00
|
|
|
{
|
2012-10-03 22:42:34 +00:00
|
|
|
if (!TranslateAcceleratorW(hFrameWnd, hAccel, &msg) &&
|
|
|
|
!TranslateChildTabMessage(&msg))
|
2010-12-07 21:49:25 +00:00
|
|
|
{
|
2002-07-14 17:59:36 +00:00
|
|
|
TranslateMessage(&msg);
|
2012-10-03 22:42:34 +00:00
|
|
|
DispatchMessageW(&msg);
|
2002-07-14 17:59:36 +00:00
|
|
|
}
|
|
|
|
}
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2004-06-20 12:21:47 +00:00
|
|
|
ExitInstance(hInstance);
|
2012-10-03 22:42:34 +00:00
|
|
|
return (int)msg.wParam;
|
2002-07-14 17:59:36 +00:00
|
|
|
}
|
2012-10-03 22:42:34 +00:00
|
|
|
|
|
|
|
/* EOF */
|