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
33 LPCSTR g_pszDefaultValueName
= _T("(Default)");
35 BOOL
ProcessCmdLine(LPSTR lpCmdLine
);
38 /*******************************************************************************
46 HMENU hPopupMenus
= 0;
47 UINT nClipboardFormat
;
48 LPCTSTR strClipboardFormat
= _T("TODO: SET CORRECT FORMAT");
51 #define MAX_LOADSTRING 100
52 TCHAR szTitle
[MAX_LOADSTRING
];
53 TCHAR szFrameClass
[MAX_LOADSTRING
];
54 TCHAR szChildClass
[MAX_LOADSTRING
];
57 /*******************************************************************************
60 * FUNCTION: InitInstance(HANDLE, int)
62 * PURPOSE: Saves instance handle and creates main window
66 * In this function, we save the instance handle in a global variable and
67 * create and display the main program window.
70 BOOL
InitInstance(HINSTANCE hInstance
, int nCmdShow
)
72 WNDCLASSEX wcFrame
= {
74 CS_HREDRAW
| CS_VREDRAW
/*style*/,
79 LoadIcon(hInstance
, MAKEINTRESOURCE(IDI_REGEDIT
)),
80 LoadCursor(0, IDC_ARROW
),
84 (HICON
)LoadImage(hInstance
, MAKEINTRESOURCE(IDI_REGEDIT
), IMAGE_ICON
,
85 GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
), LR_SHARED
)
87 ATOM hFrameWndClass
= RegisterClassEx(&wcFrame
); /* register frame window class */
89 WNDCLASSEX wcChild
= {
91 CS_HREDRAW
| CS_VREDRAW
/*style*/,
94 sizeof(HANDLE
)/*cbWndExtra*/,
96 LoadIcon(hInstance
, MAKEINTRESOURCE(IDI_REGEDIT
)),
97 LoadCursor(0, IDC_ARROW
),
101 (HICON
)LoadImage(hInstance
, MAKEINTRESOURCE(IDI_REGEDIT
), IMAGE_ICON
,
102 GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
), LR_SHARED
)
105 ATOM hChildWndClass
= RegisterClassEx(&wcChild
); /* register child windows class */
106 hChildWndClass
= hChildWndClass
; /* warning eater */
108 hMenuFrame
= LoadMenu(hInstance
, MAKEINTRESOURCE(IDR_REGEDIT_MENU
));
109 hPopupMenus
= LoadMenu(hInstance
, MAKEINTRESOURCE(IDR_POPUP_MENUS
));
111 /* Initialize the Windows Common Controls DLL */
112 InitCommonControls();
114 nClipboardFormat
= RegisterClipboardFormat(strClipboardFormat
);
115 /* if (nClipboardFormat == 0) {
116 DWORD dwError = GetLastError();
119 hFrameWnd
= CreateWindowEx(0, (LPCTSTR
)(int)hFrameWndClass
, szTitle
,
120 WS_OVERLAPPEDWINDOW
| WS_EX_CLIENTEDGE
,
121 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
122 NULL
, hMenuFrame
, hInstance
, NULL
/*lpParam*/);
128 /* Create the status bar */
129 hStatusBar
= CreateStatusWindow(WS_VISIBLE
|WS_CHILD
|WS_CLIPSIBLINGS
|SBT_NOBORDERS
,
130 _T(""), hFrameWnd
, STATUS_WINDOW
);
132 /* Create the status bar panes */
133 SetupStatusBar(hFrameWnd
, FALSE
);
134 CheckMenuItem(GetSubMenu(hMenuFrame
, ID_VIEW_MENU
), ID_VIEW_STATUSBAR
, MF_BYCOMMAND
|MF_CHECKED
);
136 ShowWindow(hFrameWnd
, nCmdShow
);
137 UpdateWindow(hFrameWnd
);
141 /******************************************************************************/
143 void ExitInstance(void)
145 DestroyMenu(hMenuFrame
);
148 BOOL
TranslateChildTabMessage(MSG
*msg
)
150 if (msg
->message
!= WM_KEYDOWN
) return FALSE
;
151 if (msg
->wParam
!= VK_TAB
) return FALSE
;
152 if (GetParent(msg
->hwnd
) != g_pChildWnd
->hWnd
) return FALSE
;
153 PostMessage(g_pChildWnd
->hWnd
, WM_COMMAND
, ID_SWITCH_PANELS
, 0);
157 int APIENTRY
WinMain(HINSTANCE hInstance
,
158 HINSTANCE hPrevInstance
,
165 if (ProcessCmdLine(lpCmdLine
)) {
169 /* Initialize global strings */
170 LoadString(hInstance
, IDS_APP_TITLE
, szTitle
, COUNT_OF(szTitle
));
171 LoadString(hInstance
, IDC_REGEDIT_FRAME
, szFrameClass
, COUNT_OF(szFrameClass
));
172 LoadString(hInstance
, IDC_REGEDIT
, szChildClass
, COUNT_OF(szChildClass
));
174 /* Store instance handle in our global variable */
177 /* Perform application initialization */
178 if (!InitInstance(hInstance
, nCmdShow
)) {
181 hAccel
= LoadAccelerators(hInstance
, (LPCTSTR
)IDC_REGEDIT
);
183 /* Main message loop */
184 while (GetMessage(&msg
, (HWND
)NULL
, 0, 0)) {
185 if (!TranslateAccelerator(hFrameWnd
, hAccel
, &msg
)
186 && !TranslateChildTabMessage(&msg
)) {
187 TranslateMessage(&msg
);
188 DispatchMessage(&msg
);