ReactOS 0.4.15-dev-7681-g776c3a3
fontview.c File Reference
#include "precomp.h"
#include <winnls.h>
#include <shellapi.h>
#include <windowsx.h>
#include <winreg.h>
#include "fontview.h"
#include "resource.h"
Include dependency graph for fontview.c:

Go to the source code of this file.

Functions

BOOL WINAPI GetFontResourceInfoW (LPCWSTR lpFileName, DWORD *pdwBufSize, void *lpBuffer, DWORD dwType)
 
DWORD FormatString (DWORD dwFlags, HINSTANCE hInstance, DWORD dwStringId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, va_list *Arguments)
 
static void FormatMsgBox (_In_ HWND hParent, _In_ DWORD dwMessageId, _In_ DWORD dwCaptionId, _In_ UINT uType, _In_ va_list args)
 
static void ErrorMsgBox (HWND hParent, DWORD dwMessageId,...)
 
static void SuccessMsgBox (HWND hParent, DWORD dwMessageId,...)
 
int WINAPI wWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
 
static LRESULT MainWnd_OnCreate (HWND hwnd)
 
static LRESULT MainWnd_OnSize (HWND hwnd)
 
static LRESULT MainWnd_OnPaint (HWND hwnd)
 
static LRESULT MainWnd_OnInstall (HWND hwnd)
 
static LRESULT MainWnd_OnPrev (HWND hwnd)
 
static LRESULT MainWnd_OnNext (HWND hwnd)
 
LRESULT CALLBACK MainWndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 

Variables

HINSTANCE g_hInstance
 
INT g_FontIndex = 0
 
INT g_NumFonts = 0
 
LOGFONTW g_LogFonts [64]
 
LPCWSTR g_fileName = L""
 
WCHAR g_FontTitle [1024] = L""
 
BOOL g_FontPrint = FALSE
 
BOOL g_DisableInstall = FALSE
 
static const WCHAR g_szFontViewClassName [] = L"FontViewWClass"
 

Function Documentation

◆ ErrorMsgBox()

static void ErrorMsgBox ( HWND  hParent,
DWORD  dwMessageId,
  ... 
)
static

Definition at line 82 of file fontview.c.

86{
88
89 va_start(args, dwMessageId);
90 FormatMsgBox(hParent, dwMessageId, IDS_ERROR, MB_ICONERROR, args);
91 va_end(args);
92}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define IDS_ERROR
Definition: resource.h:18
static void FormatMsgBox(_In_ HWND hParent, _In_ DWORD dwMessageId, _In_ DWORD dwCaptionId, _In_ UINT uType, _In_ va_list args)
Definition: fontview.c:61
#define args
Definition: format.c:66
Definition: match.c:390
#define MB_ICONERROR
Definition: winuser.h:786

Referenced by MainWnd_OnInstall(), and wWinMain().

◆ FormatMsgBox()

static void FormatMsgBox ( _In_ HWND  hParent,
_In_ DWORD  dwMessageId,
_In_ DWORD  dwCaptionId,
_In_ UINT  uType,
_In_ va_list  args 
)
static

Definition at line 61 of file fontview.c.

67{
68 HLOCAL hMemCaption = NULL;
69 HLOCAL hMemText = NULL;
70
72 NULL, dwMessageId, 0, (LPWSTR)&hMemText, 0, &args);
74 NULL, dwCaptionId, 0, (LPWSTR)&hMemCaption, 0, NULL);
75
76 MessageBoxW(hParent, hMemText, hMemCaption, uType);
77 LocalFree(hMemCaption);
78 LocalFree(hMemText);
79}
#define NULL
Definition: types.h:112
DWORD FormatString(DWORD dwFlags, HINSTANCE hInstance, DWORD dwStringId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, va_list *Arguments)
Definition: fontview.c:34
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:419
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by ErrorMsgBox(), and SuccessMsgBox().

◆ FormatString()

