2002-07-14 17:59:36 +00:00
|
|
|
/*
|
|
|
|
* ReactOS regedit
|
|
|
|
*
|
|
|
|
* main.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
|
|
|
|
*
|
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
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2002-07-14 17:59:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
|
|
|
#include <windows.h>
|
|
|
|
#include <commctrl.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <tchar.h>
|
|
|
|
#include <process.h>
|
|
|
|
#include <stdio.h>
|
2002-11-13 12:08:26 +00:00
|
|
|
#include <fcntl.h>
|
2002-07-14 17:59:36 +00:00
|
|
|
|
|
|
|
#include "main.h"
|
|
|
|
#include "framewnd.h"
|
2002-07-14 20:38:52 +00:00
|
|
|
#include "childwnd.h"
|
2002-07-14 17:59:36 +00:00
|
|
|
|
|
|
|
|
2002-08-29 18:42:38 +00:00
|
|
|
BOOL ProcessCmdLine(LPSTR lpCmdLine);
|
|
|
|
|
|
|
|
|
2002-07-14 17:59:36 +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;
|
2003-01-07 18:06:16 +00:00
|
|
|
UINT nClipboardFormat;
|
|
|
|
LPCTSTR strClipboardFormat = _T("TODO: SET CORRECT FORMAT");
|
|
|
|
|
2002-07-14 17:59:36 +00:00
|
|
|
|
|
|
|
TCHAR szTitle[MAX_LOADSTRING];
|
|
|
|
TCHAR szFrameClass[MAX_LOADSTRING];
|
2002-07-14 20:38:52 +00:00
|
|
|
TCHAR szChildClass[MAX_LOADSTRING];
|
2002-07-14 17:59:36 +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)
|
|
|
|
{
|
2002-07-14 20:38:52 +00:00
|
|
|
WNDCLASSEX wcFrame = {
|
|
|
|
sizeof(WNDCLASSEX),
|
|
|
|
CS_HREDRAW | CS_VREDRAW/*style*/,
|
|
|
|
FrameWndProc,
|
|
|
|
0/*cbClsExtra*/,
|
|
|
|
0/*cbWndExtra*/,
|
|
|
|
hInstance,
|
|
|
|
LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT)),
|
|
|
|
LoadCursor(0, IDC_ARROW),
|
|
|
|
0/*hbrBackground*/,
|
|
|
|
0/*lpszMenuName*/,
|
|
|
|
szFrameClass,
|
|
|
|
(HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON,
|
|
|
|
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED)
|
|
|
|
};
|
|
|
|
ATOM hFrameWndClass = RegisterClassEx(&wcFrame); // register frame window class
|
|
|
|
|
|
|
|
WNDCLASSEX wcChild = {
|
|
|
|
sizeof(WNDCLASSEX),
|
|
|
|
CS_HREDRAW | CS_VREDRAW/*style*/,
|
|
|
|
ChildWndProc,
|
|
|
|
0/*cbClsExtra*/,
|
|
|
|
sizeof(HANDLE)/*cbWndExtra*/,
|
|
|
|
hInstance,
|
|
|
|
LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT)),
|
|
|
|
LoadCursor(0, IDC_ARROW),
|
|
|
|
0/*hbrBackground*/,
|
|
|
|
0/*lpszMenuName*/,
|
|
|
|
szChildClass,
|
|
|
|
(HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON,
|
|
|
|
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED)
|
|
|
|
|
|
|
|
};
|
2002-07-20 16:29:26 +00:00
|
|
|
ATOM hChildWndClass = RegisterClassEx(&wcChild); // register child windows class
|
2002-08-29 18:42:38 +00:00
|
|
|
hChildWndClass = hChildWndClass; // warning eater
|
2002-07-14 20:38:52 +00:00
|
|
|
|
|
|
|
hMenuFrame = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_REGEDIT_MENU));
|
2002-07-14 17:59:36 +00:00
|
|
|
|
|
|
|
// Initialize the Windows Common Controls DLL
|
|
|
|
InitCommonControls();
|
|
|
|
|
2003-01-07 18:06:16 +00:00
|
|
|
nClipboardFormat = RegisterClipboardFormat(strClipboardFormat);
|
|
|
|
if (nClipboardFormat == 0) {
|
|
|
|
DWORD dwError = GetLastError();
|
|
|
|
}
|
|
|
|
|
2002-07-16 22:18:29 +00:00
|
|
|
hFrameWnd = CreateWindowEx(0, (LPCTSTR)(int)hFrameWndClass, szTitle,
|
2002-07-20 16:29:26 +00:00
|
|
|
WS_OVERLAPPEDWINDOW | WS_EX_CLIENTEDGE,
|
2002-07-14 20:38:52 +00:00
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
NULL, hMenuFrame, hInstance, NULL/*lpParam*/);
|
|
|
|
|
|
|
|
if (!hFrameWnd) {
|
2002-07-14 17:59:36 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create the status bar
|
|
|
|
hStatusBar = CreateStatusWindow(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBT_NOBORDERS,
|
2002-07-14 20:38:52 +00:00
|
|
|
_T(""), hFrameWnd, STATUS_WINDOW);
|
|
|
|
if (hStatusBar) {
|
|
|
|
// Create the status bar panes
|
2002-07-18 18:16:42 +00:00
|
|
|
SetupStatusBar(hFrameWnd, FALSE);
|
2002-07-14 20:38:52 +00:00
|
|
|
CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_STATUSBAR, MF_BYCOMMAND|MF_CHECKED);
|
|
|
|
}
|
|
|
|
ShowWindow(hFrameWnd, nCmdShow);
|
|
|
|
UpdateWindow(hFrameWnd);
|
2002-07-14 17:59:36 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void ExitInstance(void)
|
|
|
|
{
|
2002-07-14 20:38:52 +00:00
|
|
|
DestroyMenu(hMenuFrame);
|
2002-07-14 17:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int APIENTRY WinMain(HINSTANCE hInstance,
|
|
|
|
HINSTANCE hPrevInstance,
|
|
|
|
LPSTR lpCmdLine,
|
|
|
|
int nCmdShow)
|
|
|
|
{
|
|
|
|
MSG msg;
|
|
|
|
HACCEL hAccel;
|
2002-11-13 12:08:26 +00:00
|
|
|
/*
|
|
|
|
int hCrt;
|
|
|
|
FILE *hf;
|
|
|
|
AllocConsole();
|
|
|
|
hCrt = _open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT);
|
|
|
|
hf = _fdopen(hCrt, "w");
|
|
|
|
*stdout = *hf;
|
|
|
|
setvbuf(stdout, NULL, _IONBF, 0);
|
|
|
|
|
|
|
|
wprintf(L"command line exit, hInstance = %d\n", hInstance);
|
|
|
|
getch();
|
|
|
|
FreeConsole();
|
|
|
|
return 0;
|
|
|
|
*/
|
2002-07-14 17:59:36 +00:00
|
|
|
|
2002-08-29 18:42:38 +00:00
|
|
|
if (ProcessCmdLine(lpCmdLine)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-07-14 17:59:36 +00:00
|
|
|
// Initialize global strings
|
|
|
|
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
|
|
|
|
LoadString(hInstance, IDC_REGEDIT_FRAME, szFrameClass, MAX_LOADSTRING);
|
2002-07-14 20:38:52 +00:00
|
|
|
LoadString(hInstance, IDC_REGEDIT, szChildClass, MAX_LOADSTRING);
|
2002-07-14 17:59:36 +00:00
|
|
|
|
|
|
|
// Store instance handle in our global variable
|
|
|
|
hInst = hInstance;
|
|
|
|
|
|
|
|
// Perform application initialization:
|
|
|
|
if (!InitInstance(hInstance, nCmdShow)) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
hAccel = LoadAccelerators(hInstance, (LPCTSTR)IDC_REGEDIT);
|
|
|
|
|
|
|
|
// Main message loop:
|
|
|
|
while (GetMessage(&msg, (HWND)NULL, 0, 0)) {
|
|
|
|
if (!TranslateAccelerator(msg.hwnd, hAccel, &msg)) {
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ExitInstance();
|
|
|
|
return msg.wParam;
|
|
|
|
}
|