ReactOS 0.4.15-dev-7958-gcd0bb1a
main.c File Reference
#include <windows.h>
#include <commctrl.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <process.h>
#include <stdio.h>
#include "main.h"
#include "framewnd.h"
#include "childwnd.h"
Include dependency graph for main.c:

Go to the source code of this file.

Macros

#define WIN32_LEAN_AND_MEAN
 

Functions

BOOL InitInstance (HINSTANCE hInstance, int nCmdShow)
 
void UpdateStatusBar (void)
 
static BOOL CALLBACK EnumWndProc (HWND hWnd, LPARAM lParam)
 
void ExitInstance (void)
 
int APIENTRY WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
 

Variables

HINSTANCE hInst
 
HACCEL hAccel
 
HWND hFrameWnd
 
HWND hMDIClient
 
HMENU hMenuFrame
 
HWND hStatusBar
 
HWND hToolBar
 
HFONT hFont
 
TCHAR szTitle [MAX_LOADSTRING]
 
TCHAR szFrameClass [MAX_LOADSTRING]
 
TCHAR szChildClass [MAX_LOADSTRING]
 
static int g_foundPrevInstance = 0
 

Macro Definition Documentation

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 26 of file main.c.

Function Documentation

◆ EnumWndProc()

static BOOL CALLBACK EnumWndProc ( HWND  hWnd,
LPARAM  lParam 
)
static

Definition at line 199 of file main.c.

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}
HWND hWnd
Definition: settings.c:17
LPARAM lParam
Definition: combotst.c:139
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static int g_foundPrevInstance
Definition: main.c:196
#define lstrcmp
Definition: winbase.h:3872
#define GetClassName
Definition: winuser.h:5783
char TCHAR
Definition: xmlstorage.h:189
const CHAR * LPCTSTR
Definition: xmlstorage.h:193

Referenced by WinMain().

◆ ExitInstance()

void ExitInstance ( void  )

Definition at line 213 of file main.c.

214{
216}
HMENU hMenuFrame
Definition: main.c:37
BOOL WINAPI DestroyMenu(_In_ HMENU)

Referenced by WinMain(), and wWinMain().

◆ InitInstance()

BOOL InitInstance ( HINSTANCE  hInstance,
int  nCmdShow 
)

Definition at line 62 of file main.c.

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}
#define IDC_STATUSBAR
Definition: resource.h:12
LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: childwnd.c:313
LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: framewnd.c:1385
HWND hFrameWnd
Definition: main.c:35
WCHAR szFrameClass[MAX_LOADSTRING]
Definition: main.c:44
WCHAR szTitle[MAX_LOADSTRING]
Definition: main.c:43
WCHAR szChildClass[MAX_LOADSTRING]
Definition: main.c:45
HWND hStatusBar
Definition: main.c:36
HFONT hFont
Definition: main.c:53
#define ID_WINDOW_CASCADE
Definition: resource.h:76
HINSTANCE hInstance
Definition: charmap.c:19
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:893
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:929
WORD ATOM
Definition: dimm.idl:113
#define NULL
Definition: types.h:112
#define ID_WINDOW_TILE_VERT
Definition: resource.h:49
#define ID_WINDOW_TILE_HORZ
Definition: resource.h:48
HACCEL hAccel
Definition: main.c:47
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 ID_WINDOW_NEW_WINDOW
Definition: resource.h:44
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
static HICON
Definition: imagelist.c:84
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:1933
#define SBT_NOBORDERS
Definition: commctrl.h:1971
#define TBSTYLE_BUTTON
Definition: commctrl.h:981
#define TBSTYLE_SEP
Definition: commctrl.h:982
#define TBSTATE_ENABLED
Definition: commctrl.h:974
#define SB_SETPARTS
Definition: commctrl.h:1954
#define ICC_BAR_CLASSES
Definition: commctrl.h:60
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define _T(x)
Definition: vfdio.h:22
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:5755
#define MF_BYCOMMAND
Definition: winuser.h:202
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define IMAGE_ICON
Definition: winuser.h:212
#define CS_HREDRAW
Definition: winuser.h:653
#define IDC_ARROW
Definition: winuser.h:687
#define SM_CYSMICON
Definition: winuser.h:1013
#define MF_CHECKED
Definition: winuser.h:132
#define CS_DBLCLKS
Definition: winuser.h:651
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define SM_CXSMICON
Definition: winuser.h:1012
#define RegisterClassEx
Definition: winuser.h:5837
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define LoadIcon
Definition: winuser.h:5813
BOOL WINAPI UpdateWindow(_In_ HWND)
#define SendMessage
Definition: winuser.h:5843
#define LoadCursor
Definition: winuser.h:5812
WNDCLASSEXA WNDCLASSEX
Definition: winuser.h:5719
HDC WINAPI GetDC(_In_opt_ HWND)
#define LR_SHARED
Definition: winuser.h:1100
#define LoadMenu
Definition: winuser.h:5817
#define CW_USEDEFAULT
Definition: winuser.h:225
#define LoadImage
Definition: winuser.h:5815
#define RegisterClass
Definition: winuser.h:5836
#define CS_CLASSDC
Definition: winuser.h:650
#define MAKEINTRESOURCE
Definition: winuser.h:591
int WINAPI GetSystemMetrics(_In_ int)
#define LoadAccelerators
Definition: winuser.h:5810
#define MF_GRAYED
Definition: winuser.h:129
#define IDB_TOOLBAR
Definition: wordpad.h:183
#define IDC_TOOLBAR
Definition: wordpad.h:157

