ReactOS  0.4.13-dev-687-g023794c
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 }
uint16_t * PWSTR
Definition: typedefs.h:54
int32_t INT_PTR
Definition: typedefs.h:62
static INT AllocAndLoadString(OUT LPTSTR *lpTarget, IN HINSTANCE hInst, IN UINT uID)
Definition: misc.c:60
struct TraceInfo Info
LONG_PTR LPARAM
Definition: windef.h:208
INT_PTR iString
Definition: commctrl.h:931
int iBitmap
Definition: commctrl.h:921
int idCommand
Definition: commctrl.h:922
#define TB_ADDBUTTONSW
Definition: commctrl.h:1238
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define TBSTATE_ENABLED
Definition: commctrl.h:946
BYTE fsState
Definition: commctrl.h:923
#define HeapFree(x, y, z)
Definition: compat.h:394
HANDLE hProcessHeap
Definition: kbswitch.c:25

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 }
BYTE fsStyle
Definition: commctrl.h:924
struct TraceInfo Info
LONG_PTR LPARAM
Definition: windef.h:208
#define BTNS_SEP
Definition: commctrl.h:971
#define TB_ADDBUTTONSW
Definition: commctrl.h:1238
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

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 
339  EmptyClipboard();
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 
348  CloseClipboard();
349 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
unsigned char * PUCHAR
Definition: retypes.h:3
HANDLE WINAPI SetClipboardData(_In_ UINT, _In_opt_ HANDLE)
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI EmptyClipboard(void)
Definition: ntwrapper.h:190
BOOL WINAPI CloseClipboard(void)
Definition: ntwrapper.h:178
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
UINT uCharacterClipboardFormat
Definition: main.c:15
BOOL WINAPI OpenClipboard(_In_opt_ HWND)
#define GMEM_MOVEABLE
Definition: winbase.h:291

Referenced by MenuCommand().

◆ CreateMainWindow()

BOOL CreateMainWindow ( IN INT  nCmdShow,
OUT PMAIN_WND_INFO Info 
)

Definition at line 608 of file mainwnd.c.

609 {
610  HWND hMainWnd;
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
634  HeapFree(hProcessHeap, 0, *Info);
635  }
636 
637  return FALSE;
638 }
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define TRUE
Definition: types.h:120
static const WCHAR szMainWndClass[]
Definition: mainwnd.c:11
#define WS_CLIPCHILDREN
Definition: pedump.c:619
struct TraceInfo Info
#define CW_USEDEFAULT
Definition: winuser.h:225
smooth NULL
Definition: ftsmooth.c:416
#define IDM_MAINMENU
Definition: resources.h:3
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
struct _MAIN_WND_INFO * PMAIN_WND_INFO
HWND hMainWnd
Definition: magnifier.c:32
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)
TCHAR szAppName[128]
Definition: solitaire.cpp:16
HINSTANCE hInstance
Definition: mainwnd.c:15
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
HMENU WINAPI LoadMenuW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define HeapFree(x, y, z)
Definition: compat.h:394
HANDLE hProcessHeap
Definition: kbswitch.c:25

