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

Referenced by WinMain().

◆ ExitInstance()

void ExitInstance ( void  )

Definition at line 213 of file main.c.

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

◆ 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*/,
70  hInstance,
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*/,
86  hInstance,
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 
117  INITCOMMONCONTROLSEX icc = {
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
159  "", hFrameWnd, IDC_STATUSBAR);
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);
176  UpdateStatusBar();
177  return TRUE;
178 }
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: childwnd.c:385
#define MAKEINTRESOURCE
Definition: winuser.h:591
static HICON
Definition: imagelist.c:84
#define TRUE
Definition: types.h:120
HWND hToolBar
Definition: main.c:52
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define LR_SHARED
Definition: winuser.h:1090
#define IMAGE_ICON
Definition: winuser.h:212
#define IDC_STATUSBAR
Definition: resource.h:14
#define RegisterClassEx
Definition: winuser.h:5812
#define MF_BYCOMMAND
Definition: winuser.h:202
#define ID_OPTIONS_TOOLBAR
Definition: resource.h:40
HDC WINAPI GetDC(_In_opt_ HWND)
WORD ATOM
Definition: dimm.idl:113
#define TBSTYLE_SEP
Definition: commctrl.h:978
#define IDC_MDI_APP
Definition: resource.h:16
static HDC
Definition: imagelist.c:92
WCHAR szTitle[MAX_LOADSTRING]
Definition: main.c:38
BOOL WINAPI UpdateWindow(_In_ HWND)
#define CS_HREDRAW
Definition: winuser.h:648
#define SM_CYSMICON
Definition: winuser.h:1003
#define ID_WINDOW_TILE_VERT
Definition: resource.h:49
#define WS_CHILD
Definition: pedump.c:617
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define WS_CLIPCHILDREN
Definition: pedump.c:619
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
struct tagINITCOMMONCONTROLSEX INITCOMMONCONTROLSEX
void UpdateStatusBar(void)
Definition: main.c:182
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define LoadAccelerators
Definition: winuser.h:5785
HACCEL hAccel
Definition: main.c:47
#define CreateStatusWindow
Definition: commctrl.h:1929
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define ID_OPTIONS_MENU
Definition: resource.h:8
#define CreateWindowEx
Definition: winuser.h:5730
#define CW_USEDEFAULT
Definition: winuser.h:225
#define CreateFont
Definition: wingdi.h:4442
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
HWND hStatusBar
Definition: main.c:31
#define ID_WINDOW_CASCADE
Definition: resource.h:79
#define MF_CHECKED
Definition: winuser.h:132
#define CS_VREDRAW
Definition: winuser.h:653
#define ICC_BAR_CLASSES
Definition: commctrl.h:60
#define _T(x)
Definition: vfdio.h:22
WCHAR szFrameClass[MAX_LOADSTRING]
Definition: main.c:39
int WINAPI GetSystemMetrics(_In_ int)
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define IDC_TOOLBAR
Definition: wordpad.h:157
HINSTANCE hInstance
Definition: main.c:36
#define SM_CXSMICON
Definition: winuser.h:1002
#define ID_WINDOW_TILE_HORZ
Definition: resource.h:48
HDC hdc
Definition: main.c:9
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:893
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
WCHAR szChildClass[MAX_LOADSTRING]
Definition: main.c:40
#define CS_DBLCLKS
Definition: winuser.h:646
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define LoadCursor
Definition: winuser.h:5787
#define CS_CLASSDC
Definition: winuser.h:645
HWND hFrameWnd
Definition: main.c:30
HMENU hMenuFrame
Definition: main.c:32
#define LoadMenu
Definition: winuser.h:5792
LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: framewnd.c:1304
#define ID_OPTIONS_STATUSBAR
Definition: resource.h:41
#define SB_SETPARTS
Definition: commctrl.h:1950
#define IDC_ARROW
Definition: winuser.h:682
#define SendMessage
Definition: winuser.h:5818
#define TBSTATE_ENABLED
Definition: commctrl.h:970
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define LOGPIXELSY
Definition: wingdi.h:718
#define IDB_TOOLBAR
Definition: wordpad.h:183
#define LoadImage
Definition: winuser.h:5790
#define RegisterClass
Definition: winuser.h:5811
WNDCLASSEXA WNDCLASSEX
Definition: winuser.h:5694
#define LoadIcon
Definition: winuser.h:5788
#define MF_GRAYED
Definition: winuser.h:129
#define ID_WINDOW_NEW_WINDOW
Definition: resource.h:44
#define WS_VISIBLE
Definition: pedump.c:620
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define SBT_NOBORDERS
Definition: commctrl.h:1967
#define MulDiv(x, y, z)
Definition: gdifloat.h:86
#define TBSTYLE_BUTTON
Definition: commctrl.h:977
#define IDI_MDI_APP
Definition: resource.h:14
HFONT hFont
Definition: main.c:53

