ReactOS 0.4.16-dev-297-gc569aee
mainwnd.c File Reference
#include "precomp.h"
Include dependency graph for mainwnd.c:

Go to the source code of this file.

Functions

static VOID InitResources (IN PMAIN_WND_INFO Info)
 
static VOID UnInitResources (IN PMAIN_WND_INFO Info)
 
static VOID AddToolbarButton (IN PMAIN_WND_INFO Info, IN INT iBitmap, IN INT idCommand, IN UINT uID)
 
static VOID SetToolbarButtonState (IN PMAIN_WND_INFO Info, INT idCommand, BOOL bEnabled)
 
VOID SetToolbarFileButtonState (IN PMAIN_WND_INFO Info, BOOL bEnabled)
 
static VOID AddToolbarSeparator (IN PMAIN_WND_INFO Info)
 
static VOID InitMainWnd (IN PMAIN_WND_INFO Info)
 
static VOID InitMenuPopup (IN PMAIN_WND_INFO Info)
 
static VOID OutOfMemory (IN PMAIN_WND_INFO Info)
 
static PFONT_OPEN_INFO CreateOpenInfo (IN PMAIN_WND_INFO Info, BOOL bCreateNew, LPCWSTR File)
 
static VOID DoFileNew (IN PMAIN_WND_INFO Info)
 
static VOID DoFileOpen (IN PMAIN_WND_INFO Info)
 
static VOID MainWndOpenFile (IN PMAIN_WND_INFO Info, LPCWSTR File)
 
static VOID MainWndDropFiles (IN PMAIN_WND_INFO Info, HDROP hDrop)
 
VOID DoFileSave (IN PMAIN_WND_INFO Info, IN BOOL bSaveAs)
 
static VOID CopyCurrentGlyph (IN PFONT_WND_INFO FontWndInfo)
 
static VOID PasteIntoCurrentGlyph (IN PFONT_WND_INFO FontWndInfo)
 
VOID SetPasteButtonState (IN PMAIN_WND_INFO Info)
 
static BOOL MenuCommand (IN INT nMenuItemID, IN PMAIN_WND_INFO Info)
 
static VOID MainWndSize (PMAIN_WND_INFO Info, INT cx, INT cy)
 
static LRESULT CALLBACK MainWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
BOOL CreateMainWindow (IN INT nCmdShow, OUT PMAIN_WND_INFO *Info)
 
BOOL InitMainWndClass (VOID)
 
VOID UnInitMainWndClass (VOID)
 

Variables

static const WCHAR szMainWndClass [] = L"VGAFontEditMainWndClass"
 

Function Documentation

◆ AddToolbarButton()

static VOID AddToolbarButton ( IN PMAIN_WND_INFO  Info,
IN INT  iBitmap,
IN INT  idCommand,
IN UINT  uID 
)
static

Definition at line 62 of file mainwnd.c.

63{
64 PWSTR pszTooltip;
65 TBBUTTON tbb = {0,};
66
67 if( AllocAndLoadString(&pszTooltip, uID) )
68 {
70 tbb.iBitmap = iBitmap;
71 tbb.idCommand = idCommand;
72 tbb.iString = (INT_PTR)pszTooltip;
73
74 SendMessageW( Info->hToolbar, TB_ADDBUTTONSW, 1, (LPARAM)&tbb );
75 HeapFree(hProcessHeap, 0, pszTooltip);
76 }
77}
INT AllocAndLoadString(OUT LPTSTR *lpTarget, IN HINSTANCE hInst, IN UINT uID)
Definition: misc.c:59
#define HeapFree(x, y, z)
Definition: compat.h:735
HANDLE hProcessHeap
Definition: kbswitch.c:37
#define TBSTATE_ENABLED
Definition: commctrl.h:974
#define TB_ADDBUTTONSW
Definition: commctrl.h:1266
BYTE fsState
Definition: commctrl.h:951
INT_PTR iString
Definition: commctrl.h:959
int idCommand
Definition: commctrl.h:950
int iBitmap
Definition: commctrl.h:949
uint16_t * PWSTR
Definition: typedefs.h:56
int32_t INT_PTR
Definition: typedefs.h:64
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
LONG_PTR LPARAM
Definition: windef.h:208
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by InitMainWnd().

◆ AddToolbarSeparator()

static VOID AddToolbarSeparator ( IN PMAIN_WND_INFO  Info)
static

Definition at line 100 of file mainwnd.c.

101{
102 TBBUTTON tbb = {0,};
103
104 tbb.fsStyle = BTNS_SEP;
105
106 SendMessageW( Info->hToolbar, TB_ADDBUTTONSW, 1, (LPARAM)&tbb );
107}
#define BTNS_SEP
Definition: commctrl.h:999
BYTE fsStyle
Definition: commctrl.h:952

Referenced by InitMainWnd().

