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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
34 BOOL
ProcessCmdLine(LPSTR lpCmdLine
);
37 /*******************************************************************************
45 HMENU hPopupMenus
= 0;
46 UINT nClipboardFormat
;
47 LPCTSTR strClipboardFormat
= _T("TODO: SET CORRECT FORMAT");
50 #define MAX_LOADSTRING 100
51 TCHAR szTitle
[MAX_LOADSTRING
];
52 TCHAR szFrameClass
[MAX_LOADSTRING
];
53 TCHAR szChildClass
[MAX_LOADSTRING
];
56 /*******************************************************************************
59 * FUNCTION: InitInstance(HANDLE, int)
61 * PURPOSE: Saves instance handle and creates main window
65 * In this function, we save the instance handle in a global variable and
66 * create and display the main program window.
69 BOOL
InitInstance(HINSTANCE hInstance
, int nCmdShow
)
73 WNDCLASSEX wcFrame
= {
75 CS_HREDRAW
| CS_VREDRAW
/*style*/,
80 LoadIcon(hInstance
, MAKEINTRESOURCE(IDI_REGEDIT
)),
81 LoadCursor(0, IDC_ARROW
),
85 (HICON
)LoadImage(hInstance
, MAKEINTRESOURCE(IDI_REGEDIT
), IMAGE_ICON
,
86 GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
), LR_SHARED
)
88 ATOM hFrameWndClass
= RegisterClassEx(&wcFrame
); /* register frame window class */
90 WNDCLASSEX wcChild
= {
92 CS_HREDRAW
| CS_VREDRAW
/*style*/,
95 sizeof(HANDLE
)/*cbWndExtra*/,
97 LoadIcon(hInstance
, MAKEINTRESOURCE(IDI_REGEDIT
)),
98 LoadCursor(0, IDC_ARROW
),
102 (HICON
)LoadImage(hInstance
, MAKEINTRESOURCE(IDI_REGEDIT
), IMAGE_ICON
,
103 GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
), LR_SHARED
)
106 ATOM hChildWndClass
= RegisterClassEx(&wcChild
); /* register child windows class */
107 hChildWndClass
= hChildWndClass
; /* warning eater */
109 RegisterHexEditorClass(hInstance
);
111 hMenuFrame
= LoadMenu(hInstance
, MAKEINTRESOURCE(IDR_REGEDIT_MENU
));
112 hPopupMenus
= LoadMenu(hInstance
, MAKEINTRESOURCE(IDR_POPUP_MENUS
));
114 /* Initialize the Windows Common Controls DLL */
115 InitCommonControls();
117 AclUiAvailable
= InitializeAclUiDll();
122 /* hide the Edit/Permissions... menu entry */
123 hEditMenu
= GetSubMenu(hMenuFrame
, 1);
124 if(hEditMenu
!= NULL
)
126 RemoveMenu(hEditMenu
, ID_EDIT_PERMISSIONS
, MF_BYCOMMAND
);
127 /* remove the separator after the menu item */
128 RemoveMenu(hEditMenu
, 4, MF_BYPOSITION
);
132 nClipboardFormat
= RegisterClipboardFormat(strClipboardFormat
);
133 /* if (nClipboardFormat == 0) {
134 DWORD dwError = GetLastError();
137 hFrameWnd
= CreateWindowEx(WS_EX_WINDOWEDGE
, (LPCTSTR
)(int)hFrameWndClass
, szTitle
,
138 WS_OVERLAPPEDWINDOW
| WS_CLIPSIBLINGS
| WS_CLIPCHILDREN
,
139 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
140 NULL
, hMenuFrame
, hInstance
, NULL
/*lpParam*/);
146 /* Create the status bar */
147 hStatusBar
= CreateStatusWindow(WS_VISIBLE
|WS_CHILD
|WS_CLIPSIBLINGS
|SBT_NOBORDERS
,
148 _T(""), hFrameWnd
, STATUS_WINDOW
);
150 /* Create the status bar panes */
151 SetupStatusBar(hFrameWnd
, FALSE
);
152 CheckMenuItem(GetSubMenu(hMenuFrame
, ID_VIEW_MENU
), ID_VIEW_STATUSBAR
, MF_BYCOMMAND
|MF_CHECKED
);
154 ShowWindow(hFrameWnd
, nCmdShow
);
155 UpdateWindow(hFrameWnd
);
159 /******************************************************************************/
161 void ExitInstance(HINSTANCE hInstance
)
163 UnregisterHexEditorClass(hInstance
);
164 DestroyMenu(hMenuFrame
);
168 BOOL
TranslateChildTabMessage(MSG
*msg
)
170 if (msg
->message
!= WM_KEYDOWN
) return FALSE
;
171 if (msg
->wParam
!= VK_TAB
) return FALSE
;
172 if (GetParent(msg
->hwnd
) != g_pChildWnd
->hWnd
) return FALSE
;
173 PostMessage(g_pChildWnd
->hWnd
, WM_COMMAND
, ID_SWITCH_PANELS
, 0);
177 int APIENTRY
WinMain(HINSTANCE hInstance
,
178 HINSTANCE hPrevInstance
,
188 hCrt = _open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT);
189 hf = _fdopen(hCrt, "w");
191 setvbuf(stdout, NULL, _IONBF, 0);
193 wprintf(L"command line exit, hInstance = %d\n", hInstance);
199 if (ProcessCmdLine(lpCmdLine
)) {
203 /* Initialize global strings */
204 LoadString(hInstance
, IDS_APP_TITLE
, szTitle
, MAX_LOADSTRING
);
205 LoadString(hInstance
, IDC_REGEDIT_FRAME
, szFrameClass
, MAX_LOADSTRING
);
206 LoadString(hInstance
, IDC_REGEDIT
, szChildClass
, MAX_LOADSTRING
);
208 /* Store instance handle in our global variable */
211 /* Perform application initialization */
212 if (!InitInstance(hInstance
, nCmdShow
)) {
215 hAccel
= LoadAccelerators(hInstance
, (LPCTSTR
)IDC_REGEDIT
);
217 /* Main message loop */
218 while (GetMessage(&msg
, (HWND
)NULL
, 0, 0)) {
219 if (!TranslateAccelerator(msg
.hwnd
, hAccel
, &msg
)
220 && !TranslateChildTabMessage(&msg
)) {
221 TranslateMessage(&msg
);
222 DispatchMessage(&msg
);
225 ExitInstance(hInstance
);