c9bfd2e848fafbcbe8ce3819fadfed18556b28da
6 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 //#include <winspool.h>
28 #define MAX_LOADSTRING 100
32 HINSTANCE hInst
; // current instance
33 TCHAR szTitle
[MAX_LOADSTRING
]; // The title bar text
34 TCHAR szWindowClass
[MAX_LOADSTRING
]; // The title bar text
35 TCHAR szFrameClass
[MAX_LOADSTRING
]; // The title bar text
37 // Foward declarations of functions included in this code module:
38 ATOM
MyRegisterClass(HINSTANCE hInstance
);
39 ATOM
MyRegisterClass2(HINSTANCE hInstance
);
40 BOOL
InitInstance(HINSTANCE
, int);
41 LRESULT CALLBACK
WndProc(HWND
, UINT
, WPARAM
, LPARAM
);
42 LRESULT CALLBACK
FrameWndProc(HWND
, UINT
, WPARAM
, LPARAM
);
43 LRESULT CALLBACK
About(HWND
, UINT
, WPARAM
, LPARAM
);
45 int APIENTRY
WinMain(HINSTANCE hInstance
,
46 HINSTANCE hPrevInstance
,
50 // TODO: Place code here.
54 // Initialize global strings
55 LoadString(hInstance
, IDS_APP_TITLE
, szTitle
, MAX_LOADSTRING
);
56 LoadString(hInstance
, IDC_REGEDT32
, szWindowClass
, MAX_LOADSTRING
);
57 LoadString(hInstance
, IDC_REGEDT32_FRAME
, szFrameClass
, MAX_LOADSTRING
);
59 MyRegisterClass(hInstance
);
60 MyRegisterClass2(hInstance
);
62 // Perform application initialization:
63 if (!InitInstance (hInstance
, nCmdShow
))
68 hAccelTable
= LoadAccelerators(hInstance
, (LPCTSTR
)IDC_REGEDT32
);
71 while (GetMessage(&msg
, NULL
, 0, 0))
73 if (!TranslateAccelerator(msg
.hwnd
, hAccelTable
, &msg
))
75 TranslateMessage(&msg
);
76 DispatchMessage(&msg
);
86 // FUNCTION: MyRegisterClass()
88 // PURPOSE: Registers the window class.
92 // This function and its usage is only necessary if you want this code
93 // to be compatible with Win32 systems prior to the 'RegisterClassEx'
94 // function that was added to Windows 95. It is important to call this function
95 // so that the application will get 'well formed' small icons associated
98 ATOM
MyRegisterClass(HINSTANCE hInstance
)
102 wcex
.cbSize
= sizeof(WNDCLASSEX
);
104 wcex
.style
= CS_HREDRAW
| CS_VREDRAW
;
105 wcex
.lpfnWndProc
= (WNDPROC
)WndProc
;
108 wcex
.hInstance
= hInstance
;
109 wcex
.hIcon
= LoadIcon(hInstance
, (LPCTSTR
)IDI_REGEDT32
);
110 wcex
.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
111 wcex
.hbrBackground
= (HBRUSH
)SS_BLACKRECT
/*(COLOR_WINDOW+1)*/;
112 // wcex.lpszMenuName = (LPCSTR)IDC_REGEDT32;
113 // wcex.lpszMenuName = (LPCSTR)IDR_REGEDIT_MENU;
114 wcex
.lpszMenuName
= (LPCSTR
)IDR_REGEDT32_MENU
;
115 wcex
.lpszClassName
= szWindowClass
;
116 wcex
.hIconSm
= LoadIcon((HINSTANCE
)wcex
.hInstance
, (LPCTSTR
)IDI_SMALL
);
117 return RegisterClassEx(&wcex
);
120 ATOM
MyRegisterClass2(HINSTANCE hInstance
)
124 wcex
.cbSize
= sizeof(WNDCLASSEX
);
126 wcex
.style
= CS_HREDRAW
| CS_VREDRAW
;
127 wcex
.lpfnWndProc
= (WNDPROC
)FrameWndProc
;
130 wcex
.hInstance
= hInstance
;
131 wcex
.hIcon
= LoadIcon(hInstance
, (LPCTSTR
)IDI_REGEDT32
);
132 wcex
.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
133 wcex
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+1);
134 wcex
.lpszMenuName
= (LPCSTR
)IDR_REGEDIT_MENU
;
135 // wcex.lpszMenuName = (LPCSTR)IDR_REGEDT32_MENU;
136 wcex
.lpszClassName
= szFrameClass
;
137 wcex
.hIconSm
= LoadIcon((HINSTANCE
)wcex
.hInstance
, (LPCTSTR
)IDI_SMALL
);
139 return RegisterClassEx(&wcex
);
144 // FUNCTION: InitInstance(HANDLE, int)
146 // PURPOSE: Saves instance handle and creates main window
150 // In this function, we save the instance handle in a global variable and
151 // create and display the main program window.
153 BOOL
InitInstance(HINSTANCE hInstance
, int nCmdShow
)
157 hInst
= hInstance
; // Store instance handle in our global variable
159 hWnd
= CreateWindow(szWindowClass
, szTitle
, WS_OVERLAPPEDWINDOW
,
160 CW_USEDEFAULT
, 0, CW_USEDEFAULT
, 0, NULL
, NULL
, hInstance
, NULL
);
168 ShowWindow(hWnd
, nCmdShow
);
175 LRESULT CALLBACK
FrameWndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
180 TCHAR szHello
[MAX_LOADSTRING
];
181 LoadString(hInst
, IDS_HELLO
, szHello
, MAX_LOADSTRING
);
186 wmId
= LOWORD(wParam
);
187 wmEvent
= HIWORD(wParam
);
188 // Parse the menu selections:
192 // DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
194 HICON hIcon
= LoadIcon(hInst
, (LPCTSTR
)IDI_REGEDT32
);
195 ShellAbout(hWnd
, szTitle
, "FrameWndProc", hIcon
);
196 //if (hIcon) DestroyIcon(hIcon); // NOT REQUIRED
203 return DefWindowProc(hWnd
, message
, wParam
, lParam
);
207 hdc
= BeginPaint(hWnd
, &ps
);
208 // TODO: Add any drawing code here...
210 GetClientRect(hWnd
, &rt
);
211 DrawText(hdc
, szHello
, strlen(szHello
), &rt
, DT_CENTER
);
218 return DefWindowProc(hWnd
, message
, wParam
, lParam
);
225 // FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
227 // PURPOSE: Processes messages for the main window.
229 // WM_COMMAND - process the application menu
230 // WM_PAINT - Paint the main window
231 // WM_DESTROY - post a quit message and return
234 LRESULT CALLBACK
WndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
239 //TCHAR szHello[MAX_LOADSTRING];
240 //LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
245 wmId
= LOWORD(wParam
);
246 wmEvent
= HIWORD(wParam
);
247 // Parse the menu selections:
250 case ID_REGISTRY_PRINTERSETUP
:
254 //PageSetupDlg(&psd);
256 case ID_REGISTRY_OPENLOCAL
:
259 // hChildWnd = CreateWindow(szFrameClass, szTitle, WS_OVERLAPPEDWINDOW | WS_CHILD,
260 // CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, hWnd, NULL, hInst, NULL);
261 hChildWnd
= CreateWindow(szFrameClass
, szTitle
, WS_OVERLAPPEDWINDOW
| WS_CHILD
,
262 0, 0, 150, 170, hWnd
, NULL
, hInst
, NULL
);
264 ShowWindow(hChildWnd
, 1);
265 UpdateWindow(hChildWnd
);
270 // DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
272 HICON hIcon
= LoadIcon(hInst
, (LPCTSTR
)IDI_REGEDT32
);
273 ShellAbout(hWnd
, szTitle
, "", hIcon
);
274 //if (hIcon) DestroyIcon(hIcon); // NOT REQUIRED
281 return DefWindowProc(hWnd
, message
, wParam
, lParam
);
285 hdc
= BeginPaint(hWnd
, &ps
);
286 // TODO: Add any drawing code here...
288 GetClientRect(hWnd
, &rt
);
289 //DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER);
296 return DefWindowProc(hWnd
, message
, wParam
, lParam
);
301 // Mesage handler for about box.
302 LRESULT CALLBACK
About(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
)
310 if (LOWORD(wParam
) == IDOK
|| LOWORD(wParam
) == IDCANCEL
)
312 EndDialog(hDlg
, LOWORD(wParam
));