◆ UpdateStatusBar()

void UpdateStatusBar ( void  )

Definition at line 182 of file main.c.

183{
184 TCHAR text[260];
185 DWORD size;
186
187 size = sizeof(text)/sizeof(TCHAR);
190 size = sizeof(text)/sizeof(TCHAR);
193}
const WCHAR * text
Definition: package.c:1799
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizeiptr size
Definition: glext.h:5919
#define SB_SETTEXT
Definition: commctrl.h:1949
#define GetUserName
Definition: winbase.h:3851
#define GetComputerName
Definition: winbase.h:3800

Referenced by InitInstance().

◆ WinMain()

int APIENTRY WinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPSTR  lpCmdLine,
int  nCmdShow 
)

Definition at line 219 of file main.c.

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
#define IDS_APP_TITLE
Definition: resource.h:10
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
Definition: main.c:61
HINSTANCE hInst
Definition: dxdiag.c:13
#define MAX_LOADSTRING
Definition: fontview.h:3
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
#define IDC_MDI_APP_CHILD
Definition: resource.h:17
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define GetMessage
Definition: winuser.h:5790
BOOL WINAPI TranslateMDISysAccel(_In_ HWND, _In_ LPMSG)
BOOL WINAPI EnumWindows(_In_ WNDENUMPROC lpEnumFunc, _In_ LPARAM lParam)
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
#define LoadString
Definition: winuser.h:5819
#define DispatchMessage
Definition: winuser.h:5765
#define GW_CHILD
Definition: winuser.h:763
#define TranslateAccelerator
Definition: winuser.h:5860

Variable Documentation

◆ g_foundPrevInstance

int g_foundPrevInstance = 0
static

Definition at line 196 of file main.c.

Referenced by EnumWndProc(), and WinMain().

◆ hAccel

◆ hFont

HFONT hFont

Definition at line 53 of file main.c.

◆ hFrameWnd

HWND hFrameWnd

Definition at line 48 of file main.c.

◆ hInst

HINSTANCE hInst

Definition at line 46 of file main.c.

◆ hMDIClient

HWND hMDIClient

◆ hMenuFrame

HMENU hMenuFrame

Definition at line 50 of file main.c.

◆ hStatusBar

HWND hStatusBar

Definition at line 51 of file main.c.

◆ hToolBar

HWND hToolBar

Definition at line 52 of file main.c.

Referenced by InitInstance().

◆ szChildClass

TCHAR szChildClass[MAX_LOADSTRING]

Definition at line 57 of file main.c.

◆ szFrameClass

TCHAR szFrameClass[MAX_LOADSTRING]

Definition at line 56 of file main.c.

◆ szTitle

Definition at line 55 of file main.c.