ReactOS 0.4.16-dev-320-g3bd9ddc
main.c
Go to the documentation of this file.
1/*
2 * ReactOS Application
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#ifdef _MSC_VER
24#include "stdafx.h"
25#else
26#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
27#include <windows.h>
28#include <commctrl.h>
29#include <stdlib.h>
30#include <malloc.h>
31#include <memory.h>
32#include <tchar.h>
33#include <process.h>
34#include <stdio.h>
35#endif
36
37#include "main.h"
38#include "framewnd.h"
39#include "childwnd.h"
40
41
43// Global Variables:
44//
45
47HACCEL hAccel;
54
58
59
61
63{
64 WNDCLASSEX wcFrame = {
65 sizeof(WNDCLASSEX),
66 CS_HREDRAW | CS_VREDRAW/*style*/,
68 0/*cbClsExtra*/,
69 0/*cbWndExtra*/,
73 0/*hbrBackground*/,
74 0/*lpszMenuName*/,
78 };
79 ATOM hFrameWndClass = RegisterClassEx(&wcFrame); // register frame window class
80#if 0
81 WNDCLASS wcChild = {
84 0/*cbClsExtra*/,
85 0/*cbWndExtra*/,
87 0/*hIcon*/,
89 0/*hbrBackground*/,
90 0/*lpszMenuName*/,
92 };
93 ATOM hChildWndClass = RegisterClass(&wcChild); // register child windows class
94#else
95 // WNDCLASSEX wcChild = {
96 // sizeof(WNDCLASSEX),
97 // CS_HREDRAW | CS_VREDRAW/*style*/,
98 // ChildWndProc,
99 // 0/*cbClsExtra*/,
100 // sizeof(HANDLE)/*cbWndExtra*/,
101 // hInstance,
102 // LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MDI_APP)),
103 // LoadCursor(0, IDC_ARROW),
104 // 0/*hbrBackground*/,
105 // 0/*lpszMenuName*/,
106 // szChildClass,
107 // (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDC_MDI_APP), IMAGE_ICON,
108 // GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED)
109 // };
110 // ATOM hChildWndClass = RegisterClassEx(&wcChild); // register child windows class
111#endif
112
114 HMENU hMenuOptions = GetSubMenu(hMenu, ID_OPTIONS_MENU);
115 // HMENU hChildMenu = LoadMenu(hInstance, MAKEINTRESOURCE(IDC_MDI_APP_CHILD));
116
118 sizeof(INITCOMMONCONTROLSEX),
120 };
121
122 HDC hdc = GetDC(0);
123
124 hMenuFrame = hMenu;
125// hMenuView = GetSubMenu(hMenuFrame, ID_VIEW_MENU);
127 hFont = CreateFont(-MulDiv(8,GetDeviceCaps(hdc,LOGPIXELSY),72), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _T("MS Sans Serif"));
128 ReleaseDC(0, hdc);
129
130 hFrameWnd = CreateWindowEx(0, (LPCTSTR)(ULONG_PTR)hFrameWndClass, szTitle,
131// hFrameWnd = CreateWindow(szFrameClass, szTitle,
134 NULL/*hWndParent*/, hMenuFrame, hInstance, NULL/*lpParam*/);
135 if (!hFrameWnd) {
136 return FALSE;
137 }
138
139 if (InitCommonControlsEx(&icc))
140 {
141 int nParts[3];
142 TBBUTTON toolbarBtns[] = {
143 {0, 0, 0, TBSTYLE_SEP},
148 {4, 2/*TODO: ID_...*/, TBSTATE_ENABLED, TBSTYLE_BUTTON},
149 {5, 2/*TODO: ID_...*/, TBSTATE_ENABLED, TBSTYLE_BUTTON},
150 };
151
153 IDC_TOOLBAR, 2, hInstance, IDB_TOOLBAR, toolbarBtns,
154 sizeof(toolbarBtns)/sizeof(TBBUTTON), 16, 15, 16, 15, sizeof(TBBUTTON));
156
157 // Create the status bar
160 if (!hStatusBar)
161 return FALSE;
163
164 // Create the status bar panes
165 nParts[0] = 100;
166 nParts[1] = 210;
167 nParts[2] = 400;
169 } else {
172 }
173
174 ShowWindow(hFrameWnd, nCmdShow);
177 return TRUE;
178}
179
181
183{
184 TCHAR text[260];
185 DWORD size;
186
187 size = sizeof(text)/sizeof(TCHAR);
190 size = sizeof(text)/sizeof(TCHAR);
193}
194
195
196static int g_foundPrevInstance = 0;
197
198// search for already running win[e]files
200{
201 TCHAR cls[128];
202
203 GetClassName(hWnd, cls, 128);
204 if (!lstrcmp(cls, (LPCTSTR)lParam)) {
206 return FALSE;
207 }
208 return TRUE;
209}
210
212
213void ExitInstance(void)
214{
216}
217
218
220 HINSTANCE hPrevInstance,
221 LPSTR lpCmdLine,
222 int nCmdShow)
223{
224 MSG msg;
225// HACCEL hAccel;
227
228 // Initialize global strings
232
233 // Allow only one running instance
236 return 1;
237
238 // Store instance handle in our global variable
240
241 // Perform application initialization:
242 if (!InitInstance(hInstance, nCmdShow)) {
243 return FALSE;
244 }
245// hAccel = LoadAccelerators(hInstance, (LPCTSTR)IDC_MDI_APP);
247
248 // Main message loop:
249 while (GetMessage(&msg, (HWND)NULL, 0, 0)) {
254 }
255 }
256 ExitInstance();
257 return msg.wParam;
258}
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
#define IDS_APP_TITLE
Definition: resource.h:10
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdline, int cmdshow)
Definition: main.c:8
#define IDC_STATUSBAR
Definition: resource.h:12
LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: childwnd.c:366
LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: framewnd.c:1440
#define MAX_LOADSTRING
Definition: main.c:29
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
Definition: main.c:42
HWND hFrameWnd
Definition: main.c:22
WCHAR szFrameClass[MAX_LOADSTRING]
Definition: main.c:31
HMENU hMenuFrame
Definition: main.c:24
WCHAR szTitle[MAX_LOADSTRING]
Definition: main.c:30
WCHAR szChildClass[MAX_LOADSTRING]
Definition: main.c:32
HWND hStatusBar
Definition: main.c:23
HFONT hFont
Definition: main.c:53
HINSTANCE hInstance
Definition: charmap.c:19
LPARAM lParam
Definition: combotst.c:139
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:900
HWND WINAPI CreateToolbarEx(HWND hwnd, DWORD style, UINT wID, INT nBitmaps, HINSTANCE hBMInst, UINT_PTR wBMID, LPCTBBUTTON lpButtons, INT iNumButtons, INT dxButton, INT dyButton, INT dxBitmap, INT dyBitmap, UINT uStructSize)
Definition: commctrl.c:936
WORD ATOM
Definition: dimm.idl:113
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define APIENTRY
Definition: api.h:79
#define CALLBACK
Definition: compat.h:35
const WCHAR * text
Definition: package.c:1794
HINSTANCE hInst
Definition: dxdiag.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizeiptr size
Definition: glext.h:5919
#define ID_WINDOW_TILE_VERT
Definition: resource.h:49
#define ID_WINDOW_TILE_HORZ
Definition: resource.h:48
#define ID_WINDOW_CASCADE
Definition: resource.h:50
static BOOL CALLBACK EnumWndProc(HWND hWnd, LPARAM lParam)
Definition: main.c:199
void ExitInstance(void)
Definition: main.c:213
HWND hMDIClient
Definition: main.c:49
HACCEL hAccel
Definition: main.c:47
static int g_foundPrevInstance
Definition: main.c:196
void UpdateStatusBar(void)
Definition: main.c:182
HWND hToolBar
Definition: main.c:52
#define ID_OPTIONS_TOOLBAR
Definition: resource.h:40
#define IDI_MDI_APP
Definition: resource.h:14
#define ID_OPTIONS_STATUSBAR
Definition: resource.h:41
#define IDC_MDI_APP
Definition: resource.h:16
#define ID_OPTIONS_MENU
Definition: resource.h:8
#define IDC_MDI_APP_CHILD
Definition: resource.h:17
#define ID_WINDOW_NEW_WINDOW
Definition: resource.h:44
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
static HICON
Definition: imagelist.c:80
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
#define WS_CHILD
Definition: pedump.c:617
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_VISIBLE
Definition: pedump.c:620
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define WS_CLIPCHILDREN
Definition: pedump.c:619
struct tagINITCOMMONCONTROLSEX INITCOMMONCONTROLSEX
#define CreateStatusWindow
Definition: commctrl.h:1938
#define SBT_NOBORDERS
Definition: commctrl.h:1976
#define TBSTYLE_BUTTON
Definition: commctrl.h:981
#define TBSTYLE_SEP
Definition: commctrl.h:982
#define TBSTATE_ENABLED
Definition: commctrl.h:974
#define SB_SETTEXT
Definition: commctrl.h:1954
#define SB_SETPARTS
Definition: commctrl.h:1959
#define ICC_BAR_CLASSES
Definition: commctrl.h:60
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define _T(x)
Definition: vfdio.h:22
#define lstrcmp
Definition: winbase.h:3897
#define GetUserName
Definition: winbase.h:3876
#define GetComputerName
Definition: winbase.h:3825
LONG_PTR LPARAM
Definition: windef.h:208
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define LOGPIXELSY
Definition: wingdi.h:719
#define CreateFont
Definition: wingdi.h:4443
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define CS_VREDRAW
Definition: winuser.h:658
#define CreateWindowEx
Definition: winuser.h:5767
#define MF_BYCOMMAND
Definition: winuser.h:202
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define IMAGE_ICON
Definition: winuser.h:212
#define GetClassName
Definition: winuser.h:5795
#define CS_HREDRAW
Definition: winuser.h:653
#define IDC_ARROW
Definition: winuser.h:687
#define SM_CYSMICON
Definition: winuser.h:1016
#define MF_CHECKED
Definition: winuser.h:132
#define CS_DBLCLKS
Definition: winuser.h:651
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define GetMessage
Definition: winuser.h:5802
#define SM_CXSMICON
Definition: winuser.h:1015
#define RegisterClassEx
Definition: winuser.h:5849
BOOL WINAPI TranslateMDISysAccel(_In_ HWND, _In_ LPMSG)
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
BOOL WINAPI EnumWindows(_In_ WNDENUMPROC lpEnumFunc, _In_ LPARAM lParam)
#define LoadIcon
Definition: winuser.h:5825
BOOL WINAPI UpdateWindow(_In_ HWND)
#define SendMessage
Definition: winuser.h:5855
#define LoadCursor
Definition: winuser.h:5824
WNDCLASSEXA WNDCLASSEX
Definition: winuser.h:5731
HDC WINAPI GetDC(_In_opt_ HWND)
#define LR_SHARED
Definition: winuser.h:1103
#define LoadMenu
Definition: winuser.h:5829
#define CW_USEDEFAULT
Definition: winuser.h:225
#define LoadImage
Definition: winuser.h:5827
BOOL WINAPI DestroyMenu(_In_ HMENU)
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
#define LoadString
Definition: winuser.h:5831
#define RegisterClass
Definition: winuser.h:5848
#define CS_CLASSDC
Definition: winuser.h:650
#define DispatchMessage
Definition: winuser.h:5777
#define GW_CHILD
Definition: winuser.h:766
#define TranslateAccelerator
Definition: winuser.h:5872
#define MAKEINTRESOURCE
Definition: winuser.h:591
int WINAPI GetSystemMetrics(_In_ int)
#define LoadAccelerators
Definition: winuser.h:5822
#define MF_GRAYED
Definition: winuser.h:129
#define IDB_TOOLBAR
Definition: wordpad.h:183
#define IDC_TOOLBAR
Definition: wordpad.h:157
char TCHAR
Definition: xmlstorage.h:189
char * LPSTR
Definition: xmlstorage.h:182
const CHAR * LPCTSTR
Definition: xmlstorage.h:193