◆ CopyCurrentGlyph()

static VOID CopyCurrentGlyph ( IN PFONT_WND_INFO  FontWndInfo)
static

Definition at line 331 of file mainwnd.c.

332{
333 HGLOBAL hMem;
334 PUCHAR pCharacterBits;
335
336 if(!OpenClipboard(NULL))
337 return;
338
340
341 hMem = GlobalAlloc(GMEM_MOVEABLE, 8);
342 pCharacterBits = GlobalLock(hMem);
343 RtlCopyMemory(pCharacterBits, FontWndInfo->Font->Bits + FontWndInfo->uSelectedCharacter * 8, 8);
344 GlobalUnlock(hMem);
345
347
349}
#define NULL
Definition: types.h:112
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
UINT uCharacterClipboardFormat
Definition: main.c:15
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
unsigned char * PUCHAR
Definition: typedefs.h:53
#define GMEM_MOVEABLE
Definition: winbase.h:320
HANDLE WINAPI SetClipboardData(_In_ UINT, _In_opt_ HANDLE)
BOOL WINAPI CloseClipboard(void)
Definition: ntwrapper.h:178
BOOL WINAPI OpenClipboard(_In_opt_ HWND)
BOOL WINAPI EmptyClipboard(void)
Definition: ntwrapper.h:190

Referenced by MenuCommand().

◆ CreateMainWindow()

BOOL CreateMainWindow ( IN INT  nCmdShow,
OUT PMAIN_WND_INFO Info 
)

Definition at line 608 of file mainwnd.c.

609{
611
613
614 if(*Info)
615 {
616 (*Info)->nCmdShow = nCmdShow;
617
620 szAppName,
626 NULL,
628 hInstance,
629 *Info);
630
631 if(hMainWnd)
632 return TRUE;
633 else
635 }
636
637 return FALSE;
638}
static const WCHAR szMainWndClass[]
Definition: mainwnd.c:15
struct _MAIN_WND_INFO * PMAIN_WND_INFO
#define IDM_MAINMENU
Definition: resources.h:3
HINSTANCE hInstance
Definition: charmap.c:19
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
HWND hMainWnd
Definition: magnifier.c:32
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define WS_CLIPCHILDREN
Definition: pedump.c:619
TCHAR szAppName[128]
Definition: solitaire.cpp:18
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define CW_USEDEFAULT
Definition: winuser.h:225
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HMENU WINAPI LoadMenuW(_In_opt_ HINSTANCE, _In_ LPCWSTR)

◆ CreateOpenInfo()

static PFONT_OPEN_INFO CreateOpenInfo ( IN PMAIN_WND_INFO  Info,
BOOL  bCreateNew,
LPCWSTR  File 
)
static

Definition at line 205 of file mainwnd.c.

206{
207 PFONT_OPEN_INFO OpenInfo;
208
210 if (!OpenInfo)
211 {
213 return NULL;
214 }
215
216 OpenInfo->bCreateNew = bCreateNew;
218 if (!OpenInfo->pszFileName)
219 {
221 HeapFree(hProcessHeap, 0, OpenInfo);
222 return NULL;
223 }
224
225 if (StringCchCopyW(OpenInfo->pszFileName, MAX_PATH, File) != S_OK)
226 {
227 MessageBoxW(Info->hMainWnd, L"Pathname is too long!", NULL, MB_ICONERROR);
228 HeapFree(hProcessHeap, 0, OpenInfo->pszFileName);
229 HeapFree(hProcessHeap, 0, OpenInfo);
230 return NULL;
231 }
232
233 return OpenInfo;
234}
Definition: File.h:16
#define MAX_PATH
Definition: compat.h:34
@ OutOfMemory
Definition: gdiplustypes.h:29
#define S_OK
Definition: intsafe.h:52
#define L(x)
Definition: ntvdm.h:50
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
PWSTR pszFileName
Definition: precomp.h:61
BOOL bCreateNew
Definition: precomp.h:58
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MB_ICONERROR
Definition: winuser.h:790

Referenced by DoFileNew(), DoFileOpen(), and MainWndOpenFile().

◆ DoFileNew()

static VOID DoFileNew ( IN PMAIN_WND_INFO  Info)
static

Definition at line 237 of file mainwnd.c.

238{
239 PFONT_OPEN_INFO OpenInfo = CreateOpenInfo(Info, TRUE, L"");
240 if (!OpenInfo)
241 return;
242
243 CreateFontWindow(Info, OpenInfo);
244}
BOOL CreateFontWindow(IN PMAIN_WND_INFO MainWndInfo, IN PFONT_OPEN_INFO OpenInfo)
Definition: fontwnd.c:363
static PFONT_OPEN_INFO CreateOpenInfo(IN PMAIN_WND_INFO Info, BOOL bCreateNew, LPCWSTR File)
Definition: mainwnd.c:205