DWORD FormatString ( DWORD  dwFlags,
HINSTANCE  hInstance,
DWORD  dwStringId,
DWORD  dwLanguageId,
LPWSTR  lpBuffer,
DWORD  nSize,
va_list Arguments 
)

Definition at line 34 of file fontview.c.

43{
44 DWORD dwRet;
45 int len;
46 WCHAR Buffer[1000];
47
48 len = LoadStringW(hInstance, dwStringId, (LPWSTR)Buffer, 1000);
49
50 if (len)
51 {
54 dwRet = FormatMessageW(dwFlags, Buffer, 0, dwLanguageId, lpBuffer, nSize, Arguments);
55 return dwRet;
56 }
57 return 0;
58}
HINSTANCE hInstance
Definition: charmap.c:19
Definition: bufpool.h:45
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
#define FORMAT_MESSAGE_FROM_STRING
Definition: winbase.h:421
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:423
#define FORMAT_MESSAGE_FROM_HMODULE
Definition: winbase.h:422
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:2084
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by BmFatalErrorEx(), EtfsOpen(), FormatMsgBox(), GetComCtl32Version(), GetExecutableVendor(), LoadXMLDocumentFromFile(), LoadXMLDocumentFromResource(), RequiredServicesDisablingDialogWndProc(), SafeFormatString(), ServicesPageWndProc(), and UserpFormatMessages().

◆ GetFontResourceInfoW()

BOOL WINAPI GetFontResourceInfoW ( LPCWSTR  lpFileName,
DWORD pdwBufSize,
void lpBuffer,
DWORD  dwType 
)

◆ MainWnd_OnCreate()

static LRESULT MainWnd_OnCreate ( HWND  hwnd)
static

Definition at line 298 of file fontview.c.