◆ 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  {
212  OutOfMemory(Info);
213  return NULL;
214  }
215 
216  OpenInfo->bCreateNew = bCreateNew;
217  OpenInfo->pszFileName = HeapAlloc(hProcessHeap, 0, MAX_PATH);
218  if (!OpenInfo->pszFileName)
219  {
220  OutOfMemory(Info);
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 }
struct TraceInfo Info
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
PWSTR pszFileName
Definition: precomp.h:61
smooth NULL
Definition: ftsmooth.c:416
BOOL bCreateNew
Definition: precomp.h:58
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
#define MAX_PATH
Definition: compat.h:26
static const WCHAR L[]
Definition: oid.c:1250
static VOID OutOfMemory(IN PMAIN_WND_INFO Info)
Definition: mainwnd.c:199
#define MB_ICONERROR
Definition: winuser.h:781
#define S_OK
Definition: intsafe.h:59
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
Definition: File.h:15
#define HeapFree(x, y, z)
Definition: compat.h:394
HANDLE hProcessHeap
Definition: kbswitch.c:25

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 }
#define TRUE
Definition: types.h:120
BOOL CreateFontWindow(IN PMAIN_WND_INFO MainWndInfo, IN PFONT_OPEN_INFO OpenInfo)
Definition: fontwnd.c:363
struct TraceInfo Info
static const WCHAR L[]
Definition: oid.c:1250
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 }
BOOL CreateFontWindow(IN PMAIN_WND_INFO MainWndInfo, IN PFONT_OPEN_INFO OpenInfo)
Definition: fontwnd.c:363
struct TraceInfo Info
static VOID DoOpenFile(PINFO pInfo)
Definition: connectdialog.c:34
PWSTR pszFileName
Definition: precomp.h:61
static const WCHAR L[]
Definition: oid.c:1250
static PFONT_OPEN_INFO CreateOpenInfo(IN PMAIN_WND_INFO Info, BOOL bCreateNew, LPCWSTR File)
Definition: mainwnd.c:205
#define HeapFree(x, y, z)
Definition: compat.h:394
HANDLE hProcessHeap
Definition: kbswitch.c:25

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;
292  HANDLE hFile;
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 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define CloseHandle
Definition: compat.h:398
uint16_t * PWSTR
Definition: typedefs.h:54
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
struct TraceInfo Info
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
#define IDS_OPENERROR
Definition: resource.h:61
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define MAX_PATH
Definition: compat.h:26
VOID LocalizedError(IN UINT uID,...)
Definition: misc.c:103
unsigned long DWORD
Definition: ntddk_ex.h:95
#define OPEN_ALWAYS
Definition: disk.h:70
#define IDS_WRITEERROR
Definition: resource.h:63
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
static BOOL DoSaveFile(HWND hWnd, PCONSOLE_CHILDFRM_WND pChildInfo)
Definition: console.c:205
_In_ HANDLE hFile
Definition: mswsock.h:90
#define CreateFileW
Definition: compat.h:400
HANDLE hProcessHeap
Definition: kbswitch.c:25

Referenced by FontWndProc(), and MenuCommand().

◆ InitMainWnd()

static VOID InitMainWnd ( IN PMAIN_WND_INFO  Info)
static

Definition at line 110 of file mainwnd.c.

111 {
112  CLIENTCREATESTRUCT ccs;
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;
139  tbab.nID = IDB_STD_SMALL_COLOR;
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 
163  Info->hMdiClient = CreateWindowExW(WS_EX_CLIENTEDGE,
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 }
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define IDS_TOOLTIP_PASTE
Definition: resource.h:76
VOID SetPasteButtonState(IN PMAIN_WND_INFO Info)
Definition: mainwnd.c:389
#define STD_PASTE
Definition: commctrl.h:1045
#define TB_BUTTONSTRUCTSIZE
Definition: commctrl.h:1106
#define ID_EDIT_GLYPH
Definition: resource.h:44
#define IDS_TOOLTIP_SAVE
Definition: resource.h:73
#define ID_EDIT_COPY
Definition: resource.h:49
#define INT
Definition: polytest.cpp:20
#define TOOLBARCLASSNAMEW
Definition: commctrl.h:915
#define IDB_STD_SMALL_COLOR
Definition: commctrl.h:1036
#define ID_FILE_OPEN
Definition: resource.h:42
#define STD_FILENEW
Definition: commctrl.h:1049
HINSTANCE hInst
Definition: commctrl.h:1031
#define WS_CHILD
Definition: pedump.c:617
#define WS_CLIPCHILDREN
Definition: pedump.c:619
int32_t INT
Definition: typedefs.h:56
struct TraceInfo Info
VOID FileInitialize(IN HWND hwnd)
Definition: opensave.c:13
static VOID AddToolbarButton(IN PMAIN_WND_INFO Info, IN INT iBitmap, IN INT idCommand, IN UINT uID)
Definition: mainwnd.c:62
#define TB_SETMAXTEXTROWS
Definition: commctrl.h:1134
#define IDS_TOOLTIP_EDIT_GLYPH
Definition: resource.h:74
smooth NULL
Definition: ftsmooth.c:416
#define STD_COPY
Definition: commctrl.h:1044
LONG_PTR LPARAM
Definition: windef.h:208
#define ID_FILE_SAVE
Definition: resource.h:43
#define ID_FILE_NEW
Definition: resource.h:41
#define IDB_MAIN_TOOLBAR
Definition: resource.h:24
#define TBSTYLE_TOOLTIPS
Definition: commctrl.h:961
#define WS_HSCROLL
Definition: pedump.c:628
#define TB_ADDBITMAP
Definition: commctrl.h:1028
static const WCHAR L[]
Definition: oid.c:1250
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)
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define TOOLBAR_EDIT_GLYPH
Definition: precomp.h:118
#define IDS_TOOLTIP_COPY
Definition: resource.h:75
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
HINSTANCE hInstance
Definition: mainwnd.c:15
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static VOID AddToolbarSeparator(IN PMAIN_WND_INFO Info)
Definition: mainwnd.c:100
#define WS_VSCROLL
Definition: pedump.c:627
#define HINST_COMMCTRL
Definition: commctrl.h:1035
#define STD_FILESAVE
Definition: commctrl.h:1051
#define ID_EDIT_PASTE
Definition: resource.h:50
#define IDS_TOOLTIP_OPEN
Definition: resource.h:72
VOID SetToolbarFileButtonState(IN PMAIN_WND_INFO Info, BOOL bEnabled)
Definition: mainwnd.c:92
#define ID_MDI_FIRSTCHILD
Definition: mainwnd.c:5
#define STD_FILEOPEN
Definition: commctrl.h:1050
#define WS_VISIBLE
Definition: pedump.c:620
UINT_PTR nID
Definition: commctrl.h:1032
#define IDS_TOOLTIP_NEW
Definition: resource.h:71

