[FONTVIEW][HIVECLS] File filter improvements by Lee Schroeder. See CORE-9763 for details.

svn path=/trunk/; revision=68050
This commit is contained in:
Amine Khaldi 2015-06-06 17:20:49 +00:00
parent 7a90496c39
commit 084970da0a
24 changed files with 130 additions and 21 deletions

View file

@ -24,6 +24,7 @@
#include <winnls.h>
#include <shellapi.h>
#include <windowsx.h>
#include "fontview.h"
#include "resource.h"
@ -65,7 +66,7 @@ FormatString(
}
static void
ErrorMsgBox(HWND hParent, DWORD dwCaptionID, DWORD dwMessageId, ...)
ErrorMsgBox(HWND hParent, DWORD dwMessageId, ...)
{
HLOCAL hMemCaption = NULL;
HLOCAL hMemText = NULL;
@ -77,7 +78,7 @@ ErrorMsgBox(HWND hParent, DWORD dwCaptionID, DWORD dwMessageId, ...)
va_end(args);
FormatString(FORMAT_MESSAGE_ALLOCATE_BUFFER,
NULL, dwCaptionID, 0, (LPWSTR)&hMemCaption, 0, NULL);
NULL, IDS_ERROR, 0, (LPWSTR)&hMemCaption, 0, NULL);
MessageBoxW(hParent, hMemText, hMemCaption, MB_ICONERROR);
@ -117,11 +118,10 @@ WinMain (HINSTANCE hThisInstance,
if (argc < 2)
{
OPENFILENAMEW fontOpen;
HLOCAL dialogTitle = NULL;
WCHAR filter[MAX_PATH], dialogTitle[MAX_PATH];
/* Gets the title for the dialog box ready */
FormatString(FORMAT_MESSAGE_ALLOCATE_BUFFER,
NULL, IDS_OPEN, 0, (LPWSTR)&dialogTitle, 0, NULL);
LoadStringW(NULL, IDS_OPEN, dialogTitle, MAX_PATH);
LoadStringW(NULL, IDS_FILTER_LIST, filter, MAX_PATH);
/* Clears out any values of fontOpen before we use it */
ZeroMemory(&fontOpen, sizeof(fontOpen));
@ -129,8 +129,7 @@ WinMain (HINSTANCE hThisInstance,
/* Sets up the open dialog box */
fontOpen.lStructSize = sizeof(fontOpen);
fontOpen.hwndOwner = NULL;
fontOpen.lpstrFilter = L"TrueType Font (*.ttf)\0*.ttf\0"
L"All Files (*.*)\0*.*\0";
fontOpen.lpstrFilter = filter;
fontOpen.lpstrFile = szFileName;
fontOpen.lpstrTitle = dialogTitle;
fontOpen.nMaxFile = MAX_PATH;
@ -145,11 +144,8 @@ WinMain (HINSTANCE hThisInstance,
} else {
/* If the user decides to close out of the open dialog effectively
exiting the program altogether */
LocalFree(dialogTitle);
return 0;
}
LocalFree(dialogTitle);
}
else
{
@ -160,7 +156,7 @@ WinMain (HINSTANCE hThisInstance,
if (!AddFontResourceW(fileName))
{
ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOFONT, fileName);
ErrorMsgBox(0, IDS_ERROR_NOFONT, fileName);
return -1;
}
@ -168,20 +164,20 @@ WinMain (HINSTANCE hThisInstance,
dwSize = sizeof(g_ExtLogFontW.elfFullName);
if (!GetFontResourceInfoW(fileName, &dwSize, g_ExtLogFontW.elfFullName, 1))
{
ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOFONT, fileName);
ErrorMsgBox(0, IDS_ERROR_NOFONT, fileName);
return -1;
}
dwSize = sizeof(LOGFONTW);
if (!GetFontResourceInfoW(fileName, &dwSize, &g_ExtLogFontW.elfLogFont, 2))
{
ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOFONT, fileName);
ErrorMsgBox(0, IDS_ERROR_NOFONT, fileName);
return -1;
}
if (!Display_InitClass(hThisInstance))
{
ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOCLASS);
ErrorMsgBox(0, IDS_ERROR_NOCLASS);
return -1;
}
@ -202,7 +198,7 @@ WinMain (HINSTANCE hThisInstance,
/* Register the window class, and if it fails quit the program */
if (!RegisterClassExW (&wincl))
{
ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOCLASS);
ErrorMsgBox(0, IDS_ERROR_NOCLASS);
return 0;
}
@ -266,7 +262,7 @@ MainWnd_OnCreate(HWND hwnd)
SendMessage(hDisplay, FVM_SETTYPEFACE, 0, (LPARAM)&g_ExtLogFontW);
ShowWindow(hDisplay, SW_SHOWNORMAL);
/* Create the quit button */
/* Create the install button */
LoadStringW(g_hInstance, IDS_INSTALL, szQuit, MAX_BUTTONNAME);
hButtonInstall = CreateWindowExW(
0, /* Extended style */
@ -342,7 +338,7 @@ MainWnd_OnInstall(HWND hwnd)
fontExists = GetFileAttributes((LPCSTR)g_fileName);
if (fontExists != 0xFFFFFFFF) /* If the file does not exist */
{
ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOFONT, g_fileName);
ErrorMsgBox(0, IDS_ERROR_NOFONT, g_fileName);
return -1;
}

View file

@ -10,4 +10,9 @@ BEGIN
IDS_ERROR_NOMEM "Няма достатъчно място за завършване на действието."
IDS_ERROR_NOFONT "%1 не е редовен шрифтов файл."
IDS_ERROR_NOCLASS "Неуспешно изпълнение на класа на прозореца."
IDS_FILTER_LIST "All Supported Fonts (*.ttf;*.fon;*.otf)\0*.ttf;*.fon;*.otf\0\
TrueType Font (*.ttf)\0*.ttf\0\
OpenType Font (*.otf)\0*.otf\0\
Font File (*.fon)\0*.fon\0\
All Files (*.*)\0*.*\0"
END

View file

@ -10,4 +10,9 @@ BEGIN
IDS_ERROR_NOMEM "K dokončení operace není dostatek paměti."
IDS_ERROR_NOFONT "Soubor %1 není platným souborem písma."
IDS_ERROR_NOCLASS "Inicializace okna aplikace selhala."
IDS_FILTER_LIST "All Supported Fonts (*.ttf;*.fon;*.otf)\0*.ttf;*.fon;*.otf\0\
TrueType Font (*.ttf)\0*.ttf\0\
OpenType Font (*.otf)\0*.otf\0\
Font File (*.fon)\0*.fon\0\
All Files (*.*)\0*.*\0"
END

View file

@ -10,4 +10,9 @@ BEGIN
IDS_ERROR_NOMEM "Es steht nicht genügend Speicher zur Verfügung."
IDS_ERROR_NOFONT "Die angegebene Datei %1 ist keine gültige Schriftartendatei."
IDS_ERROR_NOCLASS "Fehler beim Initialisieren der Fensterklasse."
IDS_FILTER_LIST "All Supported Fonts (*.ttf;*.fon;*.otf)\0*.ttf;*.fon;*.otf\0\
TrueType Font (*.ttf)\0*.ttf\0\
OpenType Font (*.otf)\0*.otf\0\
Font File (*.fon)\0*.fon\0\
All Files (*.*)\0*.*\0"
END

View file

@ -10,4 +10,9 @@ BEGIN
IDS_ERROR_NOMEM "There's not enough memory to complete the operation."
IDS_ERROR_NOFONT "The file %1 is not a valid font file."
IDS_ERROR_NOCLASS "Could not initialize window class."
IDS_FILTER_LIST "All Supported Fonts (*.ttf;*.fon;*.otf)\0*.ttf;*.fon;*.otf\0\
TrueType Font (*.ttf)\0*.ttf\0\
OpenType Font (*.otf)\0*.otf\0\
Font File (*.fon)\0*.fon\0\
All Files (*.*)\0*.*\0"
END

View file

@ -12,4 +12,9 @@ BEGIN
IDS_ERROR_NOMEM "No hay memoria suficiente para completar la operación."
IDS_ERROR_NOFONT "El archivo %1 no es un archivo de fuente válido."
IDS_ERROR_NOCLASS "No es posible iniciar la clase de ventana."
IDS_FILTER_LIST "All Supported Fonts (*.ttf;*.fon;*.otf)\0*.ttf;*.fon;*.otf\0\
TrueType Font (*.ttf)\0*.ttf\0\
OpenType Font (*.otf)\0*.otf\0\
Font File (*.fon)\0*.fon\0\
All Files (*.*)\0*.*\0"
END

View file

@ -10,4 +10,9 @@ BEGIN
IDS_ERROR_NOMEM "Mémoire insuffisante pour terminer l'opération."
IDS_ERROR_NOFONT "Le fichier %1 n'est pas un fichier police valide."
IDS_ERROR_NOCLASS "Impossible d'initialiser la classe de fenêtre."
IDS_FILTER_LIST "All Supported Fonts (*.ttf;*.fon;*.otf)\0*.ttf;*.fon;*.otf\0\
TrueType Font (*.ttf)\0*.ttf\0\
OpenType Font (*.otf)\0*.otf\0\
Font File (*.fon)\0*.fon\0\
All Files (*.*)\0*.*\0"
END

View file

@ -12,4 +12,9 @@ BEGIN
IDS_ERROR_NOMEM "אין מספיק זיכרון כדי להשלים את הפעולה."
IDS_ERROR_NOFONT "הקובץ %1 אינו קובץ גופנים חוקי."
IDS_ERROR_NOCLASS "Could not initialize window class."
IDS_FILTER_LIST "All Supported Fonts (*.ttf;*.fon;*.otf)\0*.ttf;*.fon;*.otf\0\
TrueType Font (*.ttf)\0*.ttf\0\
OpenType Font (*.otf)\0*.otf\0\
Font File (*.fon)\0*.fon\0\
All Files (*.*)\0*.*\0"
END

View file

@ -10,4 +10,9 @@ BEGIN
IDS_ERROR_NOMEM "Memoria insufficiente per completare l'operazione."
IDS_ERROR_NOFONT "Il file% 1 non è un file di origine valido."
IDS_ERROR_NOCLASS "Impossibile avviare la classe."
IDS_FILTER_LIST "All Supported Fonts (*.ttf;*.fon;*.otf)\0*.ttf;*.fon;*.otf\0\
TrueType Font (*.ttf)\0*.ttf\0\
OpenType Font (*.otf)\0*.otf\0\
Font File (*.fon)\0*.fon\0\
All Files (*.*)\0*.*\0"
END

View file

@ -12,4 +12,9 @@ BEGIN
IDS_ERROR_NOMEM "Užduočiai užbaigti, nepakanka atminties."
IDS_ERROR_NOFONT "%1 nėra teisinga šrifto byla."
IDS_ERROR_NOCLASS "Nepavyko inicijuoti lango klasės."
IDS_FILTER_LIST "All Supported Fonts (*.ttf;*.fon;*.otf)\0*.ttf;*.fon;*.otf\0\
TrueType Font (*.ttf)\0*.ttf\0\
OpenType Font (*.otf)\0*.otf\0\
Font File (*.fon)\0*.fon\0\
All Files (*.*)\0*.*\0"
END

View file

@ -10,4 +10,9 @@ BEGIN
IDS_ERROR_NOMEM "Det er ikke nok minne for å fullføre oppgaven."
IDS_ERROR_NOFONT "Filen %1 er ikke et gyldig skriftfil."
IDS_ERROR_NOCLASS "Kunne ikke initialise vindu klassen."
IDS_FILTER_LIST "All Supported Fonts (*.ttf;*.fon;*.otf)\0*.ttf;*.fon;*.otf\0\
TrueType Font (*.ttf)\0*.ttf\0\
OpenType Font (*.otf)\0*.otf\0\
Font File (*.fon)\0*.fon\0\
All Files (*.*)\0*.*\0"
END

View file

@ -18,4 +18,9 @@ BEGIN
IDS_ERROR_NOMEM "Brakuje pamięci do ukończenia tej operacji."
IDS_ERROR_NOFONT "Plik %1 nie jest poprawnym plikiem czcionki."
IDS_ERROR_NOCLASS "Nie udało się zainicjować klasy window."
IDS_FILTER_LIST "All Supported Fonts (*.ttf;*.fon;*.otf)\0*.ttf;*.fon;*.otf\0\
TrueType Font (*.ttf)\0*.ttf\0\
OpenType Font (*.otf)\0*.otf\0\
Font File (*.fon)\0*.fon\0\
All Files (*.*)\0*.*\0"
END

View file

@ -12,4 +12,9 @@ BEGIN
IDS_ERROR_NOMEM "Não há memória suficiente para completar a operação."
IDS_ERROR_NOFONT "O arquivo %1 não é um arquivo de fonte válida."
IDS_ERROR_NOCLASS "Não foi possível inicializar a janela."
IDS_FILTER_LIST "All Supported Fonts (*.ttf;*.fon;*.otf)\0*.ttf;*.fon;*.otf\0\
TrueType Font (*.ttf)\0*.ttf\0\
OpenType Font (*.otf)\0*.otf\0\
Font File (*.fon)\0*.fon\0\
All Files (*.*)\0*.*\0"
END

View file

@ -12,4 +12,9 @@ BEGIN
IDS_ERROR_NOMEM "Nu e destulă memorie pentru a încheia operația."
IDS_ERROR_NOFONT "Fișierul «%1» este un fișier font deteriorat."
IDS_ERROR_NOCLASS "Nu s-a putut inițializa clasa de ferestre."
IDS_FILTER_LIST "All Supported Fonts (*.ttf;*.fon;*.otf)\0*.ttf;*.fon;*.otf\0\
TrueType Font (*.ttf)\0*.ttf\0\
OpenType Font (*.otf)\0*.otf\0\
Font File (*.fon)\0*.fon\0\
All Files (*.*)\0*.*\0"
END

View file

@ -12,4 +12,9 @@ BEGIN
IDS_ERROR_NOMEM "Недостаточно памяти для выполнения операции."
IDS_ERROR_NOFONT "%1 не является корректным файлом шрифта."
IDS_ERROR_NOCLASS "Невозможно инициализировать класс окна."
IDS_FILTER_LIST "All Supported Fonts (*.ttf;*.fon;*.otf)\0*.ttf;*.fon;*.otf\0\
TrueType Font (*.ttf)\0*.ttf\0\
OpenType Font (*.otf)\0*.otf\0\
Font File (*.fon)\0*.fon\0\
All Files (*.*)\0*.*\0"
END

View file

@ -15,4 +15,9 @@ BEGIN
IDS_ERROR_NOMEM "Na vykonanie tejto operácie nie je dostatok voľnej pamäte."
IDS_ERROR_NOFONT "Požadovaný súbor %1 nie je platným súborom písiem."
IDS_ERROR_NOCLASS "Nepodarilo sa inicializovať triedu window."
IDS_FILTER_LIST "All Supported Fonts (*.ttf;*.fon;*.otf)\0*.ttf;*.fon;*.otf\0\
TrueType Font (*.ttf)\0*.ttf\0\
OpenType Font (*.otf)\0*.otf\0\
Font File (*.fon)\0*.fon\0\
All Files (*.*)\0*.*\0"
END

View file

@ -14,4 +14,9 @@ BEGIN
IDS_ERROR_NOMEM "Nuk ka memorie të mjaftueshme për të përfunduar operacionin."
IDS_ERROR_NOFONT "Dokumenti %1 nuk është një font i vlefshem."
IDS_ERROR_NOCLASS "Nuk mund të fillojë dritaren e klases."
IDS_FILTER_LIST "All Supported Fonts (*.ttf;*.fon;*.otf)\0*.ttf;*.fon;*.otf\0\
TrueType Font (*.ttf)\0*.ttf\0\
OpenType Font (*.otf)\0*.otf\0\
Font File (*.fon)\0*.fon\0\
All Files (*.*)\0*.*\0"
END

View file

@ -17,4 +17,9 @@ BEGIN
IDS_ERROR_NOMEM "Det er inte nog minne för att slutföre operationen."
IDS_ERROR_NOFONT "Filen %1 är inte en giltig typsnittsfil."
IDS_ERROR_NOCLASS "Kunde inte initialisera Windows klassen."
IDS_FILTER_LIST "All Supported Fonts (*.ttf;*.fon;*.otf)\0*.ttf;*.fon;*.otf\0\
TrueType Font (*.ttf)\0*.ttf\0\
OpenType Font (*.otf)\0*.otf\0\
Font File (*.fon)\0*.fon\0\
All Files (*.*)\0*.*\0"
END

View file

@ -11,4 +11,9 @@ BEGIN
IDS_ERROR_NOMEM "Bu işlemi bitirmek için yeterli bellek yok."
IDS_ERROR_NOFONT "%1 kütüğü, geçerli bir yazı tipi kütüğü değil."
IDS_ERROR_NOCLASS "Pencere sınıfı başlatılamadı."
IDS_FILTER_LIST "All Supported Fonts (*.ttf;*.fon;*.otf)\0*.ttf;*.fon;*.otf\0\
TrueType Font (*.ttf)\0*.ttf\0\
OpenType Font (*.otf)\0*.otf\0\
Font File (*.fon)\0*.fon\0\
All Files (*.*)\0*.*\0"
END

View file

@ -18,4 +18,9 @@ BEGIN
IDS_ERROR_NOMEM "Недостатньо пам'яті для завершення операції."
IDS_ERROR_NOFONT "Файл %1 не є коректним файлом шрифту."
IDS_ERROR_NOCLASS "Неможливо ініціалізувати віконний клас."
IDS_FILTER_LIST "All Supported Fonts (*.ttf;*.fon;*.otf)\0*.ttf;*.fon;*.otf\0\
TrueType Font (*.ttf)\0*.ttf\0\
OpenType Font (*.otf)\0*.otf\0\
Font File (*.fon)\0*.fon\0\
All Files (*.*)\0*.*\0"
END

View file

@ -18,4 +18,9 @@ BEGIN
IDS_ERROR_NOMEM "没有足够的内存来完成操作。"
IDS_ERROR_NOFONT "1不是一个有效的字体档案。"
IDS_ERROR_NOCLASS "窗口无法初始化。"
IDS_FILTER_LIST "All Supported Fonts (*.ttf;*.fon;*.otf)\0*.ttf;*.fon;*.otf\0\
TrueType Font (*.ttf)\0*.ttf\0\
OpenType Font (*.otf)\0*.otf\0\
Font File (*.fon)\0*.fon\0\
All Files (*.*)\0*.*\0"
END

View file

@ -18,4 +18,9 @@ BEGIN
IDS_ERROR_NOMEM "沒有足夠的記憶體來完成操作。"
IDS_ERROR_NOFONT "%1 不是一個有效的字體檔案。"
IDS_ERROR_NOCLASS "窗口無法初始化。"
IDS_FILTER_LIST "All Supported Fonts (*.ttf;*.fon;*.otf)\0*.ttf;*.fon;*.otf\0\
TrueType Font (*.ttf)\0*.ttf\0\
OpenType Font (*.otf)\0*.otf\0\
Font File (*.fon)\0*.fon\0\
All Files (*.*)\0*.*\0"
END

View file

@ -4,6 +4,7 @@
#define IDS_ERROR_NOMEM 101
#define IDS_ERROR_NOFONT 102
#define IDS_ERROR_NOCLASS 103
#define IDS_FILTER_LIST 104
#define IDS_INSTALL 500
#define IDS_PRINT 501

View file

@ -110,16 +110,23 @@ HKCR,"exefile\shellex\DropHandler","",0x00020000,"{86C86720-42A0-1069-A2E8-08002
; Fonts
HKCR,".fon","",0x00000000,"fonfile"
HKCR,"fonfile","",0x00000000,"Font File"
HKCR,"fonfile","",0x00000000,"Font file"
HKCR,"fonfile","FriendlyTypeName",0x00020000,"@%SystemRoot%\system32\shell32.dll,-166"
HKCR,"fonfile\DefaultIcon","",0x00020000,"%SystemRoot%\system32\shell32.dll,-155"
HKCR,"fonfile\shell\open\command","",0x00020000,"%SystemRoot%\system32\fontview.exe %1"
HKCR,".ttf","",0x00000000,"ttffile"
HKCR,"ttffile","",0x00000000,"TrueType Font File"
HKCR,"ttffile\DefaultIcon","",0x00020000,"%SystemRoot%\system32\shell32.dll,-156"
HKCR,"ttffile","",0x00000000,"TrueType font file"
HKCR,"ttffile","FriendlyTypeName",0x00020000,"@%SystemRoot%\system32\shell32.dll,-167"
HKCR,"ttffile\DefaultIcon","",0x00020000,"%SystemRoot%\system32\shell32.dll,-156"
HKCR,"ttffile\shell\open\command","",0x00020000,"%SystemRoot%\system32\fontview.exe %1"
HKCR,".otf","",0x00000000,"otffile"
HKCR,"otffile","",0x00000000,"OpenType font file"
HKCR,"otffile\DefaultIcon","",0x00020000,"%SystemRoot%\system32\shell32.dll,-156"
HKCR,"otffile","FriendlyTypeName",0x00020000,"@%SystemRoot%\system32\shell32.dll,-167"
HKCR,"otffile\shell\open\command","",0x00020000,"%SystemRoot%\system32\fontview.exe %1"
; Help Files
HKCR,".hlp","",0x00000000,"hlpfile"
HKCR,"hlpfile","",0x00000000,"Help File"