299{
300 WCHAR szQuit[MAX_BUTTONNAME];
301 WCHAR szPrint[MAX_BUTTONNAME];
302 WCHAR szString[MAX_STRING];
303 WCHAR szPrevious[MAX_STRING];
304 WCHAR szNext[MAX_STRING];
305 HWND hDisplay, hButtonInstall, hButtonPrint, hButtonPrev, hButtonNext;
306
307 /* create the display window */
308 hDisplay = CreateWindowExW(
309 0, /* Extended style */
310 g_szFontDisplayClassName, /* Classname */
311 L"", /* Title text */
312 WS_CHILD | WS_VSCROLL, /* Window style */
313 0, /* X-pos */
314 HEADER_SIZE, /* Y-Pos */
315 550, /* Width */
316 370-HEADER_SIZE, /* Height */
317 hwnd, /* Parent */
318 (HMENU)IDC_DISPLAY, /* Identifier */
319 g_hInstance, /* Program Instance handler */
320 NULL /* Window Creation data */
321 );
322
324 SendMessage(hDisplay, FVM_SETSTRING, 0, (LPARAM)szString);
325
326 /* Create the install button */
328 hButtonInstall = CreateWindowExW(
329 0, /* Extended style */
330 L"button", /* Classname */
331 szQuit, /* Title text */
332 WS_CHILD | WS_VISIBLE, /* Window style */
333 BUTTON_POS_X, /* X-pos */
334 BUTTON_POS_Y, /* Y-Pos */
335 BUTTON_WIDTH, /* Width */
336 BUTTON_HEIGHT, /* Height */
337 hwnd, /* Parent */
338 (HMENU)IDC_INSTALL, /* Identifier */
339 g_hInstance, /* Program Instance handler */
340 NULL /* Window Creation data */
341 );
343 EnableWindow(hButtonInstall, !g_DisableInstall);
344
345 /* Create the print button */
347 hButtonPrint = CreateWindowExW(
348 0, /* Extended style */
349 L"button", /* Classname */
350 szPrint, /* Title text */
351 WS_CHILD | WS_VISIBLE, /* Window style */
352 450, /* X-pos */
353 BUTTON_POS_Y, /* Y-Pos */
354 BUTTON_WIDTH, /* Width */
355 BUTTON_HEIGHT, /* Height */
356 hwnd, /* Parent */
357 (HMENU)IDC_PRINT, /* Identifier */
358 g_hInstance, /* Program Instance handler */
359 NULL /* Window Creation data */
360 );
362
363 /* Create the previous button */
365 hButtonPrev = CreateWindowExW(
366 0, /* Extended style */
367 L"button", /* Classname */
368 szPrevious, /* Title text */
369 WS_CHILD | WS_VISIBLE, /* Window style */
370 450, /* X-pos */
371 BUTTON_POS_Y, /* Y-Pos */
372 BUTTON_WIDTH, /* Width */
373 BUTTON_HEIGHT, /* Height */
374 hwnd, /* Parent */
375 (HMENU)IDC_PREV, /* Identifier */
376 g_hInstance, /* Program Instance handler */
377 NULL /* Window Creation data */
378 );
380
381 /* Create the next button */
383 hButtonNext = CreateWindowExW(
384 0, /* Extended style */
385 L"button", /* Classname */
386 szNext, /* Title text */
387 WS_CHILD | WS_VISIBLE, /* Window style */
388 450, /* X-pos */
389 BUTTON_POS_Y, /* Y-Pos */
390 BUTTON_WIDTH, /* Width */
391 BUTTON_HEIGHT, /* Height */
392 hwnd, /* Parent */
393 (HMENU)IDC_NEXT, /* Identifier */
394 g_hInstance, /* Program Instance handler */
395 NULL /* Window Creation data */
396 );
398
399 EnableWindow(hButtonPrev, FALSE);
400 if (g_NumFonts <= 1)
401 EnableWindow(hButtonNext, FALSE);
402
403 /* Init the display window with the font name */
404 g_FontIndex = 0;
406 ShowWindow(hDisplay, SW_SHOWNORMAL);
407
408 if (g_FontPrint)
410
411 return 0;
412}
#define IDC_DISPLAY
Definition: resource.h:19
#define IDS_NEXT
Definition: resource.h:13
const WCHAR g_szFontDisplayClassName[]
Definition: display.c:19
#define FVM_SETSTRING
Definition: display.h:5
#define FVM_SETTYPEFACE
Definition: display.h:4
#define IDS_PRINT
Definition: resource.h:16
#define IDS_STRING
Definition: resource.h:17
#define IDS_INSTALL
Definition: resource.h:15
#define IDS_PREVIOUS
Definition: resource.h:24
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define MAX_STRING
Definition: doskey.c:43
INT g_FontIndex
Definition: fontview.c:20
INT g_NumFonts
Definition: fontview.c:21
LOGFONTW g_LogFonts[64]
Definition: fontview.c:22
BOOL g_DisableInstall
Definition: fontview.c:26
HINSTANCE g_hInstance
Definition: fontview.c:19
BOOL g_FontPrint
Definition: fontview.c:25
#define BUTTON_POS_X
Definition: fontview.h:7
#define IDC_NEXT
Definition: fontview.h:17
#define HEADER_SIZE
Definition: fontview.h:6
#define IDC_INSTALL
Definition: fontview.h:13
#define BUTTON_POS_Y
Definition: fontview.h:8
#define BUTTON_HEIGHT
Definition: fontview.h:10
#define IDC_PRINT
Definition: fontview.h:14
#define MAX_BUTTONNAME
Definition: fontview.h:4
#define BUTTON_WIDTH
Definition: fontview.h:9
#define IDC_PREV
Definition: fontview.h:16
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
#define L(x)
Definition: ntvdm.h:50
#define WS_CHILD
Definition: pedump.c:617
#define WS_VSCROLL
Definition: pedump.c:627
#define WS_VISIBLE
Definition: pedump.c:620
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define DEFAULT_GUI_FONT
Definition: wingdi.h:909
#define SW_SHOWNORMAL
Definition: winuser.h:769
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define WM_COMMAND
Definition: winuser.h:1739
#define WM_SETFONT
Definition: winuser.h:1649
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 SendMessage
Definition: winuser.h:5842
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define PostMessage
Definition: winuser.h:5831

