ReactOS  r75214
fontsub.cpp File Reference
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
#include <tchar.h>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cassert>
#include "resource.h"
Include dependency graph for fontsub.cpp:

Go to the source code of this file.

Classes

struct  ITEM
 
struct  CHARSET_ENTRY
 

Macros

#define NAME_COLUMN_WIDTH   250
 
#define SUB_COLUMN_WIDTH   250
 
#define MAX_STRING   120
 
#define _countof(array)   (sizeof(array) / sizeof(array[0]))
 

Typedefs

typedef std::wstring STRING
 
typedef std::set< STRINGFONTNAMESET
 
typedef std::vector< ITEMITEMVECTOR
 
typedef struct CHARSET_ENTRY CHARSET_ENTRY
 

Functions

static void trim (STRING &str)
 
static int CALLBACK EnumFontFamExProc (const ENUMLOGFONTW *pelf, const NEWTEXTMETRICW *pntm, int FontType, LPARAM lParam)
 
BOOL DoLoadNames (void)
 
bool ItemCompareByNameAscend (const ITEM &Item1, const ITEM &Item2)
 
bool ItemCompareByNameDescend (const ITEM &Item1, const ITEM &Item2)
 
bool ItemCompareBySubAscend (const ITEM &Item1, const ITEM &Item2)
 
bool ItemCompareBySubDescend (const ITEM &Item1, const ITEM &Item2)
 
void DoSort (INT iColumn, BOOL bAscendant=TRUE)
 
void LV_AddItems (HWND hwnd)
 
BOOL DoLoadItems (void)
 
BOOL DoLoad (void)
 
void LV_InvalidateRow (HWND hwnd, INT iRow=-1)
 
BOOL LV_Init (HWND hwnd)
 
BOOL EditDlg_OnInitDialog (HWND hwnd, HWND hwndFocus, LPARAM lParam)
 
void LV_OnDelete (HWND hwnd, INT iRow=-1)
 
