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 */
36 BOOL
ProcessCmdLine(LPSTR lpCmdLine
);
39 /*******************************************************************************
47 HMENU hPopupMenus
= 0;
48 UINT nClipboardFormat
;
49 LPCTSTR strClipboardFormat
= _T("TODO: SET CORRECT FORMAT");
52 #define MAX_LOADSTRING 100
53 TCHAR szTitle
[MAX_LOADSTRING
];
54 TCHAR szFrameClass
[MAX_LOADSTRING
];
55 TCHAR szChildClass
[MAX_LOADSTRING
];
58 /*******************************************************************************
61 * FUNCTION: InitInstance(HANDLE, int)
63 * PURPOSE: Saves instance handle and creates main window
67 * In this function, we save the instance handle in a global variable and
68 * create and display the main program window.
71 BOOL
InitInstance(HINSTANCE hInstance
, int nCmdShow
)
75 WNDCLASSEX wcFrame
= {
77 CS_HREDRAW
| CS_VREDRAW
/*style*/,
82 LoadIcon(hInstance
, MAKEINTRESOURCE(IDI_REGEDIT
)),
83 LoadCursor(0, IDC_ARROW
),
87 (HICON
)LoadImage(hInstance
, MAKEINTRESOURCE(IDI_REGEDIT
), IMAGE_ICON
,
88 GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
), LR_SHARED
)
90 ATOM hFrameWndClass
= RegisterClassEx(&wcFrame
); /* register frame window class */
92 WNDCLASSEX wcChild
= {
94 CS_HREDRAW
| CS_VREDRAW
/*style*/,
97 sizeof(HANDLE
)/*cbWndExtra*/,
99 LoadIcon(hInstance
, MAKEINTRESOURCE(IDI_REGEDIT
)),
100 LoadCursor(0, IDC_ARROW
),
104 (HICON
)LoadImage(hInstance
, MAKEINTRESOURCE(IDI_REGEDIT
), IMAGE_ICON
,
105 GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
), LR_SHARED
)
108 ATOM hChildWndClass
= RegisterClassEx(&wcChild
); /* register child windows class */
109 hChildWndClass
= hChildWndClass
; /* warning eater */
111 RegisterHexEditorClass(hInstance
);
113 hMenuFrame
= LoadMenu(hInstance
, MAKEINTRESOURCE(IDR_REGEDIT_MENU
));
114 hPopupMenus
= LoadMenu(hInstance
, MAKEINTRESOURCE(IDR_POPUP_MENUS
));
116 /* Initialize the Windows Common Controls DLL */
117 InitCommonControls();
119 AclUiAvailable
= InitializeAclUiDll();
123 /* hide the Edit/Permissions... menu entry */
124 hEditMenu
= GetSubMenu(hMenuFrame
, 1);
125 if(hEditMenu
!= NULL
)
127 RemoveMenu(hEditMenu
, ID_EDIT_PERMISSIONS
, MF_BYCOMMAND
);
128 /* remove the separator after the menu item */
129 RemoveMenu(hEditMenu
, 4, MF_BYPOSITION
);
133 nClipboardFormat
= RegisterClipboardFormat(strClipboardFormat
);
134 /* if (nClipboardFormat == 0) {
135 DWORD dwError = GetLastError();
138 hFrameWnd
= CreateWindowEx(WS_EX_WINDOWEDGE
, (LPCTSTR
)(int)hFrameWndClass
, szTitle
,
139 WS_OVERLAPPEDWINDOW
| WS_CLIPSIBLINGS
| WS_CLIPCHILDREN
,
140 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
141 NULL
, hMenuFrame
, hInstance
, NULL
/*lpParam*/);
147 /* Create the status bar */
148 hStatusBar
= CreateStatusWindow(WS_VISIBLE
|WS_CHILD
|WS_CLIPSIBLINGS
|SBT_NOBORDERS
,
149 _T(""), hFrameWnd
, STATUS_WINDOW
);
151 /* Create the status bar panes */
152 SetupStatusBar(hFrameWnd
, FALSE
);
153 CheckMenuItem(GetSubMenu(hMenuFrame
, ID_VIEW_MENU
), ID_VIEW_STATUSBAR
, MF_BYCOMMAND
|MF_CHECKED
);
155 ShowWindow(hFrameWnd
, nCmdShow
);
156 UpdateWindow(hFrameWnd
);
160 /******************************************************************************/
162 void ExitInstance(HINSTANCE hInstance
)
164 UnregisterHexEditorClass(hInstance
);
165 DestroyMenu(hMenuFrame
);
169 BOOL
TranslateChildTabMessage(MSG
*msg
)
171 if (msg
->message
!= WM_KEYDOWN
) return FALSE
;
172 if (msg
->wParam
!= VK_TAB
) return FALSE
;
173 if (GetParent(msg
->hwnd
) != g_pChildWnd
->hWnd
) return FALSE
;
174 PostMessage(g_pChildWnd
->hWnd
, WM_COMMAND
, ID_SWITCH_PANELS
, 0);
178 int APIENTRY
WinMain(HINSTANCE hInstance
,
179 HINSTANCE hPrevInstance
,
189 hCrt = _open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT);
190 hf = _fdopen(hCrt, "w");
192 setvbuf(stdout, NULL, _IONBF, 0);
194 wprintf(L"command line exit, hInstance = %d\n", hInstance);
200 if (ProcessCmdLine(lpCmdLine
)) {
204 /* Initialize global strings */
205 LoadString(hInstance
, IDS_APP_TITLE
, szTitle
, MAX_LOADSTRING
);
206 LoadString(hInstance
, IDC_REGEDIT_FRAME
, szFrameClass
, MAX_LOADSTRING
);
207 LoadString(hInstance
, IDC_REGEDIT
, szChildClass
, MAX_LOADSTRING
);
209 /* Store instance handle in our global variable */
212 /* Perform application initialization */
213 if (!InitInstance(hInstance
, nCmdShow
)) {
216 hAccel
= LoadAccelerators(hInstance
, (LPCTSTR
)IDC_REGEDIT
);
218 /* Main message loop */
219 while (GetMessage(&msg
, (HWND
)NULL
, 0, 0)) {
220 if (!TranslateAccelerator(msg
.hwnd
, hAccel
, &msg
)
221 && !TranslateChildTabMessage(&msg
)) {
222 TranslateMessage(&msg
);
223 DispatchMessage(&msg
);
226 ExitInstance(hInstance
);