Referenced by MainWndProc().

◆ MainWnd_OnInstall()

static LRESULT MainWnd_OnInstall ( HWND  hwnd)
static

Definition at line 469 of file fontview.c.

470{
471 WCHAR szFullName[64];
472
473 WCHAR szSrcPath[MAX_PATH];
474 WCHAR szDestPath[MAX_PATH];
476 LONG res;
477 HKEY hKey;
478
480
481 /* First, we have to find out if the font still exists */
483 {
484 /* Fail, if the source file does not exist */
486 return -1;
487 }
488
489 /* Build the full destination file name */
491
492 GetWindowsDirectoryW(szDestPath, MAX_PATH);
493 wcscat(szDestPath, L"\\Fonts\\");
494 wcscat(szDestPath, pszFileName);
495
496 /* Check if the file already exists */
498 {
500 return 0;
501 }
502
503 /* Copy the font file */
504 if (!CopyFileW(g_fileName, szDestPath, TRUE))
505 {
507 return -1;
508 }
509
510 /* Open the fonts key */
512 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts",
513 0,
515 &hKey);
516 if (res != ERROR_SUCCESS)
517 {
519 return -1;
520 }
521
522 /* Register the font */
524 szFullName,
525 0,
526 REG_SZ,
528 (DWORD)(wcslen(pszFileName) + 1) * sizeof(WCHAR));
529 if (res != ERROR_SUCCESS)
530 {
533 return -1;
534 }
535
536 /* Close the fonts key */
538
539 /* Broadcast WM_FONTCHANGE message */
541
542 /* if all of this goes correctly, message the user about success */
544
545 return 0;
546}
#define FVM_GETFULLNAME
Definition: display.h:6
#define IDS_ERROR_NOFONT
Definition: resource.h:5
#define IDS_COMPLETED
Definition: resource.h:12
#define IDS_ERROR_OPENKEY
Definition: resource.h:9
#define IDS_ERROR_FONTCPY
Definition: resource.h:8
#define IDS_ERROR_REGISTER
Definition: resource.h:10
#define IDS_ERROR_ISINSTALLED
Definition: resource.h:7
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3362
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4911
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI CopyFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName, IN BOOL bFailIfExists)
Definition: copy.c:439
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1106
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2352
static void ErrorMsgBox(HWND hParent, DWORD dwMessageId,...)
Definition: fontview.c:82
LPCWSTR g_fileName
Definition: fontview.c:23
static void SuccessMsgBox(HWND hParent, DWORD dwMessageId,...)
Definition: fontview.c:95
FxAutoRegKey hKey
GLuint res
Definition: glext.h:9613
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define REG_SZ
Definition: layer.c:22
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
long LONG
Definition: pedump.c:60
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
uint16_t * PWSTR
Definition: typedefs.h:56
unsigned char * LPBYTE
Definition: typedefs.h:53
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:44
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
#define GetFileAttributes
Definition: winbase.h:3750
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HWND_BROADCAST
Definition: winuser.h:1203
#define WM_FONTCHANGE
Definition: winuser.h:1632
#define SendDlgItemMessage
Definition: winuser.h:5841
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by MainWndProc().

◆ MainWnd_OnNext()

static LRESULT MainWnd_OnNext ( HWND  hwnd)
static

Definition at line 567 of file fontview.c.

568{
569 HWND hDisplay;
570 if (g_FontIndex + 1 < g_NumFonts)
571 {
572 ++g_FontIndex;
574 if (g_FontIndex == g_NumFonts - 1)
576
577 hDisplay = GetDlgItem(hwnd, IDC_DISPLAY);
579 InvalidateRect(hDisplay, NULL, TRUE);
580 }
581 return 0;
582}
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)

Referenced by MainWndProc().

◆ MainWnd_OnPaint()

static LRESULT MainWnd_OnPaint ( HWND  hwnd)
static

Definition at line 453 of file fontview.c.