◆ 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);
188  GetUserName(text, &size);
190  size = sizeof(text)/sizeof(TCHAR);
193 }
#define GetUserName
Definition: winbase.h:3685
const WCHAR * text
Definition: package.c:1827
#define GetComputerName
Definition: winbase.h:3634
LONG_PTR LPARAM
Definition: windef.h:208
HWND hStatusBar
Definition: main.c:31
char TCHAR
Definition: xmlstorage.h:189
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SB_SETTEXT
Definition: commctrl.h:1945
#define SendMessage
Definition: winuser.h:5818

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
239  hInst = hInstance;
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 TranslateAccelerator
Definition: winuser.h:5835
#define MAX_LOADSTRING
Definition: main.c:37
#define DispatchMessage
Definition: winuser.h:5740
BOOL WINAPI TranslateMessage(_In_ const MSG *)
void ExitInstance(HINSTANCE hInstance)
Definition: main.c:164
#define GW_CHILD
Definition: winuser.h:758
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define IDC_MDI_APP
Definition: resource.h:16
WCHAR szTitle[MAX_LOADSTRING]
Definition: main.c:38
#define IDC_MDI_APP_CHILD
Definition: resource.h:17
HINSTANCE hInst
Definition: main.c:29
HACCEL hAccel
Definition: main.c:47
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
WCHAR szFrameClass[MAX_LOADSTRING]
Definition: main.c:39
static int g_foundPrevInstance
Definition: main.c:196
BOOL WINAPI EnumWindows(_In_ WNDENUMPROC, _In_ LPARAM)
HINSTANCE hInstance
Definition: main.c:36
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
WCHAR szChildClass[MAX_LOADSTRING]
Definition: main.c:40
HWND hFrameWnd
Definition: main.c:30
#define IDS_APP_TITLE
Definition: resource.h:10
#define GetMessage
Definition: winuser.h:5765
#define msg(x)
Definition: auth_time.c:54
static BOOL CALLBACK EnumWndProc(HWND hWnd, LPARAM lParam)
Definition: main.c:199
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
Definition: main.c:56
#define LoadString
Definition: winuser.h:5794
BOOL WINAPI TranslateMDISysAccel(_In_ HWND, _In_ LPMSG)
HWND hMDIClient
Definition: main.c:49

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.

Referenced by add_ruler_units(), AddCharToSelection(), AddDialogControl(), BUTTON_CalcLabelRect(), CB_Paint(), check_height_font_enumproc(), ChildWndProc(), COMBO_Font(), COMCTL32_GetFontMetrics(), CreateFontset(), CreateLayoutIcon(), CreateMonospaceFont(), CreateTitleFont(), CreateTrayIcon(), DlgProc(), DoEntry(), DrawCaptionTempA(), DrawCaptionTempW(), DrawProc(), DrawThemeText(), DRIVER_SelectFont(), DumpFont(), EditTypeDlg_OnDrawItem(), EMFDRV_CreateFontIndirect(), EMFDRV_SelectFont(), EnumEnhMetaFile(), EnumMetaFile(), FillFontSizeComboList(), FillFontStyleComboList(), fnIMLangFontLink2_ReleaseFont(), fnIMLangFontLink_ReleaseFont(), font_height(), FontSizeChange(), ftGdiGetGlyphOutline(), ftGdiGetTextCharsetInfo(), GB_Paint(), GetButtonHeight(), GetFontCellSize(), GetFontMetrics(), GetThemeTextExtent(), GetThemeTextMetrics(), HEADER_CreateDragImage(), HEADER_Refresh(), HEADER_SetFont(), HEXEDIT_WM_SETFONT(), HOTKEY_SetFont(), InitFonts(), InitInstance(), IPADDRESS_Create(), LISTVIEW_Command(), LISTVIEW_GetItemMetrics(), LISTVIEW_GetStringWidthT(), LISTVIEW_SaveTextMetrics(), LISTVIEW_SetFont(), LISTVIEW_ShowFocusRect(), LoadIniFile(), LrgCellWndProc(), MainFrameBase::MainFrameBase(), MainWndProc(), ME_DebugWrite(), MENU_DrawPopupGlyph(), MFDRV_CreateFontIndirect(), MonSelChangeFont(), MonSelGetMonitorFont(), MonSelPaintMonitor(), MONTHCAL_SetFont(), MonthCalChangeFont(), msi_dialog_get_sans_serif_height(), MyDrawCaptionTemp(), MyDrawFrameCaption(), MyDrawFrameScroll(), MyEnumFontFamExProc(), NOTEPAD_LoadSettingsFromRegistry(), NT5_DrawLogoffCaptionText(), NtGdiGetCharABCWidthsW(), NtGdiGetCharWidthW(), NtGdiGetFontData(), NtGdiGetFontUnicodeRanges(), NtGdiGetGlyphIndicesW(), NtGdiGetOutlineTextMetricsInternalW(), NtGdiGetTextFaceW(), NtUserDrawCaptionTemp(), NtUserDrawMenuBarTemp(), OB_Paint(), OnMeasureItem(), PB_Paint(), PlotCharacter(), PROGRESS_SetFont(), RealizeFontInit(), RetChangeControlFont(), RosImageProc(), ATL::CWindow::SetFont(), SetLrgFont(), SetMessageFont(), SetupControls(), SoftModalMessageBox(), START_TEST(), STATIC_PaintTextfn(), SYSLINK_SetFont(), test_bitmap_font_glyph_index(), test_combo_setfont(), Test_CreateFontA(), Test_CreateFontIndirectA(), Test_CreateFontIndirectExA(), Test_CreateFontIndirectExW(), Test_CreateFontIndirectW(), test_DrawTextCalcRect(), test_emf_ExtTextOut_on_path(), test_ExtTextOut(), Test_Font(), Test_FontSelectionEntry(), Test_GdiGetCharDimensions(), Test_GetTextFaceAliasW(), test_height(), test_MessageBoxFontTest(), test_mf_SaveDC(), test_SaveDC(), test_setfont(), ThemeDrawCaptionText(), TOOLBAR_SetFont(), TOOLTIPS_SetFont(), TreeListEditLabel(), TreeListProc(), TREEVIEW_Command(), TREEVIEW_SetFont(), UB_Paint(), UITOOLS95_DFC_ButtonCheckRadio(), UITOOLS95_DrawFrameCaption(), UITOOLS95_DrawFrameMenu(), UITOOLS95_DrawFrameScroll(), UpdateFontPreview(), UserDrawCaption(), UserDrawCaptionText(), and WndProc().

◆ 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

◆ 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.