Referenced by MenuCommand().

◆ DoFileOpen()

static VOID DoFileOpen ( IN PMAIN_WND_INFO  Info)
static

Definition at line 247 of file mainwnd.c.

248{
249 PFONT_OPEN_INFO OpenInfo = CreateOpenInfo(Info, FALSE, L"");
250 if (!OpenInfo)
251 return;
252
253 if (DoOpenFile(OpenInfo->pszFileName))
254 {
255 CreateFontWindow(Info, OpenInfo);
256 return;
257 }
258
259 HeapFree(hProcessHeap, 0, OpenInfo->pszFileName);
260 HeapFree(hProcessHeap, 0, OpenInfo);
261}
static VOID DoOpenFile(PINFO pInfo)
Definition: connectdialog.c:34

Referenced by MenuCommand().

◆ DoFileSave()

VOID DoFileSave ( IN PMAIN_WND_INFO  Info,
IN BOOL  bSaveAs 
)

Definition at line 289 of file mainwnd.c.

290{
291 DWORD dwBytesWritten;
293
294 // Show the "Save" dialog
295 // - if "Save As" was clicked
296 // - if the file was not yet saved
297 // - if another format than the binary format was opened
298 if(bSaveAs || !Info->CurrentFontWnd->OpenInfo->bBinaryFileOpened)
299 {
300 if(!Info->CurrentFontWnd->OpenInfo->pszFileName)
301 {
302 Info->CurrentFontWnd->OpenInfo->pszFileName = (PWSTR) HeapAlloc(hProcessHeap, 0, MAX_PATH);
303 Info->CurrentFontWnd->OpenInfo->pszFileName[0] = 0;
304 }
305 else if(!Info->CurrentFontWnd->OpenInfo->bBinaryFileOpened)
306 {
307 // For a file in another format, the user has to enter a new file name as well
308 Info->CurrentFontWnd->OpenInfo->pszFileName[0] = 0;
309 }
310
311 if( !DoSaveFile(Info->CurrentFontWnd->OpenInfo->pszFileName) )
312 return;
313 }
314
315 // Save the binary font
316 hFile = CreateFileW(Info->CurrentFontWnd->OpenInfo->pszFileName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
317
319 {
321 return;
322 }
323
324 if( !WriteFile(hFile, Info->CurrentFontWnd->Font, sizeof(BITMAP_FONT), &dwBytesWritten, NULL) )
326
328}
static BOOL DoSaveFile(HWND hWnd, PCONSOLE_CHILDFRM_WND pChildInfo)
Definition: console.c:208
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
unsigned long DWORD
Definition: ntddk_ex.h:95
VOID LocalizedError(IN UINT uID,...)
Definition: misc.c:103
#define IDS_OPENERROR
Definition: resource.h:61
#define IDS_WRITEERROR
Definition: resource.h:63
#define OPEN_ALWAYS
Definition: disk.h:70
_In_ HANDLE hFile
Definition: mswsock.h:90
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define GENERIC_WRITE
Definition: nt_native.h:90
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by FontWndProc(), and MenuCommand().

◆ InitMainWnd()

static VOID InitMainWnd ( IN PMAIN_WND_INFO  Info)
static

Definition at line 110 of file mainwnd.c.

111{
113 INT iCustomBitmaps;
114 INT iStandardBitmaps;
115 TBADDBITMAP tbab;
116
117 // Add the toolbar
118 Info->hToolbar = CreateWindowExW(0,
120 NULL,
122 0,
123 0,
124 0,
125 0,
126 Info->hMainWnd,
127 NULL,
128 hInstance,
129 NULL);
130
131 // Identify the used Common Controls version
132 SendMessageW(Info->hToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
133
134 // Enable Tooltips
135 SendMessageW(Info->hToolbar, TB_SETMAXTEXTROWS, 0, 0);
136
137 // Add the toolbar bitmaps
138 tbab.hInst = HINST_COMMCTRL;
140 iStandardBitmaps = (INT)SendMessageW(Info->hToolbar, TB_ADDBITMAP, 0, (LPARAM)&tbab);
141
142 tbab.hInst = hInstance;
143 tbab.nID = IDB_MAIN_TOOLBAR;
144 iCustomBitmaps = (INT)SendMessageW(Info->hToolbar, TB_ADDBITMAP, 0, (LPARAM)&tbab);
145
146 // Add the toolbar buttons
155
158
159 // Add the MDI client area
160 ccs.hWindowMenu = GetSubMenu(Info->hMenu, 2);
162
164 L"MDICLIENT",
165 NULL,
167 0,
168 0,
169 0,
170 0,
171 Info->hMainWnd,
172 NULL,
173 hInstance,
174 &ccs);
175
176 // Initialize the file handling
177 FileInitialize(Info->hMainWnd);
178}
VOID FileInitialize(IN HWND hwnd)
Definition: opensave.c:13
#define ID_EDIT_COPY
Definition: resource.h:48
#define ID_EDIT_PASTE
Definition: resource.h:49
#define ID_FILE_OPEN
Definition: resource.h:41
#define ID_FILE_NEW
Definition: resource.h:40
#define ID_FILE_SAVE
Definition: resource.h:42
VOID SetPasteButtonState(IN PMAIN_WND_INFO Info)
Definition: mainwnd.c:389
VOID SetToolbarFileButtonState(IN PMAIN_WND_INFO Info, BOOL bEnabled)
Definition: mainwnd.c:92
static VOID AddToolbarButton(IN PMAIN_WND_INFO Info, IN INT iBitmap, IN INT idCommand, IN UINT uID)
Definition: mainwnd.c:62
static VOID AddToolbarSeparator(IN PMAIN_WND_INFO Info)
Definition: mainwnd.c:100
#define ID_MDI_FIRSTCHILD
Definition: precomp.h:97
#define TOOLBAR_EDIT_GLYPH
Definition: precomp.h:118
#define IDS_TOOLTIP_EDIT_GLYPH
Definition: resource.h:74
#define IDS_TOOLTIP_PASTE
Definition: resource.h:76
#define ID_EDIT_GLYPH
Definition: resource.h:44
#define IDB_MAIN_TOOLBAR
Definition: resource.h:24
#define IDS_TOOLTIP_COPY
Definition: resource.h:75
#define IDS_TOOLTIP_SAVE
Definition: resource.h:73
#define IDS_TOOLTIP_NEW
Definition: resource.h:71
#define IDS_TOOLTIP_OPEN
Definition: resource.h:72
#define WS_CHILD
Definition: pedump.c:617
#define WS_VSCROLL
Definition: pedump.c:627
#define WS_VISIBLE
Definition: pedump.c:620
#define WS_HSCROLL
Definition: pedump.c:628
#define INT
Definition: polytest.cpp:20
#define STD_COPY
Definition: commctrl.h:1072
#define STD_FILENEW
Definition: commctrl.h:1077
#define TBSTYLE_TOOLTIPS
Definition: commctrl.h:989
#define HINST_COMMCTRL
Definition: commctrl.h:1063
#define STD_PASTE
Definition: commctrl.h:1073
#define TB_BUTTONSTRUCTSIZE
Definition: commctrl.h:1134
#define STD_FILEOPEN
Definition: commctrl.h:1078
#define STD_FILESAVE
Definition: commctrl.h:1079
#define TOOLBARCLASSNAMEW
Definition: commctrl.h:943
#define TB_SETMAXTEXTROWS
Definition: commctrl.h:1162
#define TB_ADDBITMAP
Definition: commctrl.h:1056
#define IDB_STD_SMALL_COLOR
Definition: commctrl.h:1064
UINT_PTR nID
Definition: commctrl.h:1060
HINSTANCE hInst
Definition: commctrl.h:1059
int32_t INT
Definition: typedefs.h:58
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384

◆ InitMainWndClass()

BOOL InitMainWndClass ( VOID  )

Definition at line 641 of file mainwnd.c.

642{
643 WNDCLASSW wc = {0,};
644
646 wc.hInstance = hInstance;
649 wc.hbrBackground = (HBRUSH)( COLOR_BTNFACE + 1 );
651
652 return RegisterClassW(&wc) != 0;
653}
#define IDI_MAIN
Definition: resource.h:4
static LRESULT CALLBACK MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: mainwnd.c:639
LPCWSTR lpszClassName
Definition: winuser.h:3188
HBRUSH hbrBackground
Definition: winuser.h:3186
HICON hIcon
Definition: winuser.h:3184
HINSTANCE hInstance
Definition: winuser.h:3183
WNDPROC lpfnWndProc
Definition: winuser.h:3180
HCURSOR hCursor
Definition: winuser.h:3185
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
#define IDC_ARROW
Definition: winuser.h:687
#define LoadCursor
Definition: winuser.h:5824
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2127
#define COLOR_BTNFACE
Definition: winuser.h:931

Referenced by wWinMain().

◆ InitMenuPopup()

static VOID InitMenuPopup ( IN PMAIN_WND_INFO  Info)
static

Definition at line 181 of file mainwnd.c.

182{
183 UINT uState;
184
185 uState = MF_BYCOMMAND | !(Info->CurrentFontWnd);
186
187 EnableMenuItem(Info->hMenu, ID_FILE_CLOSE, uState);
188 EnableMenuItem(Info->hMenu, ID_FILE_SAVE, uState);
189 EnableMenuItem(Info->hMenu, ID_FILE_SAVE_AS, uState);
190
191 EnableMenuItem(Info->hMenu, ID_EDIT_COPY, uState);
192 EnableMenuItem(Info->hMenu, ID_EDIT_GLYPH, uState);
193
195 EnableMenuItem(Info->hMenu, ID_EDIT_PASTE, uState);
196}
#define ID_FILE_SAVE_AS
Definition: resource.h:41
#define ID_FILE_CLOSE
Definition: resource.h:39
unsigned int UINT
Definition: ndis.h:50
#define MF_BYCOMMAND
Definition: winuser.h:202
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
BOOL WINAPI IsClipboardFormatAvailable(_In_ UINT)

Referenced by MainWndProc().

◆ InitResources()

static VOID InitResources ( IN PMAIN_WND_INFO  Info)
static

Definition at line 14 of file mainwnd.c.

15{
16 HDC hMemDC;
17 HDC hMainDC;
18 HPEN hPen, hPenOld;
19 RECT rect;
20 HBITMAP hBitmapOld;
21
22 hMemDC = CreateCompatibleDC(NULL);
23 hMainDC = GetDC(Info->hMainWnd);
24
25 // Create the "Box" bitmap
27 hBitmapOld = SelectObject(hMemDC, Info->hBoxBmp);
28
29 rect.left = 0;
30 rect.top = 0;
33 FillRect( hMemDC, &rect, (HBRUSH)(COLOR_BTNFACE + 1) );
34
35 hPenOld = SelectObject( hMemDC, GetStockObject(WHITE_PEN) );
36 Rectangle(hMemDC, 0, 0, CHARACTER_INFO_BOX_WIDTH - 1, 2);
37 Rectangle(hMemDC, 0, 2, 2, CHARACTER_INFO_BOX_HEIGHT - 1);
38 hPen = SelectObject(hMemDC, hPenOld);
39
40 hPen = CreatePen( PS_SOLID, 1, RGB(128, 128, 128) );
41 hPenOld = SelectObject(hMemDC, hPen);
44
45 SetPixel( hMemDC, CHARACTER_INFO_BOX_WIDTH - 1, 0, RGB(128, 128, 128) );
46 SetPixel( hMemDC, 0, CHARACTER_INFO_BOX_HEIGHT - 1, RGB(128, 128, 128) );
47 SelectObject(hMemDC, hBitmapOld);
48
49 hPen = SelectObject(hMemDC, hPenOld);
50 DeleteObject(hPen);
51 DeleteDC(hMemDC);
52 ReleaseDC(Info->hMainWnd, hMainDC);
53}
FORCEINLINE VOID SetPixel(_In_ ULONG Left, _In_ ULONG Top, _In_ UCHAR Color)
Definition: arm.h:55
#define RGB(r, g, b)
Definition: precomp.h:71
pKey DeleteObject()
#define CHARACTER_BOX_WIDTH
Definition: precomp.h:103
#define CHARACTER_INFO_BOX_WIDTH
Definition: precomp.h:100
#define CHARACTER_INFO_BOX_HEIGHT
Definition: precomp.h:101
#define CHARACTER_BOX_HEIGHT
Definition: precomp.h:104
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
& rect
Definition: startmenu.cpp:1413
HGDIOBJ WINAPI GetStockObject(_In_ int)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define WHITE_PEN
Definition: wingdi.h:905
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI DeleteDC(_In_ HDC)
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
#define PS_SOLID
Definition: wingdi.h:586
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)