454{
455 HDC hDC;
456 PAINTSTRUCT ps;
457 RECT rc;
458
459 hDC = BeginPaint(hwnd, &ps);
460 GetClientRect(hwnd, &rc);
461 rc.top = HEADER_SIZE - 2;
462 rc.bottom = HEADER_SIZE;
464 EndPaint(hwnd, &ps);
465 return 0;
466}
static HDC hDC
Definition: 3dtext.c:33
static HDC
Definition: imagelist.c:92
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
#define GRAY_BRUSH
Definition: wingdi.h:898
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)

Referenced by MainWndProc().

◆ MainWnd_OnPrev()

static LRESULT MainWnd_OnPrev ( HWND  hwnd)
static

Definition at line 549 of file fontview.c.

550{
551 HWND hDisplay;
552 if (g_FontIndex > 0)
553 {
554 --g_FontIndex;
556 if (g_FontIndex == 0)
558
559 hDisplay = GetDlgItem(hwnd, IDC_DISPLAY);
561 InvalidateRect(hDisplay, NULL, TRUE);
562 }
563 return 0;
564}

Referenced by MainWndProc().

◆ MainWnd_OnSize()

static LRESULT MainWnd_OnSize ( HWND  hwnd)
static

Definition at line 415 of file fontview.c.

416{
417 RECT rc;
418 HWND hInstall, hPrint, hPrev, hNext, hDisplay;
419 HDWP hDWP;
420
421 GetClientRect(hwnd, &rc);
422
423 hDWP = BeginDeferWindowPos(5);
424
425 hInstall = GetDlgItem(hwnd, IDC_INSTALL);
426 if (hDWP)
428
429 hPrint = GetDlgItem(hwnd, IDC_PRINT);
430 if (hDWP)
432
433 hPrev = GetDlgItem(hwnd, IDC_PREV);
434 if (hDWP)
436
437 hNext = GetDlgItem(hwnd, IDC_NEXT);
438 if (hDWP)
440
441 hDisplay = GetDlgItem(hwnd, IDC_DISPLAY);
442 if (hDWP)
443 hDWP = DeferWindowPos(hDWP, hDisplay, NULL, 0, HEADER_SIZE, rc.right, rc.bottom - HEADER_SIZE, SWP_NOZORDER);
444
445 EndDeferWindowPos(hDWP);
446
448
449 return 0;
450}
#define BUTTON_PADDING
Definition: fontview.h:11
LONG right
Definition: windef.h:308
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:1246
HDWP WINAPI BeginDeferWindowPos(_In_ int)

Referenced by MainWndProc().

◆ MainWndProc()

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

Definition at line 585 of file fontview.c.

586{
587 switch (message)
588 {
589 case WM_CREATE:
590 return MainWnd_OnCreate(hwnd);
591
592 case WM_PAINT:
593 return MainWnd_OnPaint(hwnd);
594
595 case WM_SIZE:
596 return MainWnd_OnSize(hwnd);
597
598 case WM_COMMAND:
599 switch(LOWORD(wParam))
600 {
601 case IDC_INSTALL:
602 return MainWnd_OnInstall(hwnd);
603
604 case IDC_PRINT:
605 return Display_OnPrint(hwnd);
606
607 case IDC_PREV:
608 return MainWnd_OnPrev(hwnd);
609
610 case IDC_NEXT:
611 return MainWnd_OnNext(hwnd);
612 }
613 break;
614
615 case WM_DESTROY:
616 PostQuitMessage (0); /* send a WM_QUIT to the message queue */
617 break;
618
619 default: /* for messages that we don't deal with */
621 }
622
623 return 0;
624}
LRESULT Display_OnPrint(HWND hwnd)
Definition: display.c:422
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
static LRESULT MainWnd_OnNext(HWND hwnd)
Definition: fontview.c:567
static LRESULT MainWnd_OnInstall(HWND hwnd)
Definition: fontview.c:469
static LRESULT MainWnd_OnPaint(HWND hwnd)
Definition: fontview.c:453
static LRESULT MainWnd_OnCreate(HWND hwnd)
Definition: fontview.c:298
static LRESULT MainWnd_OnPrev(HWND hwnd)
Definition: fontview.c:549
static LRESULT MainWnd_OnSize(HWND hwnd)
Definition: fontview.c:415
#define LOWORD(l)
Definition: pedump.c:82
Definition: tftpd.h:60
#define WM_PAINT
Definition: winuser.h:1619
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_CREATE
Definition: winuser.h:1607
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_SIZE
Definition: winuser.h:1610
#define WM_DESTROY
Definition: winuser.h:1608