Referenced by MainWndProc().

◆ InitMainWndClass()

BOOL InitMainWndClass ( VOID  )

Definition at line 641 of file mainwnd.c.

642 {
643  WNDCLASSW wc = {0,};
644 
646  wc.hInstance = hInstance;
647  wc.hCursor = LoadCursor( NULL, IDC_ARROW );
649  wc.hbrBackground = (HBRUSH)( COLOR_BTNFACE + 1 );
651 
652  return RegisterClassW(&wc) != 0;
653 }
static const WCHAR szMainWndClass[]
Definition: mainwnd.c:11
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
WNDPROC lpfnWndProc
Definition: winuser.h:3151
smooth NULL
Definition: ftsmooth.c:416
LPCWSTR lpszClassName
Definition: winuser.h:3159
HICON hIcon
Definition: winuser.h:3155
#define IDI_MAIN
Definition: resource.h:4
#define COLOR_BTNFACE
Definition: winuser.h:918
#define LoadCursor
Definition: winuser.h:5710
HCURSOR hCursor
Definition: winuser.h:3156
HINSTANCE hInstance
Definition: mainwnd.c:15
HBRUSH hbrBackground
Definition: winuser.h:3157
HINSTANCE hInstance
Definition: winuser.h:3154
#define IDC_ARROW
Definition: winuser.h:682
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
static LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: mainwnd.c:503

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 
194  uState = MF_BYCOMMAND | !(Info->CurrentFontWnd && IsClipboardFormatAvailable(uCharacterClipboardFormat));
195  EnableMenuItem(Info->hMenu, ID_EDIT_PASTE, uState);
196 }
#define ID_EDIT_GLYPH
Definition: resource.h:44
BOOL WINAPI IsClipboardFormatAvailable(_In_ UINT)
#define MF_BYCOMMAND
Definition: winuser.h:202
#define ID_EDIT_COPY
Definition: resource.h:49
#define ID_FILE_SAVE_AS
Definition: resource.h:41
struct TraceInfo Info
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define ID_FILE_SAVE
Definition: resource.h:43
#define ID_FILE_CLOSE
Definition: resource.h:39
unsigned int UINT
Definition: ndis.h:50
#define ID_EDIT_PASTE
Definition: resource.h:50
UINT uCharacterClipboardFormat
Definition: main.c:15

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 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
#define CHARACTER_INFO_BOX_WIDTH
Definition: precomp.h:100
#define CHARACTER_BOX_WIDTH
Definition: precomp.h:103
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
HDC WINAPI GetDC(_In_opt_ HWND)
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
#define WHITE_PEN
Definition: wingdi.h:904
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
& rect
Definition: startmenu.cpp:1413
struct TraceInfo Info
#define PS_SOLID
Definition: wingdi.h:585
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416
#define CHARACTER_INFO_BOX_HEIGHT
Definition: precomp.h:101
FORCEINLINE VOID SetPixel(IN ULONG Left, IN ULONG Top, IN UCHAR Color)
Definition: vga.c:93
#define RGB(r, g, b)
Definition: wingdi.h:2918
#define COLOR_BTNFACE
Definition: winuser.h:918
BOOL WINAPI DeleteDC(_In_ HDC)
#define CHARACTER_BOX_HEIGHT
Definition: precomp.h:104
static HBITMAP
Definition: button.c:44
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)

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 }
static VOID MainWndOpenFile(IN PMAIN_WND_INFO Info, LPCWSTR File)
Definition: mainwnd.c:264
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
int32_t INT
Definition: typedefs.h:56
struct TraceInfo Info
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
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
PRTL_UNICODE_STRING_BUFFER Path
void WINAPI DragFinish(HDROP h)
Definition: shellole.c:543
UINT WINAPI DragQueryFileW(HDROP hDrop, UINT lFile, LPWSTR lpszwFile, UINT lLength)
Definition: shellole.c:627

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 }
BOOL CreateFontWindow(IN PMAIN_WND_INFO MainWndInfo, IN PFONT_OPEN_INFO OpenInfo)
Definition: fontwnd.c:363
struct TraceInfo Info
Definition: File.h:15
static PFONT_OPEN_INFO CreateOpenInfo(IN PMAIN_WND_INFO Info, BOOL bCreateNew, LPCWSTR File)
Definition: mainwnd.c:205

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 
560  InitMainWnd(Info);
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 
577  PostQuitMessage(0);
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:
596  MainWndDropFiles(Info, (HDROP)wParam);
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 VOID MainWndSize(PMAIN_WND_INFO Info, INT cx, INT cy)
Definition: mainwnd.c:470
static VOID InitMainWnd(IN PMAIN_WND_INFO Info)
Definition: mainwnd.c:110
#define WM_USER_APPCLOSE
Definition: precomp.h:115
#define WM_CHANGECBCHAIN
Definition: winuser.h:1856
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
VOID SetPasteButtonState(IN PMAIN_WND_INFO Info)
Definition: mainwnd.c:389
#define TRUE
Definition: types.h:120
static VOID MainWndOpenFile(IN PMAIN_WND_INFO Info, LPCWSTR File)
Definition: mainwnd.c:264
HWND WINAPI SetClipboardViewer(_In_ HWND)
#define WM_INITMENUPOPUP
Definition: winuser.h:1728
void WINAPI DragAcceptFiles(HWND hWnd, BOOL b)
Definition: shellole.c:527
static BOOL MenuCommand(IN INT nMenuItemID, IN PMAIN_WND_INFO Info)
Definition: mainwnd.c:397
#define GetWindowLongPtrW
Definition: winuser.h:4730
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
int32_t INT
Definition: typedefs.h:56
WPARAM wParam
Definition: combotst.c:138
struct TraceInfo Info
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
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
#define WM_DROPFILES
Definition: winuser.h:1807
#define GWLP_USERDATA
Definition: treelist.c:63
static VOID MainWndDropFiles(IN PMAIN_WND_INFO Info, HDROP hDrop)
Definition: mainwnd.c:274
#define WM_DESTROY
Definition: winuser.h:1591
#define WM_SIZE
Definition: winuser.h:1593
#define WM_CLOSE
Definition: winuser.h:1603
struct _MAIN_WND_INFO * PMAIN_WND_INFO
HWND hSelf
Definition: precomp.h:70
#define WM_DRAWCLIPBOARD
Definition: winuser.h:1851
#define WM_COMMAND
Definition: winuser.h:1722
static VOID UnInitResources(IN PMAIN_WND_INFO Info)
Definition: mainwnd.c:56
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
static VOID InitResources(IN PMAIN_WND_INFO Info)
Definition: mainwnd.c:14
_CRTIMP int __argc
Definition: getargs.c:21
_CRTIMP wchar_t ** __wargv
Definition: getargs.c:20
#define SendMessage
Definition: winuser.h:5741
#define WM_CREATE
Definition: winuser.h:1590
#define HIWORD(l)
Definition: typedefs.h:246
PFONT_WND_INFO NextFontWnd
Definition: precomp.h:75
#define SetWindowLongPtrW
Definition: winuser.h:5247
HMENU WINAPI GetMenu(_In_ HWND)
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define HeapFree(x, y, z)
Definition: compat.h:394
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
LRESULT WINAPI DefFrameProcW(_In_ HWND, _In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HANDLE hProcessHeap
Definition: kbswitch.c:25
static VOID InitMenuPopup(IN PMAIN_WND_INFO Info)
Definition: mainwnd.c:181

Referenced by InitMainWndClass().

◆ 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 
499  EndDeferWindowPos(dwp);
500 }
HDWP WINAPI BeginDeferWindowPos(_In_ int)
LONG top
Definition: windef.h:292
#define SWP_NOZORDER
Definition: winuser.h:1232
int32_t INT
Definition: typedefs.h:56
struct TraceInfo Info
BOOL WINAPI EndDeferWindowPos(_In_ HDWP)
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
smooth NULL
Definition: ftsmooth.c:416
HDWP WINAPI DeferWindowPos(_In_ HDWP, _In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
_Out_opt_ int * cx
Definition: commctrl.h:570
LONG bottom
Definition: windef.h:294
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)

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:
403  DoFileNew(Info);
404  return TRUE;
405 
406  case ID_FILE_OPEN:
407  DoFileOpen(Info);
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:
419  DoFileSave(Info, TRUE);
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
440  case ID_WINDOW_TILE_HORZ:
442  return TRUE;
443 
444  case ID_WINDOW_TILE_VERT:
445  SendMessageW(Info->hMdiClient, WM_MDITILE, MDITILE_VERTICAL, 0);
446  return TRUE;
447 
448  case ID_WINDOW_CASCADE:
449  SendMessageW(Info->hMdiClient, WM_MDICASCADE, 0, 0);
450  return TRUE;
451 
452  case ID_WINDOW_ARRANGE:
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 TRUE
Definition: types.h:120
#define ID_EDIT_GLYPH
Definition: resource.h:44
#define WM_MDICASCADE
Definition: winuser.h:1801
#define ID_EDIT_COPY
Definition: resource.h:49
#define ID_FILE_OPEN
Definition: resource.h:42
#define ID_FILE_SAVE_AS
Definition: resource.h:41
#define ID_WINDOW_TILE_VERT
Definition: resource.h:49
struct TraceInfo Info
VOID EditCurrentGlyph(PFONT_WND_INFO FontWndInfo)
Definition: fontboxeswnd.c:189
#define WM_MDIICONARRANGE
Definition: winuser.h:1802
#define ID_FILE_EXIT
Definition: resource.h:47
#define MDITILE_HORIZONTAL
Definition: winuser.h:2163
#define ID_HELP_ABOUT
Definition: resource.h:77
#define WM_MDINEXT
Definition: winuser.h:1798
#define ID_FILE_SAVE
Definition: resource.h:43
INT_PTR CALLBACK AboutDlgProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: sndrec32.cpp:83
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4300
#define ID_FILE_NEW
Definition: resource.h:41
#define PostMessage
Definition: winuser.h:5730
#define ID_WINDOW_CASCADE
Definition: resource.h:78
static VOID CopyCurrentGlyph(IN PFONT_WND_INFO FontWndInfo)
Definition: mainwnd.c:331
#define MDITILE_VERTICAL
Definition: winuser.h:2164
#define WM_CLOSE
Definition: winuser.h:1603
#define ID_WINDOW_TILE_HORZ
Definition: resource.h:48
VOID DoFileSave(IN PMAIN_WND_INFO Info, IN BOOL bSaveAs)
Definition: mainwnd.c:289
#define ID_WINDOW_ARRANGE
Definition: resource.h:52
#define IDD_ABOUT
Definition: shresdef.h:298
#define ID_WINDOW_NEXT
Definition: resource.h:51
HINSTANCE hInstance
Definition: mainwnd.c:15
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define ID_FILE_CLOSE
Definition: resource.h:39
static VOID PasteIntoCurrentGlyph(IN PFONT_WND_INFO FontWndInfo)
Definition: mainwnd.c:352
static VOID DoFileNew(IN PMAIN_WND_INFO Info)
Definition: mainwnd.c:237
#define ID_EDIT_PASTE
Definition: resource.h:50
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
static VOID DoFileOpen(IN PMAIN_WND_INFO Info)
Definition: mainwnd.c:247
#define WM_MDITILE
Definition: winuser.h:1800

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 }
struct TraceInfo Info
smooth NULL
Definition: ftsmooth.c:416
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
static const WCHAR L[]
Definition: oid.c:1250
#define MB_ICONERROR
Definition: winuser.h:781