Referenced by MainWndProc().

◆ MainWndDropFiles()

static VOID MainWndDropFiles ( IN PMAIN_WND_INFO  Info,
HDROP  hDrop 
)
static

Definition at line 274 of file mainwnd.c.

275{
277 INT i, Count = DragQueryFileW(hDrop, 0xFFFFFFFF, NULL, 0);
278
279 for (i = 0; i < Count; ++i)
280 {
281 DragQueryFileW(hDrop, i, Path, MAX_PATH);
283 }
284
285 DragFinish(hDrop);
286}
PRTL_UNICODE_STRING_BUFFER Path
void WINAPI DragFinish(HDROP h)
Definition: shellole.c:538
UINT WINAPI DragQueryFileW(HDROP hDrop, UINT lFile, LPWSTR lpszwFile, UINT lLength)
Definition: shellole.c:622
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static VOID MainWndOpenFile(IN PMAIN_WND_INFO Info, LPCWSTR File)
Definition: mainwnd.c:264
int Count
Definition: noreturn.cpp:7
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by MainWndProc().

◆ MainWndOpenFile()

static VOID MainWndOpenFile ( IN PMAIN_WND_INFO  Info,
LPCWSTR  File 
)
static

Definition at line 264 of file mainwnd.c.

265{
267 if (!OpenInfo)
268 return;
269
270 CreateFontWindow(Info, OpenInfo);
271}