Referenced by wWinMain().

◆ SuccessMsgBox()

static void SuccessMsgBox ( HWND  hParent,
DWORD  dwMessageId,
  ... 
)
static

Definition at line 95 of file fontview.c.

99{
101
102 va_start(args, dwMessageId);
103 FormatMsgBox(hParent, dwMessageId, IDS_SUCCESS, MB_ICONINFORMATION, args);
104 va_end(args);
105}
#define IDS_SUCCESS
Definition: resource.h:11
#define MB_ICONINFORMATION
Definition: winuser.h:801

Referenced by MainWnd_OnInstall().

◆ wWinMain()

int WINAPI wWinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPWSTR  lpCmdLine,
int  nShowCmd 
)

This file has no copyright assigned and is placed in the Public Domain. This file is part of the w64 mingw-runtime package. No warranty is given; refer to the file DISCLAIMER.PD within this package.

Definition at line 108 of file fontview.c.

112{
113 int argc;
114 INT i;
115 WCHAR** argv;
118 MSG msg;
119 WNDCLASSEXW wincl;
120 LPCWSTR fileName;
121
122 switch (GetUserDefaultUILanguage())
123 {
126 break;
127
128 default:
129 break;
130 }
131
132 g_hInstance = hThisInstance;
133
134 /* Get unicode command line */
136 if (argc < 2)
137 {
138#if 0
139 WCHAR szFileName[MAX_PATH] = L"";
140 OPENFILENAMEW fontOpen;
141 WCHAR filter[MAX_PATH*2] = {0}, dialogTitle[MAX_PATH];
142
143 LoadStringW(NULL, IDS_OPEN, dialogTitle, ARRAYSIZE(dialogTitle));
145
146 /* Clears out any values of fontOpen before we use it */
147 ZeroMemory(&fontOpen, sizeof(fontOpen));
148
149 /* Sets up the open dialog box */
150 fontOpen.lStructSize = sizeof(fontOpen);
151 fontOpen.hwndOwner = NULL;
152 fontOpen.lpstrFilter = filter;
153 fontOpen.lpstrFile = szFileName;
154 fontOpen.lpstrTitle = dialogTitle;
155 fontOpen.nMaxFile = MAX_PATH;
157 fontOpen.lpstrDefExt = L"ttf";
158
159 /* Opens up the Open File dialog box in order to chose a font file. */
160 if(GetOpenFileNameW(&fontOpen))
161 {
162 fileName = fontOpen.lpstrFile;
163 g_fileName = fileName;
164 } else {
165 /* If the user decides to close out of the open dialog effectively
166 exiting the program altogether */
167 return 0;
168 }
169#endif
170 }
171 else
172 {
173 /* Try to add the font resource from command line */
174 for (i = 1; i < argc; ++i)
175 {
176 // Treat the last argument as filename
177 if (i + 1 == argc)
178 {
179 fileName = argv[i];
180 }
181 else if (argv[i][0] == '/' || argv[i][0] == '-')
182 {
183 switch (argv[i][1])
184 {
185 case 'p':
186 case 'P':
188 break;
189 case 'd':
190 case 'D':
192 break;
193 default:
194 fileName = argv[i];
195 break;
196 }
197 }
198 else
199 {
200 fileName = argv[i];
201 }
202 }
203 g_fileName = fileName;
204 }
205
207 {
209 return -1;
210 }
211
212 /* Get the font name */
213 dwSize = sizeof(g_LogFonts);
215 if (!GetFontResourceInfoW(fileName, &dwSize, g_LogFonts, 2))
216 {
217 ErrorMsgBox(0, IDS_ERROR_NOFONT, fileName);
218 return -1;
219 }
220 g_NumFonts = 0;
221 for (i = 0; i < ARRAYSIZE(g_LogFonts); ++i)
222 {
223 if (g_LogFonts[i].lfFaceName[0] == 0)
224 break;
225
226 ++g_NumFonts;
227 }
228 if (g_NumFonts == 0)
229 {
230 ErrorMsgBox(0, IDS_ERROR_NOFONT, fileName);
231 return -1;
232 }
233
234 /* get font title */
235 dwSize = sizeof(g_FontTitle);
238
239 if (!Display_InitClass(hThisInstance))
240 {
242 return -1;
243 }
244
245 /* The main window class */
246 wincl.cbSize = sizeof (WNDCLASSEXW);
247 wincl.style = CS_DBLCLKS;
248 wincl.lpfnWndProc = MainWndProc;
249 wincl.cbClsExtra = 0;
250 wincl.cbWndExtra = 0;
251 wincl.hInstance = hThisInstance;
253 wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
254 wincl.hbrBackground = (HBRUSH)COLOR_BACKGROUND;
255 wincl.lpszMenuName = NULL;
258
259 /* Register the window class, and if it fails quit the program */
260 if (!RegisterClassExW (&wincl))
261 {
263 return 0;
264 }
265
266 /* The class is registered, let's create the main window */
268 0, /* Extended possibilities for variation */
269 g_szFontViewClassName, /* Classname */
270 g_FontTitle, /* Title Text */
271 WS_OVERLAPPEDWINDOW, /* default window */
272 CW_USEDEFAULT, /* Windows decides the position */
273 CW_USEDEFAULT, /* where the window ends up on the screen */
274 544, /* The programs width */
275 375, /* and height in pixels */
276 HWND_DESKTOP, /* The window is a child-window to desktop */
277 NULL, /* No menu */
278 hThisInstance, /* Program Instance handler */
279 NULL /* No Window Creation data */
280 );
281 ShowWindow(hMainWnd, nCmdShow);
282
283 /* Main message loop */
284 while (GetMessage (&msg, NULL, 0, 0))
285 {
287 continue;
290 }
291
293
294 return (int)msg.wParam;
295}
static int argc
Definition: ServiceArgs.c:12
#define msg(x)
Definition: auth_time.c:54
BOOL Display_InitClass(HINSTANCE hInstance)
Definition: display.c:40
#define IDS_FILTER_LIST
Definition: resource.h:13
#define IDI_TT
Definition: resource.h:27
#define IDS_OPEN
Definition: resource.h:18
#define IDS_ERROR_NOCLASS
Definition: resource.h:6
#define OFN_EXPLORER
Definition: commdlg.h:104
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
BOOL WINAPI GetOpenFileNameW(OPENFILENAMEW *ofn)
Definition: filedlg.c:4736
LPWSTR WINAPI GetCommandLineW(VOID)
Definition: proc.c:2013
BOOL WINAPI GetFontResourceInfoW(LPCWSTR lpFileName, DWORD *pdwBufSize, void *lpBuffer, DWORD dwType)
WCHAR g_FontTitle[1024]
Definition: fontview.c:24
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: fontview.c:585
static const WCHAR g_szFontViewClassName[]
Definition: fontview.c:28
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
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
LANGID WINAPI GetUserDefaultUILanguage(void)
Definition: lang.c:816
HWND hMainWnd
Definition: magnifier.c:32
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define argv
Definition: mplay32.c:18
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define MAKELANGID(p, s)
Definition: nls.h:15
#define LANG_HEBREW
Definition: nls.h:67
#define SUBLANG_DEFAULT
Definition: nls.h:168
LPWSTR *WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int *numargs)
Definition: shell32_main.c:80
LPCWSTR lpszClassName
Definition: winuser.h:3225
LPCWSTR lpszMenuName
Definition: winuser.h:3224
HBRUSH hbrBackground
Definition: winuser.h:3223
WNDPROC lpfnWndProc
Definition: winuser.h:3217
UINT cbSize
Definition: winuser.h:3215
int cbWndExtra
Definition: winuser.h:3219
HCURSOR hCursor
Definition: winuser.h:3222
HICON hIconSm
Definition: winuser.h:3226
HINSTANCE hInstance
Definition: winuser.h:3220
UINT style
Definition: winuser.h:3216
int cbClsExtra
Definition: winuser.h:3218
HICON hIcon
Definition: winuser.h:3221
HWND hwndOwner
Definition: commdlg.h:361
DWORD Flags
Definition: commdlg.h:373
LPWSTR lpstrFile
Definition: commdlg.h:367
LPCWSTR lpstrTitle
Definition: commdlg.h:372
LPCWSTR lpstrDefExt
Definition: commdlg.h:376
DWORD lStructSize
Definition: commdlg.h:360
DWORD nMaxFile
Definition: commdlg.h:368
LPCWSTR lpstrFilter
Definition: commdlg.h:363
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
int32_t INT
Definition: typedefs.h:58
BOOL WINAPI SetProcessDefaultLayout(DWORD dwDefaultLayout)
Definition: window.c:1719
#define ZeroMemory
Definition: winbase.h:1712
#define GetModuleHandle
Definition: winbase.h:3762
int WINAPI AddFontResourceW(_In_ LPCWSTR pszFilename)
BOOL WINAPI RemoveFontResourceW(_In_ LPCWSTR)
#define LAYOUT_RTL
Definition: wingdi.h:1371
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define IsDialogMessage
Definition: winuser.h:5808
#define IDC_ARROW
Definition: winuser.h:687
#define CS_DBLCLKS
Definition: winuser.h:651
#define HWND_DESKTOP
Definition: winuser.h:1208
#define GetMessage
Definition: winuser.h:5789
#define LoadIcon
Definition: winuser.h:5812
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
#define LoadCursor
Definition: winuser.h:5811
#define CW_USEDEFAULT
Definition: winuser.h:225
struct _WNDCLASSEXW WNDCLASSEXW
#define DispatchMessage
Definition: winuser.h:5764
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define COLOR_BACKGROUND
Definition: winuser.h:912
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Variable Documentation

