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 */
30 #define REGEDIT_DECLARE_FUNCTIONS
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
)
71 WNDCLASSEX wcFrame
= {
73 CS_HREDRAW
| CS_VREDRAW
/*style*/,
78 LoadIcon(hInstance
, MAKEINTRESOURCE(IDI_REGEDIT
)),
79 LoadCursor(0, IDC_ARROW
),
83 (HICON
)LoadImage(hInstance
, MAKEINTRESOURCE(IDI_REGEDIT
), IMAGE_ICON
,
84 GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
), LR_SHARED
)
86 ATOM hFrameWndClass
= RegisterClassEx(&wcFrame
); /* register frame window class */
88 WNDCLASSEX wcChild
= {
90 CS_HREDRAW
| CS_VREDRAW
/*style*/,
93 sizeof(HANDLE
)/*cbWndExtra*/,
95 LoadIcon(hInstance
, MAKEINTRESOURCE(IDI_REGEDIT
)),
96 LoadCursor(0, IDC_ARROW
),
100 (HICON
)LoadImage(hInstance
, MAKEINTRESOURCE(IDI_REGEDIT
), IMAGE_ICON
,
101 GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
), LR_SHARED
)
104 ATOM hChildWndClass
= RegisterClassEx(&wcChild
); /* register child windows class */
105 hChildWndClass
= hChildWndClass
; /* warning eater */
107 hMenuFrame
= LoadMenu(hInstance
, MAKEINTRESOURCE(IDR_REGEDIT_MENU
));
108 hPopupMenus
= LoadMenu(hInstance
, MAKEINTRESOURCE(IDR_POPUP_MENUS
));
110 /* Initialize the Windows Common Controls DLL */
111 InitCommonControls();
113 nClipboardFormat
= RegisterClipboardFormat(strClipboardFormat
);
114 /* if (nClipboardFormat == 0) {
115 DWORD dwError = GetLastError();
118 hFrameWnd
= CreateWindowEx(0, (LPCTSTR
)(int)hFrameWndClass
, szTitle
,
119 WS_OVERLAPPEDWINDOW
| WS_EX_CLIENTEDGE
,
120 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
121 NULL
, hMenuFrame
, hInstance
, NULL
/*lpParam*/);
127 /* Create the status bar */
128 hStatusBar
= CreateStatusWindow(WS_VISIBLE
|WS_CHILD
|WS_CLIPSIBLINGS
|SBT_NOBORDERS
,
129 _T(""), hFrameWnd
, STATUS_WINDOW
);
131 /* Create the status bar panes */
132 SetupStatusBar(hFrameWnd
, FALSE
);
133 CheckMenuItem(GetSubMenu(hMenuFrame
, ID_VIEW_MENU
), ID_VIEW_STATUSBAR
, MF_BYCOMMAND
|MF_CHECKED
);
135 ShowWindow(hFrameWnd
, nCmdShow
);
136 UpdateWindow(hFrameWnd
);
140 /******************************************************************************/
142 void ExitInstance(void)
144 DestroyMenu(hMenuFrame
);
147 int APIENTRY
WinMain(HINSTANCE hInstance
,
148 HINSTANCE hPrevInstance
,
155 if (ProcessCmdLine(lpCmdLine
)) {
159 /* Initialize global strings */
160 LoadString(hInstance
, IDS_APP_TITLE
, szTitle
, COUNT_OF(szTitle
));
161 LoadString(hInstance
, IDC_REGEDIT_FRAME
, szFrameClass
, COUNT_OF(szFrameClass
));
162 LoadString(hInstance
, IDC_REGEDIT
, szChildClass
, COUNT_OF(szChildClass
));
164 /* Store instance handle in our global variable */
167 /* Perform application initialization */
168 if (!InitInstance(hInstance
, nCmdShow
)) {
171 hAccel
= LoadAccelerators(hInstance
, (LPCTSTR
)IDC_REGEDIT
);
173 /* Main message loop */
174 while (GetMessage(&msg
, (HWND
)NULL
, 0, 0)) {
175 if (!TranslateAccelerator(hFrameWnd
, hAccel
, &msg
) &&
176 !IsDialogMessage(hFrameWnd
, &msg
)) {
177 TranslateMessage(&msg
);
178 DispatchMessage(&msg
);