basic implementation of zoomin functionality
[reactos.git] / rosapps / devutils / zoomin / main.c
1 /*
2 * ReactOS zoomin
3 *
4 * main.c
5 *
6 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
7 *
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.
12 *
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.
17 *
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.
21 */
22
23 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
24 #include <windows.h>
25 #include <tchar.h>
26 #include <stdlib.h>
27 #include <stdio.h>
28
29 #include "main.h"
30 #include "framewnd.h"
31
32
33 ////////////////////////////////////////////////////////////////////////////////
34 // Global Variables:
35 //
36
37 HWND hFrameWnd;
38 HMENU hMenuFrame;
39
40 TCHAR szTitle[MAX_LOADSTRING];
41 TCHAR szFrameClass[MAX_LOADSTRING];
42
43
44 ////////////////////////////////////////////////////////////////////////////////
45 //
46 // FUNCTION: InitInstance(HANDLE, int)
47 //
48 // PURPOSE: creates main window
49 //
50
51 BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
52 {
53 WNDCLASSEX wcFrame = {
54 sizeof(WNDCLASSEX),
55 CS_HREDRAW | CS_VREDRAW/*style*/,
56 FrameWndProc,
57 0/*cbClsExtra*/,
58 0/*cbWndExtra*/,
59 hInstance,
60 LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ZOOMIN)),
61 LoadCursor(0, IDC_ARROW),
62 0,//(HBRUSH)(COLOR_BTNFACE+1),
63 0/*lpszMenuName*/,
64 szFrameClass,
65 (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_ZOOMIN), IMAGE_ICON,
66 GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED)
67 };
68 ATOM hFrameWndClass = RegisterClassEx(&wcFrame); // register frame window class
69
70 hMenuFrame = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_ZOOMIN_MENU));
71
72 hFrameWnd = CreateWindowEx(0, (LPCTSTR)(int)hFrameWndClass, szTitle,
73 WS_OVERLAPPEDWINDOW | WS_EX_CLIENTEDGE,
74 CW_USEDEFAULT, CW_USEDEFAULT, 250, 250,
75 NULL, hMenuFrame, hInstance, NULL/*lpParam*/);
76
77 if (!hFrameWnd) {
78 return FALSE;
79 }
80
81 ShowWindow(hFrameWnd, nCmdShow);
82 UpdateWindow(hFrameWnd);
83 return TRUE;
84 }
85
86 ////////////////////////////////////////////////////////////////////////////////
87
88 void ExitInstance(void)
89 {
90 DestroyMenu(hMenuFrame);
91 }
92
93
94 int APIENTRY WinMain(HINSTANCE hInstance,
95 HINSTANCE hPrevInstance,
96 LPSTR lpCmdLine,
97 int nCmdShow)
98 {
99 MSG msg;
100 HACCEL hAccel;
101
102 // Initialize global strings
103 LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
104 LoadString(hInstance, IDC_ZOOMIN, szFrameClass, MAX_LOADSTRING);
105
106 // Perform application initialization:
107 if (!InitInstance(hInstance, nCmdShow)) {
108 return FALSE;
109 }
110
111 hAccel = LoadAccelerators(hInstance, (LPCTSTR)IDC_ZOOMIN);
112
113 // Main message loop:
114 while (GetMessage(&msg, (HWND)NULL, 0, 0)) {
115 if (!TranslateAccelerator(msg.hwnd, hAccel, &msg)) {
116 TranslateMessage(&msg);
117 DispatchMessage(&msg);
118 }
119 }
120 ExitInstance();
121 return msg.wParam;
122 }