◆ g_DisableInstall

BOOL g_DisableInstall = FALSE

Definition at line 26 of file fontview.c.

Referenced by MainWnd_OnCreate(), and wWinMain().

◆ g_fileName

LPCWSTR g_fileName = L""

Definition at line 23 of file fontview.c.

Referenced by MainWnd_OnInstall(), and wWinMain().

◆ g_FontIndex

INT g_FontIndex = 0

Definition at line 20 of file fontview.c.

Referenced by MainWnd_OnCreate(), MainWnd_OnNext(), and MainWnd_OnPrev().

◆ g_FontPrint

BOOL g_FontPrint = FALSE

Definition at line 25 of file fontview.c.

Referenced by MainWnd_OnCreate(), and wWinMain().

◆ g_FontTitle

WCHAR g_FontTitle[1024] = L""

Definition at line 24 of file fontview.c.

Referenced by wWinMain().

◆ g_hInstance

HINSTANCE g_hInstance

Definition at line 19 of file fontview.c.

Referenced by MainWnd_OnCreate(), and wWinMain().

◆ g_LogFonts

LOGFONTW g_LogFonts[64]

Definition at line 22 of file fontview.c.

Referenced by MainWnd_OnCreate(), MainWnd_OnNext(), MainWnd_OnPrev(), and wWinMain().

◆ g_NumFonts

INT g_NumFonts = 0

Definition at line 21 of file fontview.c.

Referenced by MainWnd_OnCreate(), MainWnd_OnNext(), and wWinMain().

◆ g_szFontViewClassName

const WCHAR g_szFontViewClassName[] = L"FontViewWClass"
static

Definition at line 28 of file fontview.c.

Referenced by wWinMain().