Referenced by CreateOpenInfo().

◆ 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 
385  CloseClipboard();
386 }
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
BOOL WINAPI IsClipboardFormatAvailable(_In_ UINT)
__inline VOID GetCharacterPosition(IN UINT uCharacter, OUT PUINT uFontRow, OUT PUINT uFontColumn)
Definition: fontboxeswnd.c:34
unsigned char * PUCHAR
Definition: retypes.h:3
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
BOOL WINAPI CloseClipboard(void)
Definition: ntwrapper.h:178
VOID GetCharacterRect(IN UINT uFontRow, IN UINT uFontColumn, OUT LPRECT CharacterRect)
Definition: fontboxeswnd.c:25
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
unsigned int UINT
Definition: ndis.h:50
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
HANDLE WINAPI GetClipboardData(_In_ UINT)
UINT uCharacterClipboardFormat
Definition: main.c:15
BOOL WINAPI OpenClipboard(_In_opt_ HWND)

Referenced by MenuCommand().

◆ SetPasteButtonState()

VOID SetPasteButtonState ( IN PMAIN_WND_INFO  Info)

Definition at line 389 of file mainwnd.c.

390 {
394 }
BOOL WINAPI IsClipboardFormatAvailable(_In_ UINT)
struct TraceInfo Info
static VOID SetToolbarButtonState(IN PMAIN_WND_INFO Info, INT idCommand, BOOL bEnabled)
Definition: mainwnd.c:80
#define ID_EDIT_PASTE
Definition: resource.h:50
UINT uCharacterClipboardFormat
Definition: main.c:15

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:1230
DWORD dwMask
Definition: commctrl.h:1215
struct TraceInfo Info
LONG_PTR LPARAM
Definition: windef.h:208
#define TBIF_STATE
Definition: commctrl.h:1193
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define TBSTATE_ENABLED
Definition: commctrl.h:946

Referenced by SetPasteButtonState(), and SetToolbarFileButtonState().

◆ SetToolbarFileButtonState()

VOID SetToolbarFileButtonState ( IN PMAIN_WND_INFO  Info,
BOOL  bEnabled 
)

Definition at line 92 of file mainwnd.c.

93 {
97 }
#define ID_EDIT_GLYPH
Definition: resource.h:44
#define ID_EDIT_COPY
Definition: resource.h:49
struct TraceInfo Info
static VOID SetToolbarButtonState(IN PMAIN_WND_INFO Info, INT idCommand, BOOL bEnabled)
Definition: mainwnd.c:80
#define ID_FILE_SAVE
Definition: resource.h:43

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)
static const WCHAR szMainWndClass[]
Definition: mainwnd.c:11
HINSTANCE hInstance
Definition: mainwnd.c:15

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 }
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
struct TraceInfo Info

Referenced by MainWndProc().

Variable Documentation

◆ szMainWndClass

const WCHAR szMainWndClass[] = L"VGAFontEditMainWndClass"
static

Definition at line 11 of file mainwnd.c.

Referenced by CreateMainWindow(), InitMainWndClass(), and UnInitMainWndClass().