Referenced by MainWndDropFiles(), and MainWndProc().

◆ MainWndProc()

static LRESULT CALLBACK MainWndProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 503 of file mainwnd.c.

504{
505 static HWND hNextClipboardViewer;
506 INT i;
508
510
511 if(Info || uMsg == WM_CREATE)
512 {
513 switch(uMsg)
514 {
515 case WM_COMMAND:
516 if( MenuCommand( LOWORD(wParam), Info ) )
517 return 0;
518
519 break;
520
521 case WM_CHANGECBCHAIN:
522 if((HWND)wParam == hNextClipboardViewer)
523 hNextClipboardViewer = (HWND)lParam;
524 else
525 SendMessage(hNextClipboardViewer, uMsg, wParam, lParam);
526
527 return 0;
528
529 case WM_CLOSE:
530 if(Info->FirstFontWnd)
531 {
532 // Send WM_CLOSE to all subwindows, so they can prompt for saving unsaved files
533 PFONT_WND_INFO pNextWnd;
534 PFONT_WND_INFO pWnd;
535
536 pWnd = Info->FirstFontWnd;
537
538 do
539 {
540 // The pWnd structure might already be destroyed after the WM_CLOSE, so we have to preserve the address of the next window here
541 pNextWnd = pWnd->NextFontWnd;
542
543 // Send WM_USER_APPCLOSE, so we can check for a custom return value
544 // In this case, we check if the user clicked the "Cancel" button in one of the prompts and if so, we don't close the app
545 if( !SendMessage(pWnd->hSelf, WM_USER_APPCLOSE, 0, 0) )
546 return 0;
547 }
548 while( (pWnd = pNextWnd) );
549 }
550 break;
551
552 case WM_CREATE:
553 Info = (PMAIN_WND_INFO)( ( (LPCREATESTRUCT)lParam )->lpCreateParams );
554 Info->hMainWnd = hwnd;
555 Info->hMenu = GetMenu(hwnd);
557
558 hNextClipboardViewer = SetClipboardViewer(hwnd);
559
562
563 ShowWindow(hwnd, Info->nCmdShow);
564
565 for (i = 1; i < __argc; ++i)
566 {
568 }
570 return 0;
571
572 case WM_DESTROY:
574
578 return 0;
579
580 case WM_DRAWCLIPBOARD:
582
583 // Pass the message to the next clipboard window in the chain
584 SendMessage(hNextClipboardViewer, uMsg, wParam, lParam);
585 return 0;
586
587 case WM_INITMENUPOPUP:
589 break;
590
591 case WM_SIZE:
593 return 0;
594
595 case WM_DROPFILES:
597 return 0;
598 }
599 }
600
601 if(Info && Info->hMdiClient)
602 return DefFrameProcW(hwnd, Info->hMdiClient, uMsg, wParam, lParam);
603 else
604 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
605}
static BOOL InitMainWnd(PMAIN_WND_INFO Info)
Definition: mainwnd.c:334
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
void WINAPI DragAcceptFiles(HWND hWnd, BOOL b)
Definition: shellole.c:522
_CRTIMP int __argc
Definition: getargs.c:21
_CRTIMP wchar_t ** __wargv
Definition: getargs.c:20
static VOID UnInitResources(IN PMAIN_WND_INFO Info)
Definition: mainwnd.c:56
static VOID MainWndDropFiles(IN PMAIN_WND_INFO Info, HDROP hDrop)
Definition: mainwnd.c:274
static VOID InitMenuPopup(IN PMAIN_WND_INFO Info)
Definition: mainwnd.c:181
static VOID InitResources(IN PMAIN_WND_INFO Info)
Definition: mainwnd.c:14
static BOOL MenuCommand(IN INT nMenuItemID, IN PMAIN_WND_INFO Info)
Definition: mainwnd.c:397
static VOID MainWndSize(PMAIN_WND_INFO Info, INT cx, INT cy)
Definition: mainwnd.c:470
#define WM_USER_APPCLOSE
Definition: precomp.h:115
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define LOWORD(l)
Definition: pedump.c:82
PFONT_WND_INFO NextFontWnd
Definition: precomp.h:75
HWND hSelf
Definition: precomp.h:70
#define GWLP_USERDATA
Definition: treelist.c:63
#define HIWORD(l)
Definition: typedefs.h:247
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LRESULT WINAPI DefFrameProcW(_In_ HWND, _In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_CLOSE
Definition: winuser.h:1624
#define GetWindowLongPtrW
Definition: winuser.h:4832
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_CREATE
Definition: winuser.h:1611
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_DRAWCLIPBOARD
Definition: winuser.h:1872
#define WM_SIZE
Definition: winuser.h:1614
#define WM_DROPFILES
Definition: winuser.h:1828
#define WM_COMMAND
Definition: winuser.h:1743
#define WM_CHANGECBCHAIN
Definition: winuser.h:1877
HWND WINAPI SetClipboardViewer(_In_ HWND)
#define WM_INITMENUPOPUP
Definition: winuser.h:1749
#define SendMessage
Definition: winuser.h:5855
#define WM_DESTROY
Definition: winuser.h:1612
#define SetWindowLongPtrW
Definition: winuser.h:5358
HMENU WINAPI GetMenu(_In_ HWND)

◆ MainWndSize()

static VOID MainWndSize ( PMAIN_WND_INFO  Info,
INT  cx,
INT  cy 
)
static

Definition at line 470 of file mainwnd.c.

471{
472 HDWP dwp;
473 INT iMdiTop;
474 RECT ToolbarRect;
475
476 iMdiTop = 0;
477
478 dwp = BeginDeferWindowPos(2);
479 if(!dwp)
480 return;
481
482 if(Info->hToolbar)
483 {
484 GetWindowRect(Info->hToolbar, &ToolbarRect);
485 iMdiTop += ToolbarRect.bottom - ToolbarRect.top;
486
487 dwp = DeferWindowPos(dwp, Info->hToolbar, NULL, 0, 0, cx, ToolbarRect.bottom - ToolbarRect.top, SWP_NOZORDER);
488 if(!dwp)
489 return;
490 }
491
492 if(Info->hMdiClient)
493 {
494 dwp = DeferWindowPos(dwp, Info->hMdiClient, NULL, 0, iMdiTop, cx, cy - iMdiTop, SWP_NOZORDER);
495 if(!dwp)
496 return;
497 }
498
500}
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI EndDeferWindowPos(_In_ HDWP)
HDWP WINAPI DeferWindowPos(_In_ HDWP, _In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SWP_NOZORDER
Definition: winuser.h:1250
HDWP WINAPI BeginDeferWindowPos(_In_ int)

Referenced by MainWndProc().

◆ MenuCommand()

static BOOL MenuCommand ( IN INT  nMenuItemID,
IN PMAIN_WND_INFO  Info 
)
static

Definition at line 397 of file mainwnd.c.

398{
399 switch(nMenuItemID)
400 {
401 // File Menu
402 case ID_FILE_NEW:
404 return TRUE;
405
406 case ID_FILE_OPEN:
408 return TRUE;
409
410 case ID_FILE_CLOSE:
411 SendMessageW(Info->CurrentFontWnd->hSelf, WM_CLOSE, 0, 0);
412 return TRUE;
413
414 case ID_FILE_SAVE:
416 return TRUE;
417
418 case ID_FILE_SAVE_AS:
420 return TRUE;
421
422 case ID_FILE_EXIT:
423 PostMessage(Info->hMainWnd, WM_CLOSE, 0, 0);
424 return TRUE;
425
426 // Edit Menu
427 case ID_EDIT_GLYPH:
428 EditCurrentGlyph(Info->CurrentFontWnd);
429 return TRUE;
430
431 case ID_EDIT_COPY:
432 CopyCurrentGlyph(Info->CurrentFontWnd);
433 return TRUE;
434
435 case ID_EDIT_PASTE:
436 PasteIntoCurrentGlyph(Info->CurrentFontWnd);
437 return TRUE;
438
439 // Window Menu
442 return TRUE;
443
446 return TRUE;
447
449 SendMessageW(Info->hMdiClient, WM_MDICASCADE, 0, 0);
450 return TRUE;
451
453 SendMessageW(Info->hMdiClient, WM_MDIICONARRANGE, 0, 0);
454 return TRUE;
455
456 case ID_WINDOW_NEXT:
457 SendMessageW(Info->hMdiClient, WM_MDINEXT, 0, 0);
458 return TRUE;
459
460 // Help Menu
461 case ID_HELP_ABOUT:
463 return TRUE;
464 }
465
466 return FALSE;
467}
#define ID_HELP_ABOUT
Definition: resource.h:61
#define ID_FILE_EXIT
Definition: resource.h:46
INT_PTR CALLBACK AboutDlgProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: aboutdlg.c:11
VOID EditCurrentGlyph(PFONT_WND_INFO FontWndInfo)
Definition: fontboxeswnd.c:182
static VOID PasteIntoCurrentGlyph(IN PFONT_WND_INFO FontWndInfo)
Definition: mainwnd.c:352
static VOID DoFileNew(IN PMAIN_WND_INFO Info)
Definition: mainwnd.c:237
static VOID DoFileOpen(IN PMAIN_WND_INFO Info)
Definition: mainwnd.c:247
static VOID CopyCurrentGlyph(IN PFONT_WND_INFO FontWndInfo)
Definition: mainwnd.c:331
VOID DoFileSave(IN PMAIN_WND_INFO Info, IN BOOL bSaveAs)
Definition: mainwnd.c:289
#define ID_WINDOW_ARRANGE
Definition: resource.h:52
#define ID_WINDOW_NEXT
Definition: resource.h:51
#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
#define IDD_ABOUT
Definition: shresdef.h:370
#define WM_MDITILE
Definition: winuser.h:1821
#define WM_MDICASCADE
Definition: winuser.h:1822
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4402
#define WM_MDINEXT
Definition: winuser.h:1819
#define WM_MDIICONARRANGE
Definition: winuser.h:1823
#define PostMessage
Definition: winuser.h:5844
#define MDITILE_HORIZONTAL
Definition: winuser.h:2191
#define MDITILE_VERTICAL
Definition: winuser.h:2192

Referenced by MainWndProc().

◆ OutOfMemory()

static VOID OutOfMemory ( IN PMAIN_WND_INFO  Info)
static

Definition at line 199 of file mainwnd.c.

200{
201 MessageBoxW(Info->hMainWnd, L"Out of memory!", NULL, MB_ICONERROR);
202}

◆ PasteIntoCurrentGlyph()

static VOID PasteIntoCurrentGlyph ( IN PFONT_WND_INFO  FontWndInfo)
static

Definition at line 352 of file mainwnd.c.

353{
354 HGLOBAL hMem;
355
357 return;
358
359 if(!OpenClipboard(NULL))
360 return;
361
363 if(hMem)
364 {
365 PUCHAR pCharacterBits;
366
367 pCharacterBits = GlobalLock(hMem);
368 if(pCharacterBits)
369 {
370 RECT CharacterRect;
371 UINT uFontRow;
372 UINT uFontColumn;
373
374 RtlCopyMemory(FontWndInfo->Font->Bits + FontWndInfo->uSelectedCharacter * 8, pCharacterBits, 8);
375 GlobalUnlock(hMem);
376
377 FontWndInfo->OpenInfo->bModified = TRUE;
378
379 GetCharacterPosition(FontWndInfo->uSelectedCharacter, &uFontRow, &uFontColumn);
380 GetCharacterRect(uFontRow, uFontColumn, &CharacterRect);
381 InvalidateRect(FontWndInfo->hFontBoxesWnd, &CharacterRect, FALSE);
382 }
383 }
384
386}
VOID GetCharacterRect(IN UINT uFontRow, IN UINT uFontColumn, OUT LPRECT CharacterRect)
Definition: fontboxeswnd.c:25
static __inline VOID GetCharacterPosition(IN UINT uCharacter, OUT PUINT uFontRow, OUT PUINT uFontColumn)
Definition: precomp.h:142
HANDLE WINAPI GetClipboardData(_In_ UINT)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)

Referenced by MenuCommand().

◆ SetPasteButtonState()

VOID SetPasteButtonState ( IN PMAIN_WND_INFO  Info)

Definition at line 389 of file mainwnd.c.

390{
394}
static VOID SetToolbarButtonState(IN PMAIN_WND_INFO Info, INT idCommand, BOOL bEnabled)
Definition: mainwnd.c:80

Referenced by FontWndProc(), InitMainWnd(), and MainWndProc().

◆ SetToolbarButtonState()

static VOID SetToolbarButtonState ( IN PMAIN_WND_INFO  Info,
INT  idCommand,
BOOL  bEnabled 
)
static

Definition at line 80 of file mainwnd.c.

81{
82 TBBUTTONINFOW tbbi = {0,};
83
84 tbbi.cbSize = sizeof(tbbi);
85 tbbi.dwMask = TBIF_STATE;
86 tbbi.fsState = (bEnabled ? TBSTATE_ENABLED : 0);
87
88 SendMessageW(Info->hToolbar, TB_SETBUTTONINFOW, idCommand, (LPARAM)&tbbi);
89}
#define TB_SETBUTTONINFOW
Definition: commctrl.h:1258
#define TBIF_STATE
Definition: commctrl.h:1221
DWORD dwMask
Definition: commctrl.h:1243

Referenced by SetPasteButtonState(), and SetToolbarFileButtonState().

◆ SetToolbarFileButtonState()

VOID SetToolbarFileButtonState ( IN PMAIN_WND_INFO  Info,
BOOL  bEnabled 
)

Definition at line 92 of file mainwnd.c.

Referenced by FontWndProc(), and InitMainWnd().

◆ UnInitMainWndClass()

VOID UnInitMainWndClass ( VOID  )

Definition at line 656 of file mainwnd.c.

657{
659}
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)

Referenced by wWinMain().

◆ UnInitResources()

static VOID UnInitResources ( IN PMAIN_WND_INFO  Info)
static

Definition at line 56 of file mainwnd.c.

57{
58 DeleteObject(Info->hBoxBmp);
59}

Referenced by MainWndProc().

Variable Documentation

◆ szMainWndClass

const WCHAR szMainWndClass[] = L"VGAFontEditMainWndClass"
static

Definition at line 11 of file mainwnd.c.