void EditDlg_OnCommand (HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
 
INT_PTR CALLBACK EditDlg_DlgProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
void LV_OnDblClk (HWND hwnd)
 
BOOL MainWnd_OnCreate (HWND hwnd, LPCREATESTRUCT lpCreateStruct)
 
BOOL AddDlg_OnInitDialog (HWND hwnd, HWND hwndFocus, LPARAM lParam)
 
void AddDlg_OnCommand (HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
 
INT_PTR CALLBACK AddDlg_DlgProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
void MainWnd_OnNew (HWND hwnd)
 
BOOL MainWnd_OnUpdateRegistry (HWND hwnd)
 
LPWSTR SkipSpace (LPCWSTR pch)
 
LPWSTR SkipQuoted (LPWSTR pch)
 
void UnescapeHex (const STRING &str, size_t &i, STRING &Ret, BOOL Unicode)
 
void UnescapeOther (const STRING &str, size_t &i, STRING &Ret)
 
void UnescapeChar (const STRING &str, size_t &i, STRING &Ret)
 
STRING Unquote (const STRING &str)
 
BOOL DoParseFile (LPVOID pvContents, DWORD dwSize)
 
BOOL DoImport (HWND hwnd, LPCWSTR pszFile)
 
STRING Escape (const STRING &str)
 
BOOL DoExport (HWND hwnd, LPCWSTR pszFile)
 
void MakeFilter (LPWSTR pszFilter)
 
void MainWnd_OnImport (HWND hwnd)
 
void MainWnd_OnExport (HWND hwnd)
 
void MainWnd_OnReload (HWND hwnd)
 
void MainWnd_OnEdit (HWND hwnd)
 
void MainWnd_OnDelete (HWND hwnd)
 
void MainWnd_OnOpenRegKey (HWND hwnd)
 
void MainWnd_OnAbout (HWND hwnd)
 
void MainWnd_OnCommand (HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
 
void MainWnd_OnDestroy (HWND hwnd)
 
void MainWnd_OnSize (HWND hwnd, UINT state, int cx, int cy)
 
void MainWnd_OnDrawItem (HWND hwnd, const DRAWITEMSTRUCT *lpDrawItem)
 
void MainWnd_OnMeasureItem (HWND hwnd, MEASUREITEMSTRUCT *lpMeasureItem)
 
LRESULT MainWnd_OnNotify (HWND hwnd, int idFrom, NMHDR *pnmhdr)
 
LRESULT MainWnd_OnContextMenu (HWND hwnd, HWND hwndContext, UINT xPos, UINT yPos)
 
void MainWnd_OnActivate (HWND hwnd, UINT state, HWND hwndActDeact, BOOL fMinimized)
 
BOOL EnableProcessPrivileges (LPCWSTR lpPrivilegeName, BOOL bEnable=TRUE)
 
void MainWnd_OnClose (HWND hwnd)
 
LRESULT CALLBACK WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
INT WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, INT nCmdShow)
 

Variables

HINSTANCE g_hInstance = NULL
 
HWND g_hMainWnd = NULL
 
HICON g_hIcon = NULL
 
HWND g_hListView = NULL
 
BOOL g_bModified = FALSE
 
BOOL g_bNeedsReboot = FALSE
 
INT g_iItem = 0
 
LPCWSTR g_pszClassName = L"ReactOS Font Substitutes Editor"
 
LPCWSTR g_pszFileHeader = L"Windows Registry Editor Version 5.00"
 
WCHAR g_szTitle [MAX_STRING]
 
WCHAR g_szNameHead [MAX_STRING]
 
WCHAR g_szSubstituteHead [MAX_STRING]
 
INT g_iSortColumn = 0
 
BOOL g_bSortAscendant = TRUE
 
LPCWSTR g_pszKey
 
FONTNAMESET g_Names
 
ITEMVECTOR g_Items
 
STRING g_strFontName
 
STRING g_strSubstitute
 
BYTE g_CharSet1 = DEFAULT_CHARSET
 
BYTE g_CharSet2 = DEFAULT_CHARSET
 
CHARSET_ENTRY g_CharSetList []
 
const WCHAR g_LongestName [] = L"CHINESEBIG5_CHARSET (136)"
 

Macro Definition Documentation

#define _countof (   array)    (sizeof(array) / sizeof(array[0]))

Definition at line 30 of file fontsub.cpp.

Referenced by _CreateNonspooledPort(), _DoDLLInjection(), CFSDropTarget::_DoDrop(), CFSFolder::_GetDropTarget(), _InitializeLocalSpooler(), _InsertMenuItemW(), _OpenEnvironment(), _ShowContextMenu(), ACDBG_FN(), CNotifyToolbar::AddButton(), CMainWindow::AddCategory(), COpenWithMenu::AddChooseProgramItem(), AddCommasW(), AddDlg_OnCommand(), AddDlg_OnInitDialog(), CMenuToolbarBase::AddPlaceholder(), CStartMenuBtnCtxMenu::AddStartContextMenuItems(), CDefaultContextMenu::AddStaticContextMenusToMenu(), CDefaultContextMenu::AddStaticEntriesForKey(), CTaskSwitchWnd::AddTaskItemButton(), Advanced_AddIcon(), Advanced_LoadAll(), Advanced_LoadTree(), CStartMenuSite::AppendMenu(), CCommonFolder< CRegistryFolder, RegPidlEntry, CRegistryFolderExtractIcon >::BindToObject(), BrsFolder_NewFolder(), CNewMenu::CacheItems(), CConfiguration::CConfiguration(), CFSExtractIcon_CreateInstance(), check_adwExeFlags(), ChkDskNow(), ChooseFolder(), Chr2Str(), CLayerStringList::CLayerStringList(), CAppsListView::CompareFunc(), CompleteSwitch(), Confirm(), ConfirmDialog(), CFileDefExt::CountFolderAndFiles(), CMainToolbar::Create(), CStartButton::Create(), CMainWindow::Create(), CreateJob(), CNewMenu::CreateNewFolder(), CNewMenu::CreateNewItem(), CreateProfile(), CMainWindow::CreateSearchBar(), CDeviceManager::CreateToolBar(), DbgDumpMenuInternal(), Dde_OnConnect(), Dde_OnConnectConfirm(), Dde_OnExecute(), Dde_OnRequest(), Dde_OnWildConnect(), delete_key(), DeleteCurrentAppsDB(), DisplayResourceText(), DisplayTrayProperties(), DoChangePassword(), CDefaultContextMenu::DoCreateNewFolder(), DoDeleteDataObject(), DoEntry(), DoUnlock(), DriverDetailsDlgProc(), CExeDropHandler::Drop(), EditDlg_OnCommand(), EditDlg_OnInitDialog(), EnumAvailableApplications(), EnumerateCallback(), CDefaultContextMenu::EnumerateDynamicContextHandlerForKey(), CEnumRegRoot::EnumerateNext(), EnumerateSoundProfiles(), EnumPrintProcessorDatatypesW(), CTrayWindow::ExecResourceCmd(), COpenWithList::Execute(), ATL::CImage::FileTypeFromExtension(), FormatDrive(), FormatInteger(), FormatMenuString(), GdiCreateClientObjLink(), GdiGetClientObjLink(), GdiRemoveClientObjLink(), CDrvDefExt::GeneralPageProc(), CFileDefExt::GeneralPageProc(), CAddressBand::GetBandInfo(), CExplorerBand::GetBandInfo(), ATL::CImage::GetClsidFromFileType(), CDefaultContextMenu::GetCommandString(), ATL::CImage::GetCommonFilterString(), CRecycleBin::GetDetailsOf(), CCommonFolder< CRegistryFolder, RegPidlEntry, CRegistryFolderExtractIcon >::GetDisplayNameOf(), CShellLink::GetIconLocation(), GetINIFullPath(), CFileVersionInfo::GetLangName(), CShellLink::GetPath(), GetRosInstallCD(), CCommonFolder< CRegistryFolder, RegPidlEntry, CRegistryFolderExtractIcon >::GetUIObjectOf(), CFSDropTarget::GetUniqueFileName(), GetVersionInfoString(), HACKISH_PathResolve(), CTaskSwitchWnd::HandleShellHookMsg(), HCR_RegGetIconW(), Hib_InitDialog(), ImportAppProfile(), ImportSoundEntry(), ImportSoundLabel(), ImportSoundProfiles(), COpenWithDialog::Init(), CMainWindow::InitApplicationsList(), InitAudioDlg(), CMainWindow::InitControls(), CLayerUIPropPage::InitFile(), CFileDefExt::InitFileAttr(), CFileDefExt::InitFilePath(), CFileDefExt::InitFileType(), CDrvDefExt::InitGeneralPage(), CFileDefExt::InitGeneralPage(), CLayerUIPropPage::Initialize(), CDrvDefExt::Initialize(), CDesktopThread::Initialize(), CFileDefExt::Initialize(), CRegistryFolder::Initialize(), CNtObjectFolder::Initialize(), CCommonFolder< CRegistryFolder, RegPidlEntry, CRegistryFolderExtractIcon >::Initialize(), InitializeFileTypesListCtrl(), InitializeFormatDriveDlg(), InitializeGlobalJobList(), InitializePrinterList(), InitializePrintMonitorList(), InitLogs(), CFileDefExt::InitOpensWithField(), InitVolumeControls(), InsertDefaultClusterSizeForFs(), InsertFileType(), CNewMenu::InsertShellNewItems(), IntGdiExtCreatePen(), IntLoadSystemFonts(), KdbpInvokeCliCallbacks(), KdbRegisterCliCallback(), COpenWithList::Load(), CShellLink::Load(), COpenWithList::LoadAppList(), LoadEventLabels(), COpenWithList::LoadInfo(), COpenWithList::LoadMRUList(), COpenWithList::LoadProgIdList(), LoadSoundFiles(), LocalePageDlgProc(), LocalGetPrintProcessorDirectory(), LocalOpenPrinter(), LV_OnDelete(), MainWnd_OnAbout(), MainWnd_OnClose(), MainWnd_OnExport(), MainWnd_OnImport(), MainWnd_OnOpenRegKey(), MapTypeNameToType(), CDefaultContextMenu::MapVerbToCmdId(), MmSysApplet(), CEnumRegKey::NextKey(), CEnumRegKey::NextValue(), CSysTray::NotifyIcon(), OnAddStartMenuItems(), OnClearRecentItems(), CMainWindow::OnCommand(), OnInitSecurityDlg(), OnPaint(), CDownloadDialog::OnProgress(), CTrayWindow::OnSysChar(), OwnerPageDlgProc(), ParserGetInt(), ParserGetString(), PerformancePageRefreshThread(), PickIconDlg(), Power_Init(), Power_Update(), PrintAllJobs(), PrintingThreadProc(), PrintJobDetails(), ProcessStartupItems(), COpenWithMenu::QueryContextMenu(), CNewMenu::QueryContextMenu(), CShellLink::QueryContextMenu(), CTrayWindowCtxMenu::QueryContextMenu(), RegFindRecurse(), RegisterComponent(), RemoveAppFromRegistry(), CNtObjectFolder::ResolveSymLink(), ResolveTarget(), ResourceMessageBox(), RetrieveCurrentModuleNTDirectory(), RSHELL_CStartMenu_CreateInstance(), runCmd(), RunControlPanelApplet(), RunDlgProc(), SdbPackAppCompatData(), SdbpAddDatabaseGuid(), SdbpAddExeMatch(), SdbpAddSingleLayerMatch(), SdbpMatchExe(), service_mainW(), service_process(), SetDefaultPrinterW(), SetDomainComboBox(), CShellLink::SetIconLocation(), SetLockMessage(), CDrivesFolder::SetNameOf(), CShellLink::SetPath(), CShellLink::SetTargetFromPIDLOrPath(), SettingsDlgProc(), SETUP_CreateDevicesListFromEnumerator(), SetWelcomeText(), SH_FormatInteger(), SH_GetTargetTypeByPath(), CShellLink::SH_ShellLinkDlgProc(), Shell_NotifyIconA(), ShellLink_GetVolumeInfo(), ShellShutdownDialog(), SHEmptyRecycleBinW(), SHExplorerParseCmdLine(), shim_dll(), SHOpenFolderAndSelectItems(), ShutdownOnInit(), SoundsDlgProc(), START_TEST(), StartChild(), StartWithDesktop(), Stream_LoadVolume(), test_basetypes(), test_checklinkpath(), Test_CloseDuplicatedSocket(), Test_FontSelection(), Test_FontSelectionEntry(), test_iconlocation(), test_MatchApplications(), test_MatchApplicationsEx(), test_mode_generic(), Test_PathFindOnPathW(), test_runner(), test_specialhandling(), test_TagRef(), TestBind(), TestDllStartup(), TestEnumFontFamilies(), TestIconLocation(), TestMain_PathResolve(), TestRedirection(), TestShellLink(), TestStaticDestruct(), ThreadFunc(), TUILockedSAS(), TUILoggedOutSAS(), UninstallApplication(), UnregisterComponent(), CMainWindow::UpdateApplicationsList(), UpdateAppsDB(), CNotifyToolbar::UpdateButton(), UpdateShutdownDesc(), CDefView::UpdateStatusbar(), CTaskSwitchWnd::UpdateTaskItemButton(), CTrayClockWnd::UpdateWnd(), validate_SDBQUERYRESULT_size(), Validate_ShimData_Win10(), Validate_ShimData_Win10_v2(), Validate_ShimData_Win7(), Volume_Init(), Volume_Update(), WhoamiGroups(), wine_dbgstr_w(), CShellLink::WriteAdvertiseInfo(), and wWinMain().

#define NAME_COLUMN_WIDTH   250

Definition at line 25 of file fontsub.cpp.

Referenced by LV_Init(), and wWinMain().

#define SUB_COLUMN_WIDTH   250

Definition at line 26 of file fontsub.cpp.

Referenced by LV_Init(), and wWinMain().

Typedef Documentation

Definition at line 67 of file fontsub.cpp.

typedef std::vector<ITEM> ITEMVECTOR

Definition at line 68 of file fontsub.cpp.

typedef std::wstring STRING

Definition at line 33 of file fontsub.cpp.

Function Documentation

INT_PTR CALLBACK AddDlg_DlgProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 696 of file fontsub.cpp.

Referenced by MainWnd_OnNew().

697 {
698  switch (uMsg)
699  {
702  }
703  return 0;
704 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
UINT uMsg
Definition: precomp.h:49
BOOL AddDlg_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
Definition: fontsub.cpp:554
void AddDlg_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
Definition: fontsub.cpp:611
#define WM_COMMAND
Definition: winuser.h:1706
#define HANDLE_MSG(hwnd, message, fn)
Definition: windowsx.h:297
#define WM_INITDIALOG
Definition: winuser.h:1705
void AddDlg_OnCommand ( HWND  hwnd,
int  id,
HWND  hwndCtl,
UINT  codeNotify 
)

Definition at line 611 of file fontsub.cpp.

Referenced by AddDlg_DlgProc().

612 {
613  WCHAR szKey[MAX_STRING], szValue[MAX_STRING], sz[MAX_STRING];
614  INT i, iCharSet1, iCharSet2;
615  BYTE CharSet1, CharSet2;
616  STRING key, value;
617  switch (id)
618  {
619  case IDOK:
620  GetDlgItemTextW(hwnd, cmb1, szKey, _countof(szKey));
621  key = szKey;
622  trim(key);
624  if (key.empty() || key == sz)
625  {
630  return;
631  }
632 
633  GetDlgItemTextW(hwnd, cmb2, szValue, _countof(szValue));
634  value = szValue;
635  trim(value);
636  if (value.empty())
637  {
642  return;
643  }
644 
645  iCharSet1 = SendDlgItemMessageW(hwnd, cmb3, CB_GETCURSEL, 0, 0);
646  if (iCharSet1 == CB_ERR)
647  iCharSet1 = 0;
648  iCharSet2 = SendDlgItemMessageW(hwnd, cmb4, CB_GETCURSEL, 0, 0);
649  if (iCharSet2 == CB_ERR)
650  iCharSet2 = 0;
651 
652  CharSet1 = g_CharSetList[iCharSet1].CharSet;
653  CharSet2 = g_CharSetList[iCharSet2].CharSet;
654 
655  for (i = 0; i < (INT)g_Items.size(); ++i)
656  {
657  if (g_Items[i].m_Name == key &&
658  g_Items[i].m_CharSet1 == CharSet1)
659  {
660  WCHAR sz[MAX_STRING];
665  return;
666  }
667  }
668  {
669  ITEM Item(key, value, CharSet1, CharSet2);
670  g_Items.push_back(Item);
671  g_bModified = TRUE;
672 
673  i = (INT)g_Items.size();
674  LV_ITEM LvItem;
675  ZeroMemory(&LvItem, sizeof(LvItem));
676  LvItem.mask = LVIF_PARAM;
677  LvItem.iItem = i;
678  LvItem.lParam = i;
679 
680  LvItem.iSubItem = 0;
682 
683  LvItem.iSubItem = 1;
685  }
686  g_bModified = TRUE;
687  EndDialog(hwnd, IDOK);
688  break;
689  case IDCANCEL:
691  break;
692  }
693 }
Definition: fontsub.cpp:35
#define LV_ITEM
Definition: commctrl.h:2307
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2198
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
HINSTANCE g_hInstance
Definition: fontsub.cpp:46
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: fontsub.cpp:30
#define MAKELPARAM(l, h)
Definition: winuser.h:3894
#define IDS_ENTERNAME
Definition: resource.h:27
#define ZeroMemory
Definition: winbase.h:1621
HWND WINAPI SetFocus(_In_opt_ HWND)
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2378
static void trim(STRING &str)
Definition: fontsub.cpp:107
#define MAX_STRING
Definition: fontsub.cpp:27
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:57
#define CB_GETCURSEL
Definition: winuser.h:1894
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
BOOL g_bModified
Definition: fontsub.cpp:50
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define INT(a)
Definition: assyntax.h:463
smooth NULL
Definition: ftsmooth.c:513
#define IDS_ALREADYEXISTS
Definition: resource.h:35
#define CB_ERR
Definition: winuser.h:2379
ITEMVECTOR g_Items
Definition: fontsub.cpp:71
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
std::wstring STRING
Definition: fontsub.cpp:33
HKEY key
Definition: reg.c:48
#define MB_ICONERROR
Definition: winuser.h:781
GLsizei const GLfloat * value
Definition: glext.h:6069
unsigned char BYTE
Definition: ntddk_ex.h:96
#define cmb2
Definition: dlgs.h:49
#define CB_SETEDITSEL
Definition: winuser.h:1914
#define cmb3
Definition: dlgs.h:50
#define IDS_ENTERNAME2
Definition: resource.h:36
#define LVIF_PARAM
Definition: commctrl.h:2281
#define cmb4
Definition: dlgs.h:51
#define IDCANCEL
Definition: winuser.h:825
#define cmb1
Definition: dlgs.h:48
HWND g_hListView
Definition: fontsub.cpp:49
CHARSET_ENTRY g_CharSetList[]
Definition: fontsub.cpp:83
BYTE CharSet
Definition: fontsub.cpp:79
BOOL AddDlg_OnInitDialog ( HWND  hwnd,
HWND  hwndFocus,
LPARAM  lParam 
)

Definition at line 554 of file fontsub.cpp.

Referenced by AddDlg_DlgProc().

555 {
556  COMBOBOXEXITEMW Item;
557  ZeroMemory(&Item, sizeof(Item));
558  Item.iItem = -1;
559  Item.mask = CBEIF_TEXT;
560 
561  FONTNAMESET::iterator it, end = g_Names.end();
562  for (it = g_Names.begin(); it != end; ++it)
563  {
564  Item.pszText = const_cast<LPWSTR>(it->c_str());
569  }
570  WCHAR szEnterName[MAX_STRING];
571  LoadStringW(g_hInstance, IDS_ENTERNAME, szEnterName, _countof(szEnterName));
572  SetDlgItemTextW(hwnd, cmb1, szEnterName);
574 
575  const INT Count = _countof(g_CharSetList);
576  for (INT i = 0; i < Count; ++i)
577  {
578  Item.pszText = const_cast<LPWSTR>(g_CharSetList[i].DisplayName);
583  }
584 
587  for (INT i = 0; i < Count; ++i)
588  {
590  {
592  }
593  if (g_CharSet2 == g_CharSetList[i].CharSet)
594  {
596  }
597  }
598 
599  SIZE siz;
603  DeleteDC(hDC);
604 
607 
608  return TRUE;
609 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define HDC
Definition: msvc.h:22
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
HINSTANCE g_hInstance
Definition: fontsub.cpp:46
const WCHAR g_LongestName[]
Definition: fontsub.cpp:105
#define CB_SETHORIZONTALEXTENT
Definition: winuser.h:1916
__wchar_t WCHAR
Definition: xmlstorage.h:180
LPCWSTR DisplayName
Definition: fontsub.cpp:80
#define _countof(array)
Definition: fontsub.cpp:30
#define MAKELPARAM(l, h)
Definition: winuser.h:3894
#define IDS_ENTERNAME
Definition: resource.h:27
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define ZeroMemory
Definition: winbase.h:1621
BYTE g_CharSet1
Definition: fontsub.cpp:74
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
GLuint GLuint end
Definition: gl.h:1545
#define lstrlenW
Definition: compat.h:407
#define MAX_STRING
Definition: fontsub.cpp:27
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:57
static void CharSet(RTF_Info *info)
Definition: reader.c:2410
FONTNAMESET g_Names
Definition: fontsub.cpp:70
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define CBEIF_TEXT
Definition: commctrl.h:3753
LONG_PTR LPARAM
Definition: windef.h:231
smooth NULL
Definition: ftsmooth.c:513
LONG cx
Definition: windef.h:347
HDC hDC
Definition: wglext.h:521
#define ComboBox_GetCount(hwndCtl)
Definition: windowsx.h:23
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define DEFAULT_GUI_FONT
Definition: wingdi.h:907
#define CB_SETCURSEL
Definition: winuser.h:1912
#define cmb2
Definition: dlgs.h:49
BOOL WINAPI DeleteDC(_In_ HDC)
#define CB_SETEDITSEL
Definition: winuser.h:1914
#define cmb3
Definition: dlgs.h:50
BYTE g_CharSet2
Definition: fontsub.cpp:75
#define cmb4
Definition: dlgs.h:51
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define cmb1
Definition: dlgs.h:48
#define CBEM_INSERTITEM
Definition: commctrl.h:3812
CHARSET_ENTRY g_CharSetList[]
Definition: fontsub.cpp:83
BOOL WINAPI GetTextExtentPoint32W(_In_ HDC hdc, _In_reads_(c) LPCWSTR lpString, _In_ int c, _Out_ LPSIZE psizl)
BOOL DoExport ( HWND  hwnd,
LPCWSTR  pszFile 
)

Definition at line 1048 of file fontsub.cpp.

Referenced by MainWnd_OnExport().

1049 {
1053  if (hFile == INVALID_HANDLE_VALUE)
1054  return FALSE;
1055 
1056  BOOL bSuccess;
1057  DWORD dwSize, cbWritten;
1058  WCHAR szCharSet1[MAX_STRING], szCharSet2[MAX_STRING];
1059  WCHAR szLine[MAX_STRING * 2 + 4];
1060 
1061  /* write header */
1062  dwSize = lstrlenW(g_pszFileHeader) * sizeof(WCHAR);
1063  bSuccess =
1064  WriteFile(hFile, "\xFF\xFE", 2, &cbWritten, NULL) &&
1065  WriteFile(hFile, g_pszFileHeader, dwSize, &cbWritten, NULL);
1066  if (bSuccess)
1067  {
1068  wsprintfW(szLine, L"\r\n\r\n[HKEY_LOCAL_MACHINE\\%s]\r\n", g_pszKey);
1069  dwSize = lstrlenW(szLine) * sizeof(WCHAR);
1070  bSuccess = WriteFile(hFile, szLine, dwSize, &cbWritten, NULL);
1071  }
1072  if (bSuccess)
1073  {
1074  size_t i, Count = g_Items.size();
1075  for (i = 0; i < Count; ++i)
1076  {
1077  if (g_Items[i].m_CharSet1 != DEFAULT_CHARSET)
1078  wsprintfW(szCharSet1, L",%u", g_Items[i].m_CharSet1);
1079  else
1080  szCharSet1[0] = UNICODE_NULL;
1081 
1082  if (g_Items[i].m_CharSet2 != DEFAULT_CHARSET)
1083  wsprintfW(szCharSet2, L",%u", g_Items[i].m_CharSet2);
1084  else
1085  szCharSet2[0] = UNICODE_NULL;
1086 
1087  STRING Name = Escape(g_Items[i].m_Name);
1088  STRING Substitute = Escape(g_Items[i].m_Substitute);
1089  wsprintfW(szLine, L"\"%s%s\"=\"%s%s\"\r\n",
1090  Name.c_str(), szCharSet1,
1091  Substitute.c_str(), szCharSet2);
1092 
1093  dwSize = lstrlenW(szLine) * sizeof(WCHAR);
1094  if (!WriteFile(hFile, szLine, dwSize, &cbWritten, NULL))
1095  {
1096  bSuccess = FALSE;
1097  break;
1098  }
1099  }
1100  WriteFile(hFile, L"\r\n", 2 * sizeof(WCHAR), &cbWritten, NULL);
1101  }
1102  CloseHandle(hFile);
1103 
1104  if (!bSuccess)
1105  {
1106  DeleteFileW(pszFile);
1107  }
1108 
1109  return bSuccess;
1110 }
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
#define CloseHandle
Definition: compat.h:398
STRING Escape(const STRING &str)
Definition: fontsub.cpp:1030
LPCWSTR g_pszFileHeader
Definition: fontsub.cpp:55
Definition: bidi.c:75
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define WCHAR
Definition: msvc.h:43
#define DEFAULT_CHARSET
Definition: wingdi.h:382
#define lstrlenW
Definition: compat.h:407
#define MAX_STRING
Definition: fontsub.cpp:27
static BOOLEAN bSuccess
Definition: drive.cpp:429
DWORD DWORD
Definition: winlogon.h:75
#define FILE_SHARE_READ
Definition: compat.h:125
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
#define GENERIC_WRITE
Definition: nt_native.h:90
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
smooth NULL
Definition: ftsmooth.c:513
static const WCHAR szLine[]
Definition: dialog.c:116
ITEMVECTOR g_Items
Definition: fontsub.cpp:71
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define FILE_FLAG_WRITE_THROUGH
Definition: disk.h:47
LPCWSTR g_pszKey
Definition: fontsub.cpp:64
unsigned int BOOL
Definition: ntddk_ex.h:94
std::wstring STRING
Definition: fontsub.cpp:33
_In_ PUNICODE_STRING Name
Definition: mrx.h:213
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
_In_ HANDLE hFile
Definition: mswsock.h:90
#define CREATE_ALWAYS
Definition: disk.h:72
DWORD *typedef HANDLE
Definition: winlogon.h:52
#define CreateFileW
Definition: compat.h:400
static VOID Substitute(_Out_writes_bytes_(BufferSize) PWCHAR Buffer, _In_ ULONG BufferSize, _In_ PCWSTR Template, _In_ PCWSTR SystemDriveName, _In_ PCWSTR SystemRootName)
Definition: IoFilesystem.c:220
DWORD dwSize
Definition: wglext.h:734
BOOL DoImport ( HWND  hwnd,
LPCWSTR  pszFile 
)

Definition at line 997 of file fontsub.cpp.

Referenced by MainWnd_OnImport().

998 {
1002  if (hFile == INVALID_HANDLE_VALUE)
1003  return FALSE;
1004 
1005  BOOL bSuccess = FALSE;
1006  DWORD dwSize = GetFileSize(hFile, NULL);
1007  if (dwSize != 0xFFFFFFFF)
1008  {
1009  std::vector<BYTE> Contents(dwSize + 2);
1010  DWORD cbRead;
1011  if (ReadFile(hFile, &Contents[0], dwSize, &cbRead, NULL) &&
1012  cbRead == dwSize)
1013  {
1014  /* check BOM */
1015  if (memcmp(&Contents[0], "\xFF\xFE", 2) == 0)
1016  {
1017  bSuccess = DoParseFile(&Contents[2], dwSize - 2);
1018  }
1019  else
1020  {
1021  bSuccess = DoParseFile(&Contents[0], dwSize);
1022  }
1023  }
1024  }
1025  CloseHandle(hFile);
1026 
1027  return bSuccess;
1028 }
#define CloseHandle
Definition: compat.h:398
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
static BOOLEAN bSuccess
Definition: drive.cpp:429
DWORD DWORD
Definition: winlogon.h:75
#define FILE_SHARE_READ
Definition: compat.h:125
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:513
#define OPEN_EXISTING
Definition: compat.h:426
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:461
BOOL DoParseFile(LPVOID pvContents, DWORD dwSize)
Definition: fontsub.cpp:915
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
#define GENERIC_READ
Definition: compat.h:124
_In_ HANDLE hFile
Definition: mswsock.h:90
DWORD *typedef HANDLE
Definition: winlogon.h:52
#define FILE_FLAG_SEQUENTIAL_SCAN
Definition: disk.h:43
#define CreateFileW
Definition: compat.h:400
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
DWORD dwSize
Definition: wglext.h:734
BOOL DoLoad ( void  )

Definition at line 310 of file fontsub.cpp.

Referenced by MainWnd_OnCreate(), and MainWnd_OnReload().

311 {
312  return DoLoadNames() && DoLoadItems();
313 }
BOOL DoLoadItems(void)
Definition: fontsub.cpp:256
BOOL DoLoadNames(void)
Definition: fontsub.cpp:145
BOOL DoLoadItems ( void  )

Definition at line 256 of file fontsub.cpp.

Referenced by DoLoad().

257 {
258  ITEMVECTOR Items;
259 
260  HKEY hKey = NULL;
262  if (hKey == NULL)
263  return FALSE;
264 
265  WCHAR szName[MAX_STRING], szValue[MAX_STRING];
266  DWORD cbName, cbValue;
267  for (DWORD dwIndex = 0; ; ++dwIndex)
268  {
269  cbName = sizeof(szName);
270  cbValue = sizeof(szValue);
271  LONG Error = RegEnumValueW(hKey, dwIndex, szName, &cbName,
272  NULL, NULL, (LPBYTE)szValue, &cbValue);
273  if (Error != ERROR_SUCCESS)
274  break;
275 
276  BYTE CharSet1 = DEFAULT_CHARSET, CharSet2 = DEFAULT_CHARSET;
277  LPWSTR pch;
278 
279  pch = wcsrchr(szName, L',');
280  if (pch)
281  {
282  *pch = 0;
283  CharSet1 = (BYTE)_wtoi(pch + 1);
284  }
285 
286  pch = wcsrchr(szValue, L',');
287  if (pch)
288  {
289  *pch = 0;
290  CharSet2 = (BYTE)_wtoi(pch + 1);
291  }
292 
293  ITEM Item(szName, szValue, CharSet1, CharSet2);
294  trim(Item.m_Name);
295  trim(Item.m_Substitute);
296  Items.push_back(Item);
297  }
298 
299  RegCloseKey(hKey);
300 
301  g_Items = Items;
303  DoSort(0, TRUE);
304  g_bModified = FALSE;
306 
307  return !g_Items.empty();
308 }
std::vector< ITEM > ITEMVECTOR
Definition: fontsub.cpp:68
Definition: fontsub.cpp:35
BOOL g_bNeedsReboot
Definition: fontsub.cpp:51
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
Definition: bidi.c:75
#define KEY_READ
Definition: nt_native.h:1023
__wchar_t WCHAR
Definition: xmlstorage.h:180
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
unsigned char * LPBYTE
Definition: typedefs.h:53
#define DEFAULT_CHARSET
Definition: wingdi.h:382
static void trim(STRING &str)
Definition: fontsub.cpp:107
#define MAX_STRING
Definition: fontsub.cpp:27
DWORD DWORD
Definition: winlogon.h:75
BOOL g_bModified
Definition: fontsub.cpp:50
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
LONG WINAPI RegEnumValueW(_In_ HKEY hKey, _In_ DWORD index, _Out_ LPWSTR value, _Inout_ PDWORD val_count, _Reserved_ PDWORD reserved, _Out_opt_ PDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ PDWORD count)
Definition: reg.c:2867
smooth NULL
Definition: ftsmooth.c:513
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcsrchr(_In_z_ const wchar_t *_Str, _In_ wchar_t _Ch)
ITEMVECTOR g_Items
Definition: fontsub.cpp:71
LPCWSTR g_pszKey
Definition: fontsub.cpp:64
HANDLE HKEY
Definition: registry.h:24
void DoSort(INT iColumn, BOOL bAscendant=TRUE)
Definition: fontsub.cpp:180
BOOL Error
Definition: chkdsk.c:63
unsigned char BYTE
Definition: ntddk_ex.h:96
void LV_AddItems(HWND hwnd)
Definition: fontsub.cpp:233
static const WCHAR szName[]
Definition: msipriv.h:1212
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
WCHAR * pch
Definition: msvc.h:81
WCHAR * LPWSTR
Definition: xmlstorage.h:184
HWND g_hListView
Definition: fontsub.cpp:49
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
BOOL DoLoadNames ( void  )

Definition at line 145 of file fontsub.cpp.

Referenced by DoLoad().

146 {
147  g_Names.clear();
148 
149  LOGFONTW lf;
150  ZeroMemory(&lf, sizeof(lf));
152 
155  DeleteDC(hDC);
156 
157  return !g_Names.empty();
158 }
#define HDC
Definition: msvc.h:22
int WINAPI EnumFontFamiliesExW(_In_ HDC, _In_ PLOGFONTW, _In_ FONTENUMPROCW, _In_ LPARAM, _In_ DWORD)
BYTE lfCharSet
Definition: dimm.idl:67
#define ZeroMemory
Definition: winbase.h:1621
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define DEFAULT_CHARSET
Definition: wingdi.h:382
FONTNAMESET g_Names
Definition: fontsub.cpp:70
smooth NULL
Definition: ftsmooth.c:513
HDC hDC
Definition: wglext.h:521
BOOL WINAPI DeleteDC(_In_ HDC)
FARPROC FONTENUMPROCW
Definition: wingdi.h:2866
static int CALLBACK EnumFontFamExProc(const ENUMLOGFONTW *pelf, const NEWTEXTMETRICW *pntm, int FontType, LPARAM lParam)
Definition: fontsub.cpp:123
BOOL DoParseFile ( LPVOID  pvContents,
DWORD  dwSize 
)

Definition at line 915 of file fontsub.cpp.

Referenced by DoImport().

916 {
917  ITEMVECTOR Items;
918 
919  LPWSTR pch, pchSep, pchStart = (LPWSTR)pvContents;
920 
921  pchStart[dwSize / sizeof(WCHAR)] = UNICODE_NULL;
922 
923  // check header
924  const DWORD cbHeader = lstrlenW(g_pszFileHeader) * sizeof(WCHAR);
925  if (memcmp(pchStart, g_pszFileHeader, cbHeader) != 0)
926  return FALSE;
927 
928  pchStart += cbHeader / sizeof(WCHAR);
929 
930  // find the key
931  WCHAR szKey[MAX_STRING];
932  wsprintfW(szKey, L"[HKEY_LOCAL_MACHINE\\%s]", g_pszKey);
933  pch = wcsstr(pchStart, szKey);
934  if (pch == NULL)
935  return FALSE;
936 
937  pchStart = pch + lstrlenW(szKey);
938 
939  for (;;)
940  {
941  pchStart = SkipSpace(pchStart);
942  if (*pchStart == UNICODE_NULL || *pchStart == L'[')
943  break;
944 
945  pch = wcschr(pchStart, L'\n');
946  if (pch)
947  *pch = UNICODE_NULL;
948 
949  pchSep = SkipQuoted(pchStart);
950  if (*pchSep == L'=')
951  {
952  *pchSep = UNICODE_NULL;
953 
954  STRING key = pchStart;
955  trim(key);
956  key = Unquote(key);
957 
958  STRING value = pchSep + 1;
959  trim(value);
960  value = Unquote(value);
961 
962  BYTE CharSet1 = DEFAULT_CHARSET, CharSet2 = DEFAULT_CHARSET;
963 
964  size_t pos;
965  pos = key.find(L',');
966  if (pos != STRING::npos)
967  {
968  CharSet1 = (BYTE)_wtoi(&key[pos + 1]);
969  key.resize(pos);
970  trim(key);
971  }
972  pos = value.find(L',');
973  if (pos != STRING::npos)
974  {
975  CharSet2 = (BYTE)_wtoi(&value[pos + 1]);
976  value.resize(pos);
977  trim(value);
978  }
979 
980  ITEM Item(key, value, CharSet1, CharSet2);
981  Items.push_back(Item);
982  }
983 
984  if (pch == NULL)
985  break;
986 
987  pchStart = pch + 1;
988  }
989 
990  g_Items = Items;
991  g_bModified = TRUE;
992 
994  return TRUE;
995 }
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
std::vector< ITEM > ITEMVECTOR
Definition: fontsub.cpp:68
Definition: fontsub.cpp:35
Definition: get.c:139
#define TRUE
Definition: types.h:120
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
LPCWSTR g_pszFileHeader
Definition: fontsub.cpp:55
Definition: bidi.c:75
__wchar_t WCHAR
Definition: xmlstorage.h:180
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
static const size_t npos
Definition: _string_npos.h:26
#define WCHAR
Definition: msvc.h:43
#define DEFAULT_CHARSET
Definition: wingdi.h:382
static void trim(STRING &str)
Definition: fontsub.cpp:107
#define lstrlenW
Definition: compat.h:407
#define MAX_STRING
Definition: fontsub.cpp:27
DWORD DWORD
Definition: winlogon.h:75
BOOL g_bModified
Definition: fontsub.cpp:50
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
smooth NULL
Definition: ftsmooth.c:513
ITEMVECTOR g_Items
Definition: fontsub.cpp:71
LPCWSTR g_pszKey
Definition: fontsub.cpp:64
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
std::wstring STRING
Definition: fontsub.cpp:33
LPWSTR SkipSpace(LPCWSTR pch)
Definition: fontsub.cpp:767
unsigned char BYTE
Definition: ntddk_ex.h:96
void LV_AddItems(HWND hwnd)
Definition: fontsub.cpp:233
STRING Unquote(const STRING &str)
Definition: fontsub.cpp:898
LPWSTR SkipQuoted(LPWSTR pch)
Definition: fontsub.cpp:776
WCHAR * pch
Definition: msvc.h:81
WCHAR * LPWSTR
Definition: xmlstorage.h:184
HWND g_hListView
Definition: fontsub.cpp:49
Definition: path.c:42
DWORD dwSize
Definition: wglext.h:734
void DoSort ( INT  iColumn,
BOOL  bAscendant = TRUE 
)

Definition at line 180 of file fontsub.cpp.

Referenced by DoLoadItems(), and MainWnd_OnNotify().

181 {
183  ZeroMemory(&Column, sizeof(Column));
184  Column.mask = LVCF_IMAGE | LVCF_SUBITEM;
185  Column.iImage = 2;
186  Column.iSubItem = 0;
187  ListView_SetColumn(g_hListView, 0, &Column);
188  Column.iSubItem = 1;
189  ListView_SetColumn(g_hListView, 1, &Column);
190 
191  switch (iColumn)
192  {
193  case 0:
194  Column.iSubItem = 0;
195  if (bAscendant)
196  {
197  std::sort(g_Items.begin(), g_Items.end(),
199  Column.iImage = 0;
200  ListView_SetColumn(g_hListView, 0, &Column);
201  }
202  else
203  {
204  std::sort(g_Items.begin(), g_Items.end(),
206  Column.iImage = 1;
207  ListView_SetColumn(g_hListView, 0, &Column);
208  }
209  break;
210  case 1:
211  Column.iSubItem = 1;
212  if (bAscendant)
213  {
214  std::sort(g_Items.begin(), g_Items.end(),
216  Column.iImage = 0;
217  ListView_SetColumn(g_hListView, 1, &Column);
218  }
219  else
220  {
221  std::sort(g_Items.begin(), g_Items.end(),
223  Column.iImage = 1;
224  ListView_SetColumn(g_hListView, 1, &Column);
225  }
226  break;
227  }
228  g_iSortColumn = iColumn;
229  g_bSortAscendant = bAscendant;
231 }
#define ListView_SetColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2599
#define TRUE
Definition: types.h:120
bool ItemCompareByNameDescend(const ITEM &Item1, const ITEM &Item2)
Definition: fontsub.cpp:165
bool ItemCompareBySubDescend(const ITEM &Item1, const ITEM &Item2)
Definition: fontsub.cpp:175
_STLP_MOVE_TO_STD_NAMESPACE void sort(_RandomAccessIter __first, _RandomAccessIter __last)
Definition: _algo.c:993
#define LV_COLUMN
Definition: commctrl.h:2517
#define ZeroMemory
Definition: winbase.h:1621
bool ItemCompareByNameAscend(const ITEM &Item1, const ITEM &Item2)
Definition: fontsub.cpp:160
INT g_iSortColumn
Definition: fontsub.cpp:61
#define LVCF_SUBITEM
Definition: commctrl.h:2559
smooth NULL
Definition: ftsmooth.c:513
ITEMVECTOR g_Items
Definition: fontsub.cpp:71
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
UINTN Column
Definition: acefiex.h:238
#define LVCF_IMAGE
Definition: commctrl.h:2560
BOOL g_bSortAscendant
Definition: fontsub.cpp:62
HWND g_hListView
Definition: fontsub.cpp:49
bool ItemCompareBySubAscend(const ITEM &Item1, const ITEM &Item2)
Definition: fontsub.cpp:170
INT_PTR CALLBACK EditDlg_DlgProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 505 of file fontsub.cpp.

Referenced by LV_OnDblClk().

506 {
507  switch (uMsg)
508  {
511  }
512  return 0;
513 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
BOOL EditDlg_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
Definition: fontsub.cpp:380
UINT uMsg
Definition: precomp.h:49
void EditDlg_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
Definition: fontsub.cpp:461
#define WM_COMMAND
Definition: winuser.h:1706
#define HANDLE_MSG(hwnd, message, fn)
Definition: windowsx.h:297
#define WM_INITDIALOG
Definition: winuser.h:1705
void EditDlg_OnCommand ( HWND  hwnd,
int  id,
HWND  hwndCtl,
UINT  codeNotify 
)

Definition at line 461 of file fontsub.cpp.

Referenced by EditDlg_DlgProc().

462 {
463  WCHAR szValue[MAX_STRING];
464  STRING str;
465  INT i;
466 
467  switch (id)
468  {
469  case IDOK:
470  GetDlgItemTextW(hwnd, cmb2, szValue, _countof(szValue));
471  str = szValue;
472  trim(str);
473  if (str.empty())
474  {
475  WCHAR sz[MAX_STRING];
480  return;
481  }
482 
483  g_Items[g_iItem].m_CharSet2 = DEFAULT_CHARSET;
485  if (i != CB_ERR)
486  {
487  g_Items[g_iItem].m_CharSet2 = g_CharSetList[i].CharSet;
488  }
489  g_Items[g_iItem].m_Substitute = str;
490 
491  g_bModified = TRUE;
492  EndDialog(hwnd, IDOK);
493  break;
494  case IDCANCEL:
496  break;
497  case psh1:
499  EndDialog(hwnd, psh1);
500  break;
501  }
502 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2198
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
HINSTANCE g_hInstance
Definition: fontsub.cpp:46
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: fontsub.cpp:30
#define MAKELPARAM(l, h)
Definition: winuser.h:3894
HWND WINAPI SetFocus(_In_opt_ HWND)
INT g_iItem
Definition: fontsub.cpp:52
#define DEFAULT_CHARSET
Definition: wingdi.h:382
static void trim(STRING &str)
Definition: fontsub.cpp:107
#define MAX_STRING
Definition: fontsub.cpp:27
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:57
#define CB_GETCURSEL
Definition: winuser.h:1894
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
BOOL g_bModified
Definition: fontsub.cpp:50
GLenum GLclampf GLint i
Definition: glfuncs.h:14
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:513
#define CB_ERR
Definition: winuser.h:2379
ITEMVECTOR g_Items
Definition: fontsub.cpp:71
#define psh1
Definition: dlgs.h:112
void LV_OnDelete(HWND hwnd, INT iRow=-1)
Definition: fontsub.cpp:434
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
std::wstring STRING
Definition: fontsub.cpp:33
#define MB_ICONERROR
Definition: winuser.h:781
#define cmb2
Definition: dlgs.h:49
#define CB_SETEDITSEL
Definition: winuser.h:1914
#define IDS_ENTERNAME2
Definition: resource.h:36
#define cmb4
Definition: dlgs.h:51
#define IDCANCEL
Definition: winuser.h:825
HWND g_hListView
Definition: fontsub.cpp:49
CHARSET_ENTRY g_CharSetList[]
Definition: fontsub.cpp:83
BYTE CharSet
Definition: fontsub.cpp:79
BOOL EditDlg_OnInitDialog ( HWND  hwnd,
HWND  hwndFocus,
LPARAM  lParam 
)

Definition at line 380 of file fontsub.cpp.

Referenced by EditDlg_DlgProc().

381 {
382  COMBOBOXEXITEMW Item;
383  ZeroMemory(&Item, sizeof(Item));
384  Item.mask = CBEIF_TEXT;
385 
386  FONTNAMESET::iterator it, end = g_Names.end();
387  for (it = g_Names.begin(); it != end; ++it)
388  {
389  Item.pszText = const_cast<LPWSTR>(it->c_str());
392  }
395 
396  const INT Count = _countof(g_CharSetList);
397  for (INT i = 0; i < Count; ++i)
398  {
399  Item.pszText = const_cast<LPWSTR>(g_CharSetList[i].DisplayName);
404  }
405 
408  for (INT i = 0; i < Count; ++i)
409  {
411  {
413  }
414  if (g_CharSet2 == g_CharSetList[i].CharSet)
415  {
417  }
418  }
419 
420  SIZE siz;
424  DeleteDC(hDC);
425 
428 
430 
431  return TRUE;
432 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define HDC
Definition: msvc.h:22
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
const WCHAR g_LongestName[]
Definition: fontsub.cpp:105
#define CB_SETHORIZONTALEXTENT
Definition: winuser.h:1916
STRING g_strFontName
Definition: fontsub.cpp:72
LPCWSTR DisplayName
Definition: fontsub.cpp:80
#define _countof(array)
Definition: fontsub.cpp:30
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define ZeroMemory
Definition: winbase.h:1621
BYTE g_CharSet1
Definition: fontsub.cpp:74
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
GLuint GLuint end
Definition: gl.h:1545
#define lstrlenW
Definition: compat.h:407
int32_t INT
Definition: typedefs.h:57
static void CharSet(RTF_Info *info)
Definition: reader.c:2410
FONTNAMESET g_Names
Definition: fontsub.cpp:70
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define FALSE
Definition: types.h:117
#define CBEIF_TEXT
Definition: commctrl.h:3753
LONG_PTR LPARAM
Definition: windef.h:231
smooth NULL
Definition: ftsmooth.c:513
LONG cx
Definition: windef.h:347
HDC hDC
Definition: wglext.h:521
#define ComboBox_GetCount(hwndCtl)
Definition: windowsx.h:23
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
STRING g_strSubstitute
Definition: fontsub.cpp:73
#define DEFAULT_GUI_FONT
Definition: wingdi.h:907
#define edt1
Definition: dlgs.h:65
#define CB_SETCURSEL
Definition: winuser.h:1912
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define cmb2
Definition: dlgs.h:49
BOOL WINAPI DeleteDC(_In_ HDC)
#define cmb3
Definition: dlgs.h:50
BYTE g_CharSet2
Definition: fontsub.cpp:75
#define cmb4
Definition: dlgs.h:51
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define CBEM_INSERTITEM
Definition: commctrl.h:3812
CHARSET_ENTRY g_CharSetList[]
Definition: fontsub.cpp:83
BOOL WINAPI GetTextExtentPoint32W(_In_ HDC hdc, _In_reads_(c) LPCWSTR lpString, _In_ int c, _Out_ LPSIZE psizl)
BOOL EnableProcessPrivileges ( LPCWSTR  lpPrivilegeName,
BOOL  bEnable = TRUE 
)

Definition at line 1443 of file fontsub.cpp.

Referenced by MainWnd_OnClose().

1444 {
1445  HANDLE hToken;
1446  LUID luid;
1447  TOKEN_PRIVILEGES tokenPrivileges;
1448  BOOL Ret;
1449 
1452  &hToken);
1453  if (!Ret)
1454  return Ret; // failure
1455 
1456  Ret = ::LookupPrivilegeValueW(NULL, lpPrivilegeName, &luid);
1457  if (Ret)
1458  {
1459  tokenPrivileges.PrivilegeCount = 1;
1460  tokenPrivileges.Privileges[0].Luid = luid;
1461  tokenPrivileges.Privileges[0].Attributes = bEnable ? SE_PRIVILEGE_ENABLED : 0;
1462 
1463  Ret = ::AdjustTokenPrivileges(hToken, FALSE, &tokenPrivileges, 0, 0, 0);
1464  }
1465 
1466  ::CloseHandle(hToken);
1467  return Ret;
1468 }
#define CloseHandle
Definition: compat.h:398
BOOL WINAPI LookupPrivilegeValueW(LPCWSTR lpSystemName, LPCWSTR lpPrivilegeName, PLUID lpLuid)
Definition: misc.c:782
$ULONG PrivilegeCount
Definition: setypes.h:969
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:513
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TOKEN_QUERY
Definition: setypes.h:874
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1183
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
Definition: security.c:366
DWORD *typedef HANDLE
Definition: winlogon.h:52
_In_ BOOL bEnable
Definition: winddi.h:3426
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:286
LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY]
Definition: setypes.h:970
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:876
static int CALLBACK EnumFontFamExProc ( const ENUMLOGFONTW pelf,
const NEWTEXTMETRICW pntm,
int  FontType,
LPARAM  lParam 
)
static

Definition at line 123 of file fontsub.cpp.

Referenced by DoLoadNames().

127 {
128  switch (pelf->elfFullName[0])
129  {
130  case UNICODE_NULL: case L'@':
131  break;
132  default:
133  g_Names.insert((const WCHAR *)pelf->elfFullName);
134  }
135  switch (pelf->elfLogFont.lfFaceName[0])
136  {
137  case UNICODE_NULL: case L'@':
138  break;
139  default:
140  g_Names.insert(pelf->elfLogFont.lfFaceName);
141  }
142  return 1;
143 }
LOGFONTW elfLogFont
Definition: wingdi.h:2668
Definition: bidi.c:75
__wchar_t WCHAR
Definition: xmlstorage.h:180
FONTNAMESET g_Names
Definition: fontsub.cpp:70
#define UNICODE_NULL
WCHAR elfFullName[LF_FULLFACESIZE]
Definition: wingdi.h:2669
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
STRING Escape ( const STRING str)

Definition at line 1030 of file fontsub.cpp.

Referenced by add_mf_comment(), DECLARE_INTERFACE_(), DoExport(), PlayMetaFileRecord(), print_something(), and test_pscript_printer_dc().

1031 {
1032  STRING Ret;
1033  for (size_t i = 0; i < str.size(); ++i)
1034  {
1035  switch (str[i])
1036  {
1037  case L'"': case L'\\':
1038  Ret += L'\\';
1039  Ret += str[i];
1040  break;
1041  default:
1042  Ret += str[i];
1043  }
1044  }
1045  return Ret;
1046 }
Definition: bidi.c:75
GLenum GLclampf GLint i
Definition: glfuncs.h:14
const WCHAR * str
std::wstring STRING
Definition: fontsub.cpp:33
bool ItemCompareByNameAscend ( const ITEM Item1,
const ITEM Item2 
)
inline

Definition at line 160 of file fontsub.cpp.

Referenced by DoSort().

161 {
162  return Item1.m_Name < Item2.m_Name;
163 }
STRING m_Name
Definition: fontsub.cpp:37
bool ItemCompareByNameDescend ( const ITEM Item1,
const ITEM Item2 
)
inline

Definition at line 165 of file fontsub.cpp.

Referenced by DoSort().

166 {
167  return Item1.m_Name > Item2.m_Name;
168 }
STRING m_Name
Definition: fontsub.cpp:37
bool ItemCompareBySubAscend ( const ITEM Item1,
const ITEM Item2 
)
inline

Definition at line 170 of file fontsub.cpp.

Referenced by DoSort().

171 {
172  return Item1.m_Substitute < Item2.m_Substitute;
173 }
STRING m_Substitute
Definition: fontsub.cpp:37
bool ItemCompareBySubDescend ( const ITEM Item1,
const ITEM Item2 
)
inline

Definition at line 175 of file fontsub.cpp.

Referenced by DoSort().

176 {
177  return Item1.m_Substitute > Item2.m_Substitute;
178 }
STRING m_Substitute
Definition: fontsub.cpp:37
void LV_AddItems ( HWND  hwnd)

Definition at line 233 of file fontsub.cpp.

Referenced by DoLoadItems(), and DoParseFile().

234 {
236 
237  LV_ITEM Item;
238  ZeroMemory(&Item, sizeof(Item));
239  Item.mask = LVIF_PARAM;
240 
241  const INT Count = INT(g_Items.size());
242  for (INT i = 0; i < Count; ++i)
243  {
244  Item.iItem = i;
245  Item.iSubItem = 0;
246  Item.lParam = i;
247  ListView_InsertItem(hwnd, &Item);
248 
249  Item.iItem = i;
250  Item.iSubItem = 1;
251  Item.lParam = i;
252  ListView_InsertItem(hwnd, &Item);
253  }
254 }
#define LV_ITEM
Definition: commctrl.h:2307
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define ZeroMemory
Definition: winbase.h:1621
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2378
int32_t INT
Definition: typedefs.h:57
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define INT(a)
Definition: assyntax.h:463
ITEMVECTOR g_Items
Definition: fontsub.cpp:71
#define LVIF_PARAM
Definition: commctrl.h:2281
#define ListView_DeleteAllItems(hwnd)
Definition: commctrl.h:2384
BOOL LV_Init ( HWND  hwnd)

Definition at line 328 of file fontsub.cpp.

Referenced by MainWnd_OnCreate().

329 {
332 
333  HIMAGELIST hImageList;
334  hImageList = ImageList_Create(12, 12, ILC_COLOR8 | ILC_MASK, 2, 2);
335 
336  HBITMAP hbm;
339  assert(hbm);
340  ImageList_AddMasked(hImageList, hbm, RGB(192, 192, 192));
341  DeleteObject(hbm);
342 
345  assert(hbm);
346  ImageList_AddMasked(hImageList, hbm, RGB(192, 192, 192));
347  DeleteObject(hbm);
348 
351  assert(hbm);
352  ImageList_AddMasked(hImageList, hbm, RGB(192, 192, 192));
353  DeleteObject(hbm);
354 
355  ListView_SetImageList(hwnd, hImageList, LVSIL_SMALL);
356 
358  ZeroMemory(&Column, sizeof(Column));
359  Column.mask = LVCF_FMT | LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH | LVCF_IMAGE;
360  Column.fmt = LVCFMT_LEFT;
361 
362  Column.cx = NAME_COLUMN_WIDTH;
363  Column.pszText = g_szNameHead;
364  Column.iSubItem = 0;
365  Column.iImage = 0;
366  ListView_InsertColumn(hwnd, 0, &Column);
367 
368  Column.cx = SUB_COLUMN_WIDTH;
369  Column.pszText = g_szSubstituteHead;
370  Column.iSubItem = 1;
371  Column.iImage = 2;
372  ListView_InsertColumn(hwnd, 1, &Column);
373 
375  ListView_SetItemState(hwnd, 0, State, State);
376 
377  return TRUE;
378 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define TRUE
Definition: types.h:120
WCHAR g_szSubstituteHead[MAX_STRING]
Definition: fontsub.cpp:59
#define LVCF_WIDTH
Definition: commctrl.h:2557
#define HBITMAP
Definition: msvc.h:28
#define LVSIL_SMALL
Definition: commctrl.h:2269
HINSTANCE g_hInstance
Definition: fontsub.cpp:46
#define LVCF_TEXT
Definition: commctrl.h:2558
#define LVS_EX_FULLROWSELECT
Definition: commctrl.h:2704
#define LVCFMT_LEFT
Definition: commctrl.h:2568
#define assert(x)
Definition: debug.h:53
#define ZeroMemory
Definition: winbase.h:1621
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define LVCF_SUBITEM
Definition: commctrl.h:2559
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2606
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:764
#define ListView_SetItemState(hwndLV, i, data, mask)
Definition: commctrl.h:2643
#define ListView_SetImageList(hwnd, himl, iImageList)
Definition: commctrl.h:2274
#define LVIS_SELECTED
Definition: commctrl.h:2289
WCHAR g_szNameHead[MAX_STRING]
Definition: fontsub.cpp:58
#define RGB(r, g, b)
Definition: wingdi.h:2909
#define ListView_SetExtendedListViewStyle(hwndLV, dw)
Definition: commctrl.h:2695
#define LVS_EX_GRIDLINES
Definition: commctrl.h:2699
#define SUB_COLUMN_WIDTH
Definition: fontsub.cpp:26
#define ILC_MASK
Definition: commctrl.h:336
UINTN Column
Definition: acefiex.h:238
#define LR_LOADMAP3DCOLORS
Definition: winuser.h:1077
#define LVCF_FMT
Definition: commctrl.h:2556
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
#define LR_CREATEDIBSECTION
Definition: winuser.h:1078
unsigned int UINT
Definition: ndis.h:50
#define IMAGE_BITMAP
Definition: winuser.h:211
#define ILC_COLOR8
Definition: commctrl.h:340
#define LV_COLUMNW
Definition: commctrl.h:2516
#define LoadImage
Definition: winuser.h:5660
INT WINAPI ImageList_AddMasked(HIMAGELIST himl, HBITMAP hBitmap, COLORREF clrMask)
Definition: imagelist.c:523
#define LVCF_IMAGE
Definition: commctrl.h:2560
#define LVIS_FOCUSED
Definition: commctrl.h:2288
#define NAME_COLUMN_WIDTH
Definition: fontsub.cpp:25
void LV_InvalidateRow ( HWND  hwnd,
INT  iRow = -1 
)

Definition at line 315 of file fontsub.cpp.

316 {
317  if (iRow == -1)
319  if (iRow == -1)
320  return;
321 
322  RECT Rect;
323  LPRECT GccIsWhining = &Rect;
324  ListView_GetItemRect(hwnd, iRow, GccIsWhining, LVIR_BOUNDS);
325  InvalidateRect(hwnd, &Rect, FALSE);
326 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2404
#define ListView_GetItemRect(hwnd, i, prc, code)
Definition: commctrl.h:2448
#define LVNI_SELECTED
Definition: commctrl.h:2394
#define FALSE
Definition: types.h:117
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define LVIR_BOUNDS
Definition: commctrl.h:2442
struct Rect Rect
void LV_OnDblClk ( HWND  hwnd)

Definition at line 515 of file fontsub.cpp.

Referenced by MainWnd_OnEdit(), and MainWnd_OnNotify().

516 {
518  if (g_iItem == -1)
519  return;
520 
521  g_strFontName = g_Items[g_iItem].m_Name;
522  g_strSubstitute = g_Items[g_iItem].m_Substitute;
523  g_CharSet1 = g_Items[g_iItem].m_CharSet1;
524  g_CharSet2 = g_Items[g_iItem].m_CharSet2;
525 
529 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2404
#define TRUE
Definition: types.h:120
HINSTANCE g_hInstance
Definition: fontsub.cpp:46
STRING g_strFontName
Definition: fontsub.cpp:72
BYTE g_CharSet1
Definition: fontsub.cpp:74
HWND g_hMainWnd
Definition: fontsub.cpp:47
#define LVNI_SELECTED
Definition: commctrl.h:2394
INT g_iItem
Definition: fontsub.cpp:52
#define DialogBox
Definition: winuser.h:5606
smooth NULL
Definition: ftsmooth.c:513
ITEMVECTOR g_Items
Definition: fontsub.cpp:71
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
STRING g_strSubstitute
Definition: fontsub.cpp:73
INT_PTR CALLBACK EditDlg_DlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: fontsub.cpp:505
BYTE g_CharSet2
Definition: fontsub.cpp:75
#define IDD_EDIT
Definition: resource.h:22
HWND g_hListView
Definition: fontsub.cpp:49
void LV_OnDelete ( HWND  hwnd,
INT  iRow = -1 
)

Definition at line 434 of file fontsub.cpp.

Referenced by EditDlg_OnCommand(), MainWnd_OnDelete(), and MainWnd_OnNotify().

435 {
436  if (iRow == -1)
438  if (iRow == -1)
439  return;
440 
442  ListView_SetItemState(g_hListView, iRow, State, State);
443 
444  WCHAR sz[MAX_STRING];
448  {
449  return;
450  }
451 
452  ListView_DeleteItem(hwnd, iRow);
453  g_Items.erase(g_Items.begin() + iRow);
454  g_bModified = TRUE;
455 
456  ListView_SetItemState(g_hListView, iRow, State, State);
457 
459 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2404
#define TRUE
Definition: types.h:120
#define IDYES
Definition: winuser.h:829
HINSTANCE g_hInstance
Definition: fontsub.cpp:46
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: fontsub.cpp:30
#define IDS_QUERYDELETE
Definition: resource.h:37
HWND g_hMainWnd
Definition: fontsub.cpp:47
#define LVNI_SELECTED
Definition: commctrl.h:2394
#define MAX_STRING
Definition: fontsub.cpp:27
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
BOOL g_bModified
Definition: fontsub.cpp:50
WCHAR g_szTitle[MAX_STRING]
Definition: fontsub.cpp:57
#define MB_YESNO
Definition: winuser.h:811
#define ListView_SetItemState(hwndLV, i, data, mask)
Definition: commctrl.h:2643
smooth NULL
Definition: ftsmooth.c:513
#define LVIS_SELECTED
Definition: commctrl.h:2289
#define ListView_DeleteItem(hwnd, i)
Definition: commctrl.h:2381
ITEMVECTOR g_Items
Definition: fontsub.cpp:71
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define MB_ICONINFORMATION
Definition: winuser.h:796
unsigned int UINT
Definition: ndis.h:50
HWND g_hListView
Definition: fontsub.cpp:49
#define LVIS_FOCUSED
Definition: commctrl.h:2288
void MainWnd_OnAbout ( HWND  hwnd)

Definition at line 1238 of file fontsub.cpp.

Referenced by MainWnd_OnCommand().

1239 {
1240  WCHAR szAbout[MAX_PATH];
1241  LoadStringW(g_hInstance, IDS_ABOUT, szAbout, _countof(szAbout));
1242 
1243  MSGBOXPARAMS Params;
1244  ZeroMemory(&Params, sizeof(Params));
1245  Params.cbSize = sizeof(Params);
1246  Params.hwndOwner = hwnd;
1247  Params.hInstance = g_hInstance;
1248  Params.lpszText = szAbout;
1249  Params.lpszCaption = g_szTitle;
1250  Params.dwStyle = MB_OK | MB_USERICON;
1251  Params.lpszIcon = MAKEINTRESOURCEW(1);
1253  MessageBoxIndirectW(&Params);
1254 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HINSTANCE g_hInstance
Definition: fontsub.cpp:46
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: fontsub.cpp:30
LPCSTR lpszText
Definition: winuser.h:3258
#define ZeroMemory
Definition: winbase.h:1621
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
HINSTANCE hInstance
Definition: winuser.h:3257
#define IDS_ABOUT
Definition: resource.h:29
DWORD dwStyle
Definition: winuser.h:3260
WCHAR g_szTitle[MAX_STRING]
Definition: fontsub.cpp:57
#define MB_USERICON
Definition: winuser.h:777
DWORD dwLanguageId
Definition: winuser.h:3264
HWND hwndOwner
Definition: winuser.h:3256
#define MAX_PATH
Definition: compat.h:26
LPCSTR lpszIcon
Definition: winuser.h:3261
#define MB_OK
Definition: winuser.h:784
int WINAPI MessageBoxIndirectW(_In_ CONST MSGBOXPARAMSW *)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define LANG_USER_DEFAULT
Definition: tnerror.cpp:50
LPCSTR lpszCaption
Definition: winuser.h:3259
void MainWnd_OnActivate ( HWND  hwnd,
UINT  state,
HWND  hwndActDeact,
BOOL  fMinimized 
)

Definition at line 1435 of file fontsub.cpp.

Referenced by WindowProc().

1436 {
1437  if (state != WA_INACTIVE)
1438  {
1440  }
1441 }
HWND WINAPI SetFocus(_In_opt_ HWND)
static int state
Definition: maze.c:121
#define WA_INACTIVE
Definition: winuser.h:2566
HWND g_hListView
Definition: fontsub.cpp:49
void MainWnd_OnClose ( HWND  hwnd)

Definition at line 1470 of file fontsub.cpp.

Referenced by WindowProc().

1471 {
1472  if (!g_bNeedsReboot && !g_bModified)
1473  {
1475  return;
1476  }
1477 
1478  if (g_bModified)
1479  {
1480  WCHAR szUpdateNow[MAX_STRING];
1481  LoadStringW(g_hInstance, IDS_QUERYUPDATE, szUpdateNow, _countof(szUpdateNow));
1482  INT id = MessageBoxW(hwnd, szUpdateNow, g_szTitle,
1484  switch (id)
1485  {
1486  case IDYES:
1488  break;
1489  case IDNO:
1490  break;
1491  case IDCANCEL:
1492  return;
1493  }
1494  }
1495 
1496  if (g_bNeedsReboot)
1497  {
1498  WCHAR szRebootNow[MAX_STRING];
1499  LoadStringW(g_hInstance, IDS_REBOOTNOW, szRebootNow, _countof(szRebootNow));
1500  INT id = MessageBoxW(hwnd, szRebootNow, g_szTitle,
1502  switch (id)
1503  {
1504  case IDYES:
1507  break;
1508  case IDNO:
1509  break;
1510  case IDCANCEL:
1511  return;
1512  }
1513  }
1514 
1516 }
BOOL g_bNeedsReboot
Definition: fontsub.cpp:51
#define EWX_FORCE
Definition: winuser.h:630
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
#define IDYES
Definition: winuser.h:829
HINSTANCE g_hInstance
Definition: fontsub.cpp:46
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: fontsub.cpp:30
#define EWX_REBOOT
Definition: winuser.h:633
#define IDS_REBOOTNOW
Definition: resource.h:39
BOOL WINAPI DestroyWindow(_In_ HWND)
#define MAX_STRING
Definition: fontsub.cpp:27
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:57
BOOL g_bModified
Definition: fontsub.cpp:50
WCHAR g_szTitle[MAX_STRING]
Definition: fontsub.cpp:57
#define MB_YESNOCANCEL
Definition: winuser.h:812
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
#define MB_ICONINFORMATION
Definition: winuser.h:796
BOOL MainWnd_OnUpdateRegistry(HWND hwnd)
Definition: fontsub.cpp:727
#define IDS_QUERYUPDATE
Definition: resource.h:34
BOOL EnableProcessPrivileges(LPCWSTR lpPrivilegeName, BOOL bEnable=TRUE)
Definition: fontsub.cpp:1443
BOOL WINAPI ExitWindowsEx(_In_ UINT, _In_ DWORD)
#define SE_SHUTDOWN_NAME
Definition: winnt_old.h:371
#define IDNO
Definition: winuser.h:830
#define IDCANCEL
Definition: winuser.h:825
void MainWnd_OnCommand ( HWND  hwnd,
int  id,
HWND  hwndCtl,
UINT  codeNotify 
)

Definition at line 1256 of file fontsub.cpp.

Referenced by WindowProc().

1257 {
1258  switch (id)
1259  {
1260  case ID_NEW:
1262  break;
1263  case ID_EDIT:
1265  break;
1266  case ID_EXIT:
1267  PostMessage(hwnd, WM_CLOSE, 0, 0);
1268  break;
1269  case ID_RELOAD:
1271  break;
1272  case ID_UPDATE_REGISTRY:
1274  break;
1275  case ID_DELETE:
1277  break;
1278  case ID_IMPORT:
1280  break;
1281  case ID_EXPORT:
1283  break;
1284  case ID_OPEN_REGKEY:
1286  break;
1287  case ID_ABOUT:
1289  break;
1290  }
1291 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
void MainWnd_OnExport(HWND hwnd)
Definition: fontsub.cpp:1155
#define ID_RELOAD
Definition: resource.h:17
#define ID_IMPORT
Definition: resource.h:15
#define ID_EXPORT
Definition: resource.h:17
void MainWnd_OnAbout(HWND hwnd)
Definition: fontsub.cpp:1238
#define ID_OPEN_REGKEY
Definition: resource.h:19
void MainWnd_OnDelete(HWND hwnd)
Definition: fontsub.cpp:1196
#define ID_DELETE
Definition: resource.h:25
void MainWnd_OnNew(HWND hwnd)
Definition: fontsub.cpp:706
#define ID_ABOUT
Definition: charmap.c:17
#define PostMessage
Definition: winuser.h:5677
#define ID_EDIT
Definition: resource.h:23
#define WM_CLOSE
Definition: winuser.h:1593
BOOL MainWnd_OnUpdateRegistry(HWND hwnd)
Definition: fontsub.cpp:727
void MainWnd_OnReload(HWND hwnd)
Definition: fontsub.cpp:1186
#define ID_NEW
Definition: resource.h:21
void MainWnd_OnImport(HWND hwnd)
Definition: fontsub.cpp:1123
#define ID_EXIT
Definition: resource.h:10
#define ID_UPDATE_REGISTRY
Definition: resource.h:13
void MainWnd_OnOpenRegKey(HWND hwnd)
Definition: fontsub.cpp:1201
void MainWnd_OnEdit(HWND hwnd)
Definition: fontsub.cpp:1191
LRESULT MainWnd_OnContextMenu ( HWND  hwnd,
HWND  hwndContext,
UINT  xPos,
UINT  yPos 
)

Definition at line 1414 of file fontsub.cpp.

Referenced by WindowProc().

1415 {
1416  POINT pt = {(INT)xPos, (INT)yPos};
1419 
1421  if (hMenu == NULL)
1422  return 0;
1423 
1424  HMENU hSubMenu = GetSubMenu(hMenu, 0);
1425  if (hSubMenu == NULL)
1426  return 0;
1427 
1430  xPos, yPos, 0, g_hMainWnd, NULL);
1431  PostMessage(g_hMainWnd, WM_NULL, 0, 0);
1432  return 0;
1433 }
#define WM_NULL
Definition: winuser.h:1579
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define MAKEINTRESOURCE
Definition: winuser.h:591
long y
Definition: polytest.cpp:48
#define WM_LBUTTONDOWN
Definition: winuser.h:1742
HINSTANCE g_hInstance
Definition: fontsub.cpp:46
long x
Definition: polytest.cpp:48
#define pt(x, y)
Definition: drawing.c:79
#define TPM_LEFTALIGN
Definition: winuser.h:2321
#define MAKELPARAM(l, h)
Definition: winuser.h:3894
HWND g_hMainWnd
Definition: fontsub.cpp:47
int32_t INT
Definition: typedefs.h:57
#define TPM_RIGHTBUTTON
Definition: winuser.h:2324
#define INT(a)
Definition: assyntax.h:463
smooth NULL
Definition: ftsmooth.c:513
#define PostMessage
Definition: winuser.h:5677
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define LoadMenu
Definition: winuser.h:5662
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI SetForegroundWindow(_In_ HWND)
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
HWND g_hListView
Definition: fontsub.cpp:49
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:68
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)
BOOL MainWnd_OnCreate ( HWND  hwnd,
LPCREATESTRUCT  lpCreateStruct 
)

Definition at line 531 of file fontsub.cpp.

Referenced by WindowProc().

532 {
533  DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_VSCROLL |
535  DWORD dwExStyle = WS_EX_CLIENTEDGE;
536  g_hListView = CreateWindowEx(dwExStyle, WC_LISTVIEW, NULL, dwStyle,
537  0, 0, 0, 0,
538  hwnd, (HMENU)1, g_hInstance, NULL);
539  if (g_hListView == NULL)
540  return FALSE;
541 
542  if (!LV_Init(g_hListView))
543  return FALSE;
544 
545  if (!DoLoad())
546  return FALSE;
547 
549  ListView_SetItemState(g_hListView, 0, State, State);
551  return TRUE;
552 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
HINSTANCE g_hInstance
Definition: fontsub.cpp:46
#define LVS_REPORT
Definition: commctrl.h:2232
HWND WINAPI SetFocus(_In_opt_ HWND)
#define WS_CHILD
Definition: pedump.c:617
DWORD DWORD
Definition: winlogon.h:75
#define FALSE
Definition: types.h:117
#define ListView_SetItemState(hwndLV, i, data, mask)
Definition: commctrl.h:2643
#define CreateWindowEx
Definition: winuser.h:5600
smooth NULL
Definition: ftsmooth.c:513
#define LVIS_SELECTED
Definition: commctrl.h:2289
#define LVS_SINGLESEL
Definition: commctrl.h:2236
BOOL DoLoad(void)
Definition: fontsub.cpp:310
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
unsigned int UINT
Definition: ndis.h:50
#define WS_VSCROLL
Definition: pedump.c:627
#define WC_LISTVIEW
Definition: commctrl.h:2229
BOOL LV_Init(HWND hwnd)
Definition: fontsub.cpp:328
#define WS_VISIBLE
Definition: pedump.c:620
HWND g_hListView
Definition: fontsub.cpp:49
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:68
#define LVS_OWNERDRAWFIXED
Definition: commctrl.h:2253
#define LVIS_FOCUSED
Definition: commctrl.h:2288
void MainWnd_OnDelete ( HWND  hwnd)

Definition at line 1196 of file fontsub.cpp.

Referenced by MainWnd_OnCommand().

1197 {
1199 }
void LV_OnDelete(HWND hwnd, INT iRow=-1)
Definition: fontsub.cpp:434
HWND g_hListView
Definition: fontsub.cpp:49
void MainWnd_OnDestroy ( HWND  hwnd)

Definition at line 1293 of file fontsub.cpp.

Referenced by WindowProc().

1294 {
1295  PostQuitMessage(0);
1296 }
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
void MainWnd_OnDrawItem ( HWND  hwnd,
const DRAWITEMSTRUCT lpDrawItem 
)

Definition at line 1303 of file fontsub.cpp.

Referenced by WindowProc().

1304 {
1305  if (lpDrawItem->CtlType != ODT_LISTVIEW)
1306  return;
1307 
1308  HDC hDC = lpDrawItem->hDC;
1309  SetBkMode(hDC, TRANSPARENT);
1310 
1311  INT iColumn = 0, x, cx;
1312  RECT rcItem, rcSubItem, rcText;
1313  STRING Str;
1314 
1316 
1317  rcItem = lpDrawItem->rcItem;
1318  if (lpDrawItem->itemState & ODS_SELECTED)
1319  {
1320  FillRect(hDC, &rcItem, (HBRUSH)(COLOR_HIGHLIGHT + 1));
1322  }
1323  else
1324  {
1325  FillRect(hDC, &rcItem, (HBRUSH)(COLOR_WINDOW + 1));
1327  }
1328 
1329  cx = ListView_GetColumnWidth(g_hListView, iColumn);
1330  rcSubItem = rcItem;
1331  rcSubItem.left = x;
1332  rcSubItem.right = x + cx;
1333 
1334  WCHAR sz[MAX_STRING];
1335 
1336  rcText = rcSubItem;
1337  InflateRect(&rcText, -1, -1);
1338  Str = g_Items[lpDrawItem->itemID].m_Name;
1339  BYTE CharSet1 = g_Items[lpDrawItem->itemID].m_CharSet1;
1340  if (CharSet1 != DEFAULT_CHARSET)
1341  wsprintfW(sz, L"%s,%u", Str.c_str(), CharSet1);
1342  else
1343  wsprintfW(sz, L"%s", Str.c_str());
1344 
1345  DrawTextW(hDC, sz, lstrlenW(sz), &rcText,
1347  DT_NOPREFIX);
1348 
1349  x += cx;
1350  ++iColumn;
1351 
1352  cx = ListView_GetColumnWidth(g_hListView, iColumn);
1353  rcSubItem = rcItem;
1354  rcSubItem.left = x;
1355  rcSubItem.right = x + cx;
1356 
1357  rcText = rcSubItem;
1358  InflateRect(&rcText, -1, -1);
1359  Str = g_Items[lpDrawItem->itemID].m_Substitute;
1360  BYTE CharSet2 = g_Items[lpDrawItem->itemID].m_CharSet2;
1361  if (CharSet2 != DEFAULT_CHARSET)
1362  wsprintfW(sz, L"%s,%u", Str.c_str(), CharSet2);
1363  else
1364  wsprintfW(sz, L"%s", Str.c_str());
1365 
1366  DrawTextW(hDC, sz, lstrlenW(sz), &rcText,
1368  DT_NOPREFIX);
1369 }
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
#define HDC
Definition: msvc.h:22
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define COLOR_HIGHLIGHT
Definition: winuser.h:906
Definition: bidi.c:75
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SB_HORZ
Definition: winuser.h:552
LONG left
Definition: windef.h:319
#define DEFAULT_CHARSET
Definition: wingdi.h:382
LONG right
Definition: windef.h:321
#define DT_NOPREFIX
Definition: winuser.h:537
#define lstrlenW
Definition: compat.h:407
#define MAX_STRING
Definition: fontsub.cpp:27
#define COLOR_WINDOW
Definition: winuser.h:898
int32_t INT
Definition: typedefs.h:57
DWORD WINAPI GetSysColor(_In_ int)
#define ODT_LISTVIEW
Definition: commctrl.h:80
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1032
#define DT_LEFT
Definition: winuser.h:534
#define TRANSPARENT
Definition: wingdi.h:948
#define DT_END_ELLIPSIS
Definition: winuser.h:529
#define DT_VCENTER
Definition: winuser.h:543
#define COLOR_HIGHLIGHTTEXT
Definition: winuser.h:907
ITEMVECTOR g_Items
Definition: fontsub.cpp:71
HDC hDC
Definition: wglext.h:521
#define COLOR_WINDOWTEXT
Definition: winuser.h:901
int WINAPI GetScrollPos(_In_ HWND, _In_ int)
std::wstring STRING
Definition: fontsub.cpp:33
unsigned char BYTE
Definition: ntddk_ex.h:96
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:756
#define DT_SINGLELINE
Definition: winuser.h:540
_Out_opt_ int * cx
Definition: commctrl.h:570
#define ODS_SELECTED
Definition: winuser.h:2489
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HWND g_hListView
Definition: fontsub.cpp:49
#define ListView_GetColumnWidth(hwnd, iCol)
Definition: commctrl.h:2612
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:17
INT x
Definition: msvc.h:62
void MainWnd_OnEdit ( HWND  hwnd)

Definition at line 1191 of file fontsub.cpp.

Referenced by MainWnd_OnCommand().

1192 {
1194 }
void LV_OnDblClk(HWND hwnd)
Definition: fontsub.cpp:515
HWND g_hListView
Definition: fontsub.cpp:49
void MainWnd_OnExport ( HWND  hwnd)

Definition at line 1155 of file fontsub.cpp.

Referenced by MainWnd_OnCommand().

1156 {
1157  OPENFILENAMEW ofn = {0};
1158  WCHAR szFile[MAX_PATH] = L"";
1159  WCHAR szExportTitle[MAX_STRING];
1160  WCHAR szCannotExport[MAX_STRING];
1161  WCHAR szExportFilter[MAX_STRING];
1162  LoadStringW(g_hInstance, IDS_EXPORT, szExportTitle, _countof(szExportTitle));
1163  LoadStringW(g_hInstance, IDS_CANTEXPORT, szCannotExport, _countof(szCannotExport));
1164  LoadStringW(g_hInstance, IDS_OUTFILTER, szExportFilter, _countof(szExportFilter));
1165  MakeFilter(szExportFilter);
1166 
1168  ofn.hwndOwner = hwnd;
1169  ofn.lpstrFilter = szExportFilter;
1170  ofn.lpstrFile = szFile;
1171  ofn.nMaxFile = _countof(szFile);
1172  ofn.lpstrTitle = szExportTitle;
1176  ofn.lpstrDefExt = L"reg";
1177  if (GetSaveFileNameW(&ofn))
1178  {
1179  if (!DoExport(hwnd, szFile))
1180  {
1181  MessageBoxW(hwnd, szCannotExport, g_szTitle, MB_ICONERROR);
1182  }
1183  }
1184 }
#define OFN_EXPLORER
Definition: commdlg.h:104
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
DWORD Flags
Definition: commdlg.h:372
#define OFN_LONGNAMES
Definition: commdlg.h:108
LPCWSTR lpstrFilter
Definition: commdlg.h:362
#define IDS_OUTFILTER
Definition: resource.h:33
HINSTANCE g_hInstance
Definition: fontsub.cpp:46
Definition: bidi.c:75
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: fontsub.cpp:30
LPWSTR lpstrFile
Definition: commdlg.h:366
OPENFILENAME ofn
Definition: main.cpp:42
#define IDS_EXPORT
Definition: resource.h:29
#define MAX_STRING
Definition: fontsub.cpp:27
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
BOOL WINAPI GetSaveFileNameW(LPOPENFILENAMEW ofn)
Definition: filedlg.c:4090
DWORD lStructSize
Definition: commdlg.h:359
WCHAR g_szTitle[MAX_STRING]
Definition: fontsub.cpp:57
LPCWSTR lpstrDefExt
Definition: commdlg.h:375
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
LPCWSTR lpstrTitle
Definition: commdlg.h:371
BOOL DoExport(HWND hwnd, LPCWSTR pszFile)
Definition: fontsub.cpp:1048
#define MAX_PATH
Definition: compat.h:26
DWORD nMaxFile
Definition: commdlg.h:367
HWND hwndOwner
Definition: commdlg.h:360
#define MB_ICONERROR
Definition: winuser.h:781
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define OPENFILENAME_SIZE_VERSION_400
Definition: commdlg.h:401
#define OFN_DONTADDTORECENT
Definition: commdlg.h:98
#define OFN_OVERWRITEPROMPT
Definition: commdlg.h:116
#define IDS_CANTEXPORT
Definition: resource.h:31
#define OFN_ENABLESIZING
Definition: commdlg.h:101
void MakeFilter(LPWSTR pszFilter)
Definition: fontsub.cpp:1112
void MainWnd_OnImport ( HWND  hwnd)

Definition at line 1123 of file fontsub.cpp.

Referenced by MainWnd_OnCommand().

1124 {
1125  OPENFILENAMEW ofn = {0};
1126  WCHAR szFile[MAX_PATH] = L"";
1127  WCHAR szImportTitle[MAX_STRING];
1128  WCHAR szCannotImport[MAX_STRING];
1129  WCHAR szImportFilter[MAX_STRING];
1130  LoadStringW(g_hInstance, IDS_IMPORT, szImportTitle, _countof(szImportTitle));
1131  LoadStringW(g_hInstance, IDS_CANTIMPORT, szCannotImport, _countof(szCannotImport));
1132  LoadStringW(g_hInstance, IDS_INPFILTER, szImportFilter, _countof(szImportFilter));
1133  MakeFilter(szImportFilter);
1134 
1136  ofn.hwndOwner = hwnd;
1137  ofn.lpstrFilter = szImportFilter;
1138  ofn.lpstrFile = szFile;
1139  ofn.nMaxFile = _countof(szFile);
1140  ofn.lpstrTitle = szImportTitle;
1145  ofn.lpstrDefExt = L"reg";
1146  if (GetOpenFileNameW(&ofn))
1147  {
1148  if (!DoImport(hwnd, szFile))
1149  {
1150  MessageBoxW(hwnd, szCannotImport, g_szTitle, MB_ICONERROR);
1151  }
1152  }
1153 }
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define OFN_EXPLORER
Definition: commdlg.h:104
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
DWORD Flags
Definition: commdlg.h:372
#define IDS_CANTIMPORT
Definition: resource.h:30
#define OFN_LONGNAMES
Definition: commdlg.h:108
LPCWSTR lpstrFilter
Definition: commdlg.h:362
HINSTANCE g_hInstance
Definition: fontsub.cpp:46
Definition: bidi.c:75
#define IDS_INPFILTER
Definition: resource.h:32
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: fontsub.cpp:30
LPWSTR lpstrFile
Definition: commdlg.h:366
#define IDS_IMPORT
Definition: resource.h:28
OPENFILENAME ofn
Definition: main.cpp:42
#define MAX_STRING
Definition: fontsub.cpp:27
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
DWORD lStructSize
Definition: commdlg.h:359
BOOL DoImport(HWND hwnd, LPCWSTR pszFile)
Definition: fontsub.cpp:997
WCHAR g_szTitle[MAX_STRING]
Definition: fontsub.cpp:57
LPCWSTR lpstrDefExt
Definition: commdlg.h:375
BOOL WINAPI GetOpenFileNameW(OPENFILENAMEW *ofn)
Definition: filedlg.c:4025
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
LPCWSTR lpstrTitle
Definition: commdlg.h:371
#define MAX_PATH
Definition: compat.h:26
DWORD nMaxFile
Definition: commdlg.h:367
HWND hwndOwner
Definition: commdlg.h:360
#define MB_ICONERROR
Definition: winuser.h:781
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define OPENFILENAME_SIZE_VERSION_400
Definition: commdlg.h:401
#define OFN_DONTADDTORECENT
Definition: commdlg.h:98
#define OFN_ENABLESIZING
Definition: commdlg.h:101
void MakeFilter(LPWSTR pszFilter)
Definition: fontsub.cpp:1112
void MainWnd_OnMeasureItem ( HWND  hwnd,
MEASUREITEMSTRUCT lpMeasureItem 
)

Definition at line 1371 of file fontsub.cpp.

Referenced by WindowProc().

1372 {
1373  if (lpMeasureItem->CtlType != ODT_LISTVIEW)
1374  return;
1375 
1376  TEXTMETRIC tm;
1377  HDC hDC = GetDC(hwnd);
1378  GetTextMetrics(hDC, &tm);
1379  ReleaseDC(hwnd, hDC);
1380 
1381  lpMeasureItem->itemHeight = tm.tmHeight * 4 / 3;
1382 }
#define HDC
Definition: msvc.h:22
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HDC WINAPI GetDC(_In_opt_ HWND)
#define GetTextMetrics
Definition: wingdi.h:4443
#define ODT_LISTVIEW
Definition: commctrl.h:80
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC hDC
Definition: wglext.h:521
LONG tmHeight
Definition: wingdi.h:2338
Definition: time.h:76
void MainWnd_OnNew ( HWND  hwnd)

Definition at line 706 of file fontsub.cpp.

Referenced by MainWnd_OnCommand().

707 {
709  if (g_iItem == -1)
710  return;
711 
712  g_strFontName = g_Items[g_iItem].m_Name;
713  g_strSubstitute = g_Items[g_iItem].m_Substitute;
714  g_CharSet1 = g_Items[g_iItem].m_CharSet1;
715  g_CharSet2 = g_Items[g_iItem].m_CharSet2;
716 
719  {
722  ListView_SetItemState(g_hListView, i, State, State);
724  }
725 }
#define ListView_EnsureVisible(hwndLV, i, fPartialOK)
Definition: commctrl.h:2489
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2404
#define IDOK
Definition: winuser.h:824
HINSTANCE g_hInstance
Definition: fontsub.cpp:46
STRING g_strFontName
Definition: fontsub.cpp:72
INT_PTR CALLBACK AddDlg_DlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: fontsub.cpp:696
#define IDD_ADD
Definition: resource.h:16
BYTE g_CharSet1
Definition: fontsub.cpp:74
HWND g_hMainWnd
Definition: fontsub.cpp:47
#define LVNI_SELECTED
Definition: commctrl.h:2394
INT g_iItem
Definition: fontsub.cpp:52
int32_t INT
Definition: typedefs.h:57
#define DialogBox
Definition: winuser.h:5606
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define FALSE
Definition: types.h:117
#define ListView_SetItemState(hwndLV, i, data, mask)
Definition: commctrl.h:2643
#define LVIS_SELECTED
Definition: commctrl.h:2289
#define ListView_GetItemCount(hwnd)
Definition: commctrl.h:2277
ITEMVECTOR g_Items
Definition: fontsub.cpp:71
STRING g_strSubstitute
Definition: fontsub.cpp:73
unsigned int UINT
Definition: ndis.h:50
BYTE g_CharSet2
Definition: fontsub.cpp:75
HWND g_hListView
Definition: fontsub.cpp:49
#define LVIS_FOCUSED
Definition: commctrl.h:2288
LRESULT MainWnd_OnNotify ( HWND  hwnd,
int  idFrom,
NMHDR pnmhdr 
)

Definition at line 1384 of file fontsub.cpp.

Referenced by WindowProc().

1385 {
1386  NM_LISTVIEW *pNMLV = (NM_LISTVIEW *)pnmhdr;
1387  LV_KEYDOWN *pLVKD = (LV_KEYDOWN *)pnmhdr;
1388 
1389  switch (pnmhdr->code)
1390  {
1391  case LVN_COLUMNCLICK:
1392  if (pNMLV->iSubItem == g_iSortColumn)
1393  DoSort(pNMLV->iSubItem, !g_bSortAscendant);
1394  else
1395  DoSort(pNMLV->iSubItem, TRUE);
1396  break;
1397  case NM_DBLCLK:
1399  break;
1400  case LVN_KEYDOWN:
1401  if (pLVKD->wVKey == VK_RETURN) // [Enter] key
1402  {
1404  }
1405  if (pLVKD->wVKey == VK_DELETE) // [Del] key
1406  {
1408  }
1409  break;
1410  }
1411  return 0;
1412 }
#define TRUE
Definition: types.h:120
#define LV_KEYDOWN
Definition: commctrl.h:3153
INT g_iSortColumn
Definition: fontsub.cpp:61
#define VK_RETURN
Definition: winuser.h:2145
UINT code
Definition: winuser.h:3102
#define LVN_KEYDOWN
Definition: commctrl.h:3151
#define VK_DELETE
Definition: winuser.h:2177
void LV_OnDelete(HWND hwnd, INT iRow=-1)
Definition: fontsub.cpp:434
void DoSort(INT iColumn, BOOL bAscendant=TRUE)
Definition: fontsub.cpp:180
#define NM_LISTVIEW
Definition: commctrl.h:3000
void LV_OnDblClk(HWND hwnd)
Definition: fontsub.cpp:515
#define NM_DBLCLK
Definition: commctrl.h:131
#define LVN_COLUMNCLICK
Definition: commctrl.h:3109
BOOL g_bSortAscendant
Definition: fontsub.cpp:62
HWND g_hListView
Definition: fontsub.cpp:49
void MainWnd_OnOpenRegKey ( HWND  hwnd)

Definition at line 1201 of file fontsub.cpp.

Referenced by MainWnd_OnCommand().

1202 {
1203  static const WCHAR s_szRegeditKey[] =
1204  L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit";
1205  WCHAR sz[MAX_STRING];
1206 
1207  // open regedit key
1208  HKEY hKey = NULL;
1209  LSTATUS Result = RegCreateKeyExW(HKEY_CURRENT_USER, s_szRegeditKey, 0,
1210  NULL, 0, KEY_WRITE, NULL, &hKey, NULL);
1211  if (Result != ERROR_SUCCESS)
1212  {
1215  return;
1216  }
1217 
1218  // set LastKey value
1219  wsprintfW(sz, L"HKEY_LOCAL_MACHINE\\%s", g_pszKey);
1220  DWORD dwSize = sizeof(sz);
1221  Result = RegSetValueExW(hKey, L"LastKey", 0, REG_SZ,
1222  (LPBYTE)sz, dwSize);
1223 
1224  // close now
1225  RegCloseKey(hKey);
1226 
1227  if (Result != ERROR_SUCCESS)
1228  {
1231  return;
1232  }
1233 
1234  // open by regedit
1235  ShellExecuteW(hwnd, NULL, L"regedit.exe", NULL, NULL, SW_SHOWNORMAL);
1236 }
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define ERROR_SUCCESS
Definition: deptool.c:10
HINSTANCE g_hInstance
Definition: fontsub.cpp:46
Definition: bidi.c:75
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: fontsub.cpp:30
#define HKEY_CURRENT_USER
Definition: winreg.h:11
unsigned char * LPBYTE
Definition: typedefs.h:53
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
#define IDS_CANTOPENKEY
Definition: resource.h:38
#define MAX_STRING
Definition: fontsub.cpp:27
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
DWORD DWORD
Definition: winlogon.h:75
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1094
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
smooth NULL
Definition: ftsmooth.c:513
#define KEY_WRITE
Definition: nt_native.h:1031
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:4884
LPCWSTR g_pszKey
Definition: fontsub.cpp:64
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
HANDLE HKEY
Definition: registry.h:24
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
#define MB_ICONERROR
Definition: winuser.h:781
#define SW_SHOWNORMAL
Definition: winuser.h:764
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2230
#define REG_SZ
Definition: layer.c:33
DWORD dwSize
Definition: wglext.h:734
void MainWnd_OnReload ( HWND  hwnd)

Definition at line 1186 of file fontsub.cpp.

Referenced by MainWnd_OnCommand().

1187 {
1188  DoLoad();
1189 }
BOOL DoLoad(void)
Definition: fontsub.cpp:310
void MainWnd_OnSize ( HWND  hwnd,
UINT  state,
int  cx,
int  cy 
)

Definition at line 1298 of file fontsub.cpp.

Referenced by WindowProc().

1299 {
1300  MoveWindow(g_hListView, 0, 0, cx, cy, TRUE);
1301 }
#define TRUE
Definition: types.h:120
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
_Out_opt_ int * cx
Definition: commctrl.h:570
HWND g_hListView
Definition: fontsub.cpp:49
BOOL MainWnd_OnUpdateRegistry ( HWND  hwnd)

Definition at line 727 of file fontsub.cpp.

Referenced by MainWnd_OnClose(), and MainWnd_OnCommand().

728 {
729  // open the key
730  HKEY hKey = NULL;
732  if (hKey == NULL)
733  return FALSE;
734 
735  // clear all values
736  WCHAR szName[MAX_STRING], szValue[MAX_STRING];
737  DWORD cbName, cbValue;
738  for (;;)
739  {
740  cbName = sizeof(szName);
741  cbValue = sizeof(szValue);
742  LONG Error = RegEnumValueW(hKey, 0, szName, &cbName,
743  NULL, NULL, (LPBYTE)szValue, &cbValue);
744  if (Error != ERROR_SUCCESS)
745  break;
746 
747  RegDeleteValueW(hKey, szName);
748  }
749 
750  // set values
751  size_t Count = g_Items.size();
752  for (size_t i = 0; i < Count; ++i)
753  {
754  DWORD cbData = (g_Items[i].m_Substitute.size() + 1) * sizeof(WCHAR);
755  RegSetValueExW(hKey, g_Items[i].m_Name.c_str(), 0,
756  REG_SZ, (LPBYTE)g_Items[i].m_Substitute.c_str(), cbData);
757  }
758 
759  // close now
760  RegCloseKey(hKey);
761 
762  g_bModified = FALSE;
764  return TRUE;
765 }
BOOL g_bNeedsReboot
Definition: fontsub.cpp:51
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char * LPBYTE
Definition: typedefs.h:53
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define MAX_STRING
Definition: fontsub.cpp:27
DWORD DWORD
Definition: winlogon.h:75
BOOL g_bModified
Definition: fontsub.cpp:50
GLenum GLclampf GLint i
Definition: glfuncs.h:14
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
LONG WINAPI RegEnumValueW(_In_ HKEY hKey, _In_ DWORD index, _Out_ LPWSTR value, _Inout_ PDWORD val_count, _Reserved_ PDWORD reserved, _Out_opt_ PDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ PDWORD count)
Definition: reg.c:2867
smooth NULL
Definition: ftsmooth.c:513
ITEMVECTOR g_Items
Definition: fontsub.cpp:71
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:4884
LPCWSTR g_pszKey
Definition: fontsub.cpp:64
HANDLE HKEY
Definition: registry.h:24
BOOL Error
Definition: chkdsk.c:63
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2368
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
static const WCHAR szName[]
Definition: msipriv.h:1212
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REG_SZ
Definition: layer.c:33
void MakeFilter ( LPWSTR  pszFilter)

Definition at line 1112 of file fontsub.cpp.

Referenced by MainWnd_OnExport(), and MainWnd_OnImport().

1113 {
1114  while (*pszFilter)
1115  {
1116  if (*pszFilter == L'|')
1117  *pszFilter = 0;
1118 
1119  ++pszFilter;
1120  }
1121 }
Definition: bidi.c:75
LPWSTR SkipQuoted ( LPWSTR  pch)

Definition at line 776 of file fontsub.cpp.

Referenced by DoParseFile().

777 {
778  ++pch; // L'"'
779  while (*pch)
780  {
781  if (*pch == L'"')
782  {
783  ++pch;
784  break;
785  }
786  if (*pch == L'\\')
787  {
788  ++pch;
789  }
790  ++pch;
791  }
792  return pch;
793 }
Definition: bidi.c:75
WCHAR * pch
Definition: msvc.h:81
LPWSTR SkipSpace ( LPCWSTR  pch)

Definition at line 767 of file fontsub.cpp.

Referenced by DoParseFile().

768 {
769  while (*pch && wcschr(L" \t\r\n", *pch) != NULL)
770  {
771  ++pch;
772  }
773  return const_cast<LPWSTR>(pch);
774 }
Definition: bidi.c:75
smooth NULL
Definition: ftsmooth.c:513
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
WCHAR * pch
Definition: msvc.h:81
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static void trim ( STRING str)
static

Definition at line 107 of file fontsub.cpp.

Referenced by AddDlg_OnCommand(), DoLoadItems(), DoParseFile(), and EditDlg_OnCommand().

108 {
109  static const WCHAR Spaces[] = L" \t\r\n";
110  size_t i = str.find_first_not_of(Spaces);
111  size_t j = str.find_last_not_of(Spaces);
112  if (i == STRING::npos || j == STRING::npos)
113  {
114  str.clear();
115  }
116  else
117  {
118  str = str.substr(i, j - i + 1);
119  }
120 }
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint 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 GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
Definition: bidi.c:75
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const size_t npos
Definition: _string_npos.h:26
GLenum GLclampf GLint i
Definition: glfuncs.h:14
const WCHAR * str
void UnescapeChar ( const STRING str,
size_t i,
STRING Ret 
)

Definition at line 862 of file fontsub.cpp.

Referenced by Unquote().

863 {
864  if (str[i] != L'\\')
865  {
866  Ret += str[i];
867  ++i;
868  return;
869  }
870 
871  ++i;
872  switch (str[i])
873  {
874  case L'a': Ret += L'\a'; ++i; break;
875  case L'b': Ret += L'\b'; ++i; break;
876  case L'f': Ret += L'\f'; ++i; break;
877  case L'n': Ret += L'\n'; ++i; break;
878  case L'r': Ret += L'\r'; ++i; break;
879  case L't': Ret += L'\t'; ++i; break;
880  case L'v': Ret += L'\v'; ++i; break;
881  case L'x':
882  // hexidemical
883  ++i;
884  UnescapeHex(str, i, Ret, FALSE);
885  break;
886  case L'u':
887  // Unicode hexidemical
888  ++i;
889  UnescapeHex(str, i, Ret, TRUE);
890  break;
891  default:
892  // other case
893  UnescapeOther(str, i, Ret);
894  break;
895  }
896 }
#define TRUE
Definition: types.h:120
Definition: bidi.c:75
void UnescapeHex(const STRING &str, size_t &i, STRING &Ret, BOOL Unicode)
Definition: fontsub.cpp:795
void UnescapeOther(const STRING &str, size_t &i, STRING &Ret)
Definition: fontsub.cpp:829
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define FALSE
Definition: types.h:117
const WCHAR * str
void UnescapeHex ( const STRING str,
size_t i,
STRING Ret,
BOOL  Unicode 
)

Definition at line 795 of file fontsub.cpp.

Referenced by UnescapeChar().

796 {
797  STRING Num;
798 
799  // hexadecimal
800  if (iswxdigit(str[i]))
801  {
802  Num += str[i];
803  ++i;
804  if (iswxdigit(str[i]))
805  {
806  Num += str[i];
807  ++i;
808  if (Unicode)
809  {
810  if (iswxdigit(str[i]))
811  {
812  Num += str[i];
813  ++i;
814  if (iswxdigit(str[i]))
815  {
816  Num += str[i];
817  ++i;
818  }
819  }
820  }
821  }
822  }
823  if (!Num.empty())
824  {
825  Ret += (WCHAR)wcstoul(&Num[0], NULL, 16);
826  }
827 }
#define iswxdigit(_c)
Definition: ctype.h:668
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
#define WCHAR
Definition: msvc.h:43
GLenum GLclampf GLint i
Definition: glfuncs.h:14
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:513
std::wstring STRING
Definition: fontsub.cpp:33
void UnescapeOther ( const STRING str,
size_t i,
STRING Ret 
)

Definition at line 829 of file fontsub.cpp.

Referenced by UnescapeChar().

830 {
831  STRING Num;
832 
833  // check octal
834  if (L'0' <= str[i] && str[i] < L'8')
835  {
836  Num += str[i];
837  ++i;
838  if (L'0' <= str[i] && str[i] < L'8')
839  {
840  Num += str[i];
841  ++i;
842  if (L'0' <= str[i] && str[i] < L'8')
843  {
844  Num += str[i];
845  ++i;
846  }
847  }
848  }
849  if (Num.empty())
850  {
851  Ret += str[i];
852  ++i;
853  }
854  else
855  {
856  // octal
857  Ret += (WCHAR)wcstoul(&Num[0], NULL, 8);
858  }
859 }
Definition: bidi.c:75
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
#define WCHAR
Definition: msvc.h:43
GLenum GLclampf GLint i
Definition: glfuncs.h:14
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:513
std::wstring STRING
Definition: fontsub.cpp:33
STRING Unquote ( const STRING str)

Definition at line 898 of file fontsub.cpp.

Referenced by DoParseFile().

899 {
900  if (str[0] != L'"')
901  return str;
902 
903  STRING Ret;
904  size_t i = 1;
905  while (i < str.size())
906  {
907  if (str[i] == L'"' || str[i] == UNICODE_NULL)
908  break;
909 
910  UnescapeChar(str, i, Ret);
911  }
912  return Ret;
913 }
void UnescapeChar(const STRING &str, size_t &i, STRING &Ret)
Definition: fontsub.cpp:862
Definition: bidi.c:75
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define UNICODE_NULL
const WCHAR * str
std::wstring STRING
Definition: fontsub.cpp:33
LRESULT CALLBACK WindowProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 1519 of file fontsub.cpp.

Referenced by CShellBrowser::GetWindowProc(), CDefView::WindowProc(), and wWinMain().

1520 {
1521  switch (uMsg)
1522  {
1533  default:
1534  return DefWindowProc(hwnd, uMsg, wParam, lParam);
1535  }
1536 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
LRESULT MainWnd_OnNotify(HWND hwnd, int idFrom, NMHDR *pnmhdr)
Definition: fontsub.cpp:1384
#define WM_CONTEXTMENU
Definition: richedit.h:64
UINT uMsg
Definition: precomp.h:49
void MainWnd_OnDestroy(HWND hwnd)
Definition: fontsub.cpp:1293
void MainWnd_OnActivate(HWND hwnd, UINT state, HWND hwndActDeact, BOOL fMinimized)
Definition: fontsub.cpp:1435
void MainWnd_OnClose(HWND hwnd)
Definition: fontsub.cpp:1470
void MainWnd_OnDrawItem(HWND hwnd, const DRAWITEMSTRUCT *lpDrawItem)
Definition: fontsub.cpp:1303
void MainWnd_OnSize(HWND hwnd, UINT state, int cx, int cy)
Definition: fontsub.cpp:1298
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1581
#define WM_SIZE
Definition: winuser.h:1583
UINT WPARAM wParam
Definition: precomp.h:49
#define WM_CLOSE
Definition: winuser.h:1593
#define WM_MEASUREITEM
Definition: winuser.h:1618
void MainWnd_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
Definition: fontsub.cpp:1256
BOOL MainWnd_OnCreate(HWND hwnd, LPCREATESTRUCT lpCreateStruct)
Definition: fontsub.cpp:531
#define WM_COMMAND
Definition: winuser.h:1706
#define WM_ACTIVATE
Definition: winuser.h:1584
LRESULT MainWnd_OnContextMenu(HWND hwnd, HWND hwndContext, UINT xPos, UINT yPos)
Definition: fontsub.cpp:1414
UINT WPARAM LPARAM lParam
Definition: precomp.h:49
#define WM_DRAWITEM
Definition: winuser.h:1617
#define WM_CREATE
Definition: winuser.h:1580
void MainWnd_OnMeasureItem(HWND hwnd, MEASUREITEMSTRUCT *lpMeasureItem)
Definition: fontsub.cpp:1371
#define HANDLE_MSG(hwnd, message, fn)
Definition: windowsx.h:297
#define WM_NOTIFY
Definition: richedit.h:61
INT WINAPI wWinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPWSTR  lpCmdLine,
INT  nCmdShow 
)

Definition at line 1538 of file fontsub.cpp.

1543 {
1546 
1548 
1552 
1553  WNDCLASSW wc = {0};
1554  wc.style = 0;
1555  wc.lpfnWndProc = WindowProc;
1556  wc.hInstance = hInstance;
1558  wc.hIcon = g_hIcon;
1560  wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
1563  if (!RegisterClassW(&wc))
1564  {
1565  MessageBoxA(NULL, "ERROR: RegisterClass failed.", NULL, MB_ICONERROR);
1566  return 1;
1567  }
1568 
1569  const DWORD dwStyle = WS_OVERLAPPEDWINDOW;
1573  INT Height = 320;
1574 
1575  RECT Rect = { 0, 0, Width, Height };
1576  AdjustWindowRect(&Rect, dwStyle, TRUE);
1577  Width = Rect.right - Rect.left;
1578  Height = Rect.bottom - Rect.top;
1579 
1581  CW_USEDEFAULT, CW_USEDEFAULT, Width, Height,
1582  NULL, NULL, hInstance, NULL);
1583  if (g_hMainWnd == NULL)
1584  {
1585  MessageBoxA(NULL, "ERROR: CreateWindow failed.", NULL, MB_ICONERROR);
1586  return 2;
1587  }
1588 
1589  ShowWindow(g_hMainWnd, nCmdShow);
1591 
1592  MSG msg;
1593  while (GetMessage(&msg, NULL, 0, 0))
1594  {
1595  if (TranslateAccelerator(g_hMainWnd, hAccel, &msg))
1596  continue;
1597 
1598  TranslateMessage(&msg);
1599  DispatchMessage(&msg);
1600  }
1601 
1602  return (INT)msg.wParam;
1603 }
#define TranslateAccelerator
Definition: winuser.h:5705
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define DispatchMessage
Definition: winuser.h:5610
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define TRUE
Definition: types.h:120
WCHAR g_szSubstituteHead[MAX_STRING]
Definition: fontsub.cpp:59
UINT style
Definition: winuser.h:3119
LPCWSTR lpszMenuName
Definition: winuser.h:3127
HINSTANCE g_hInstance
Definition: fontsub.cpp:46
#define _countof(array)
Definition: fontsub.cpp:30
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
BOOL WINAPI UpdateWindow(_In_ HWND)
LONG top
Definition: windef.h:320
HWND g_hMainWnd
Definition: fontsub.cpp:47
HICON g_hIcon
Definition: fontsub.cpp:48
#define IDS_SUBSTITUTE
Definition: resource.h:26
LONG left
Definition: windef.h:319
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
LONG right
Definition: windef.h:321
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4164
int32_t INT
Definition: typedefs.h:57
DWORD DWORD
Definition: winlogon.h:75
int WINAPI MessageBoxA(_In_opt_ HWND, _In_opt_ LPCSTR, _In_opt_ LPCSTR, _In_ UINT)
WCHAR g_szTitle[MAX_STRING]
Definition: fontsub.cpp:57
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
BOOL WINAPI AdjustWindowRect(_Inout_ LPRECT, _In_ DWORD, _In_ BOOL)
HINSTANCE hInstance
Definition: charmap.c:19
#define COLOR_3DFACE
Definition: winuser.h:909
HACCEL hAccel
Definition: main.c:47
WNDPROC lpfnWndProc
Definition: winuser.h:3120
#define CW_USEDEFAULT
Definition: winuser.h:225
HACCEL WINAPI LoadAcceleratorsW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
smooth NULL
Definition: ftsmooth.c:513
LPCWSTR lpszClassName
Definition: winuser.h:3128
LPCWSTR g_pszClassName
Definition: fontsub.cpp:54
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: fontsub.cpp:1519
#define SM_CXSIZEFRAME
Definition: winuser.h:973
WCHAR g_szNameHead[MAX_STRING]
Definition: fontsub.cpp:58
#define IDS_TITLE
Definition: resource.h:30
int WINAPI GetSystemMetrics(_In_ int)
HICON hIcon
Definition: winuser.h:3124
#define IDS_FONTNAME
Definition: resource.h:6
#define MB_ICONERROR
Definition: winuser.h:781
#define SUB_COLUMN_WIDTH
Definition: fontsub.cpp:26
#define LoadCursor
Definition: winuser.h:5657
HCURSOR hCursor
Definition: winuser.h:3125
HBRUSH hbrBackground
Definition: winuser.h:3126
#define GetMessage
Definition: winuser.h:5635
#define SM_CXVSCROLL
Definition: winuser.h:941
HINSTANCE hInstance
Definition: winuser.h:3123
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
LONG bottom
Definition: windef.h:322
VOID WINAPI InitCommonControls(void)
Definition: commctrl.c:865
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define LoadIcon
Definition: winuser.h:5658
#define NAME_COLUMN_WIDTH
Definition: fontsub.cpp:25

Variable Documentation

BOOL g_bNeedsReboot = FALSE

Definition at line 51 of file fontsub.cpp.

Referenced by DoLoadItems(), MainWnd_OnClose(), and MainWnd_OnUpdateRegistry().

BOOL g_bSortAscendant = TRUE

Definition at line 62 of file fontsub.cpp.

Referenced by DoSort(), and MainWnd_OnNotify().

BYTE g_CharSet1 = DEFAULT_CHARSET

Definition at line 74 of file fontsub.cpp.

Referenced by AddDlg_OnInitDialog(), EditDlg_OnInitDialog(), LV_OnDblClk(), and MainWnd_OnNew().

BYTE g_CharSet2 = DEFAULT_CHARSET

Definition at line 75 of file fontsub.cpp.

Referenced by AddDlg_OnInitDialog(), EditDlg_OnInitDialog(), LV_OnDblClk(), and MainWnd_OnNew().

CHARSET_ENTRY g_CharSetList[]
Initial value:
=
{
{ DEFAULT_CHARSET, L"DEFAULT_CHARSET (1)" },
{ ANSI_CHARSET, L"ANSI_CHARSET (0)" },
{ SYMBOL_CHARSET, L"SYMBOL_CHARSET (2)" },
{ SHIFTJIS_CHARSET, L"SHIFTJIS_CHARSET (128)" },
{ HANGUL_CHARSET, L"HANGUL_CHARSET (129)" },
{ GB2312_CHARSET, L"GB2312_CHARSET (134)" },
{ CHINESEBIG5_CHARSET, L"CHINESEBIG5_CHARSET (136)" },
{ OEM_CHARSET, L"OEM_CHARSET (255)" },
{ JOHAB_CHARSET, L"JOHAB_CHARSET (130)" },
{ HEBREW_CHARSET, L"HEBREW_CHARSET (177)" },
{ ARABIC_CHARSET, L"ARABIC_CHARSET (178)" },
{ GREEK_CHARSET, L"GREEK_CHARSET (161)" },
{ TURKISH_CHARSET, L"TURKISH_CHARSET (162)" },
{ VIETNAMESE_CHARSET, L"VIETNAMESE_CHARSET (163)" },
{ THAI_CHARSET, L"THAI_CHARSET (222)" },
{ EASTEUROPE_CHARSET, L"EASTEUROPE_CHARSET (238)" },
{ RUSSIAN_CHARSET, L"RUSSIAN_CHARSET (204)" },
{ MAC_CHARSET, L"MAC_CHARSET (77)" },
{ BALTIC_CHARSET, L"BALTIC_CHARSET (186)" }
}
#define MAC_CHARSET
Definition: wingdi.h:401
#define EASTEUROPE_CHARSET
Definition: wingdi.h:397
Definition: bidi.c:75
#define SYMBOL_CHARSET
Definition: wingdi.h:383
#define CHINESEBIG5_CHARSET
Definition: wingdi.h:388
#define DEFAULT_CHARSET
Definition: wingdi.h:382
#define TURKISH_CHARSET
Definition: wingdi.h:390
#define HANGUL_CHARSET
Definition: wingdi.h:386
#define THAI_CHARSET
Definition: wingdi.h:395
#define SHIFTJIS_CHARSET
Definition: wingdi.h:384
#define RUSSIAN_CHARSET
Definition: wingdi.h:394
#define OEM_CHARSET
Definition: wingdi.h:398
#define GB2312_CHARSET
Definition: wingdi.h:387
#define VIETNAMESE_CHARSET
Definition: wingdi.h:400
#define HEBREW_CHARSET
Definition: wingdi.h:391
#define ARABIC_CHARSET
Definition: wingdi.h:392
#define ANSI_CHARSET
Definition: wingdi.h:381
#define JOHAB_CHARSET
Definition: wingdi.h:399
#define BALTIC_CHARSET
Definition: wingdi.h:393
#define GREEK_CHARSET
Definition: wingdi.h:389

Definition at line 83 of file fontsub.cpp.

HICON g_hIcon = NULL

Definition at line 48 of file fontsub.cpp.

Referenced by wWinMain().

HWND g_hMainWnd = NULL

Definition at line 47 of file fontsub.cpp.

Referenced by LV_OnDblClk(), LV_OnDelete(), MainWnd_OnContextMenu(), MainWnd_OnNew(), and wWinMain().

INT g_iItem = 0

Definition at line 52 of file fontsub.cpp.

Referenced by EditDlg_OnCommand(), LV_OnDblClk(), and MainWnd_OnNew().

INT g_iSortColumn = 0

Definition at line 61 of file fontsub.cpp.

Referenced by DoSort(), and MainWnd_OnNotify().

const WCHAR g_LongestName[] = L"CHINESEBIG5_CHARSET (136)"

Definition at line 105 of file fontsub.cpp.

Referenced by AddDlg_OnInitDialog(), and EditDlg_OnInitDialog().

FONTNAMESET g_Names
LPCWSTR g_pszClassName = L"ReactOS Font Substitutes Editor"

Definition at line 54 of file fontsub.cpp.

Referenced by wWinMain().

LPCWSTR g_pszFileHeader = L"Windows Registry Editor Version 5.00"

Definition at line 55 of file fontsub.cpp.

Referenced by DoExport(), and DoParseFile().

LPCWSTR g_pszKey
Initial value:
=
L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\FontSubstitutes"
Definition: bidi.c:75

Definition at line 64 of file fontsub.cpp.

Referenced by DoExport(), DoLoadItems(), DoParseFile(), MainWnd_OnOpenRegKey(), and MainWnd_OnUpdateRegistry().

STRING g_strFontName

Definition at line 72 of file fontsub.cpp.

Referenced by EditDlg_OnInitDialog(), LV_OnDblClk(), and MainWnd_OnNew().

STRING g_strSubstitute

Definition at line 73 of file fontsub.cpp.

Referenced by EditDlg_OnInitDialog(), LV_OnDblClk(), and MainWnd_OnNew().

WCHAR g_szNameHead[MAX_STRING]

Definition at line 58 of file fontsub.cpp.

Referenced by LV_Init(), and wWinMain().

WCHAR g_szSubstituteHead[MAX_STRING]

Definition at line 59 of file fontsub.cpp.

Referenced by LV_Init(), and wWinMain().