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 */
38 BOOL
ProcessCmdLine(LPSTR lpCmdLine
);
41 /*******************************************************************************
49 HMENU hPopupMenus
= 0;
50 UINT nClipboardFormat
;
51 LPCTSTR strClipboardFormat
= _T("TODO: SET CORRECT FORMAT");
54 #define MAX_LOADSTRING 100
55 TCHAR szTitle
[MAX_LOADSTRING
];
56 TCHAR szFrameClass
[MAX_LOADSTRING
];
57 TCHAR szChildClass
[MAX_LOADSTRING
];
60 /*******************************************************************************
63 * FUNCTION: InitInstance(HANDLE, int)
65 * PURPOSE: Saves instance handle and creates main window
69 * In this function, we save the instance handle in a global variable and
70 * create and display the main program window.
73 BOOL
InitInstance(HINSTANCE hInstance
, int nCmdShow
)
77 WNDCLASSEX wcFrame
= {
79 CS_HREDRAW
| CS_VREDRAW
/*style*/,
84 LoadIcon(hInstance
, MAKEINTRESOURCE(IDI_REGEDIT
)),
85 LoadCursor(0, IDC_ARROW
),
89 (HICON
)LoadImage(hInstance
, MAKEINTRESOURCE(IDI_REGEDIT
), IMAGE_ICON
,
90 GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
), LR_SHARED
)
92 ATOM hFrameWndClass
= RegisterClassEx(&wcFrame
); /* register frame window class */
94 WNDCLASSEX wcChild
= {
96 CS_HREDRAW
| CS_VREDRAW
/*style*/,
99 sizeof(HANDLE
)/*cbWndExtra*/,
101 LoadIcon(hInstance
, MAKEINTRESOURCE(IDI_REGEDIT
)),
102 LoadCursor(0, IDC_ARROW
),
106 (HICON
)LoadImage(hInstance
, MAKEINTRESOURCE(IDI_REGEDIT
), IMAGE_ICON
,
107 GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
), LR_SHARED
)
110 ATOM hChildWndClass
= RegisterClassEx(&wcChild
); /* register child windows class */
111 hChildWndClass
= hChildWndClass
; /* warning eater */
113 RegisterHexEditorClass(hInstance
);
115 hMenuFrame
= LoadMenu(hInstance
, MAKEINTRESOURCE(IDR_REGEDIT_MENU
));
116 hPopupMenus
= LoadMenu(hInstance
, MAKEINTRESOURCE(IDR_POPUP_MENUS
));
118 /* Initialize the Windows Common Controls DLL */
119 InitCommonControls();
122 hEditMenu
= GetSubMenu(hMenuFrame
, 1);
124 AclUiAvailable
= InitializeAclUiDll();
127 /* hide the Edit/Permissions... menu entry */
128 if(hEditMenu
!= NULL
)
130 RemoveMenu(hEditMenu
, ID_EDIT_PERMISSIONS
, MF_BYCOMMAND
);
131 /* remove the separator after the menu item */
132 RemoveMenu(hEditMenu
, 4, MF_BYPOSITION
);
136 if(hEditMenu
!= NULL
)
137 SetMenuDefaultItem(hEditMenu
, ID_EDIT_MODIFY
, MF_BYCOMMAND
);
139 nClipboardFormat
= RegisterClipboardFormat(strClipboardFormat
);
140 /* if (nClipboardFormat == 0) {
141 DWORD dwError = GetLastError();
144 hFrameWnd
= CreateWindowEx(WS_EX_WINDOWEDGE
, (LPCTSTR
)(int)hFrameWndClass
, szTitle
,
145 WS_OVERLAPPEDWINDOW
| WS_CLIPSIBLINGS
| WS_CLIPCHILDREN
,
146 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
147 NULL
, hMenuFrame
, hInstance
, NULL
/*lpParam*/);
153 /* Create the status bar */
154 hStatusBar
= CreateStatusWindow(WS_VISIBLE
|WS_CHILD
|WS_CLIPSIBLINGS
|SBT_NOBORDERS
,
155 _T(""), hFrameWnd
, STATUS_WINDOW
);
157 /* Create the status bar panes */
158 SetupStatusBar(hFrameWnd
, FALSE
);
159 CheckMenuItem(GetSubMenu(hMenuFrame
, ID_VIEW_MENU
), ID_VIEW_STATUSBAR
, MF_BYCOMMAND
|MF_CHECKED
);
161 ShowWindow(hFrameWnd
, nCmdShow
);
162 UpdateWindow(hFrameWnd
);
166 /******************************************************************************/
168 void ExitInstance(HINSTANCE hInstance
)
170 UnregisterHexEditorClass(hInstance
);
171 DestroyMenu(hMenuFrame
);
172 DestroyMenu(hPopupMenus
);
176 BOOL
TranslateChildTabMessage(MSG
*msg
)
178 if (msg
->message
!= WM_KEYDOWN
) return FALSE
;
179 if (msg
->wParam
!= VK_TAB
) return FALSE
;
180 if (GetParent(msg
->hwnd
) != g_pChildWnd
->hWnd
) return FALSE
;
181 PostMessage(g_pChildWnd
->hWnd
, WM_COMMAND
, ID_SWITCH_PANELS
, 0);
185 int APIENTRY
WinMain(HINSTANCE hInstance
,
186 HINSTANCE hPrevInstance
,
196 hCrt = _open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT);
197 hf = _fdopen(hCrt, "w");
199 setvbuf(stdout, NULL, _IONBF, 0);
201 wprintf(L"command line exit, hInstance = %d\n", hInstance);
207 if (ProcessCmdLine(lpCmdLine
)) {
211 /* Initialize global strings */
212 LoadString(hInstance
, IDS_APP_TITLE
, szTitle
, MAX_LOADSTRING
);
213 LoadString(hInstance
, IDC_REGEDIT_FRAME
, szFrameClass
, MAX_LOADSTRING
);
214 LoadString(hInstance
, IDC_REGEDIT
, szChildClass
, MAX_LOADSTRING
);
216 /* Store instance handle in our global variable */
219 /* Perform application initialization */
220 if (!InitInstance(hInstance
, nCmdShow
)) {
223 hAccel
= LoadAccelerators(hInstance
, (LPCTSTR
)IDC_REGEDIT
);
225 /* Main message loop */
226 while (GetMessage(&msg
, (HWND
)NULL
, 0, 0)) {
227 if (!TranslateAccelerator(msg
.hwnd
, hAccel
, &msg
)
228 && !TranslateChildTabMessage(&msg
)) {
229 TranslateMessage(&msg
);
230 DispatchMessage(&msg
);
233 ExitInstance(hInstance
);