Revision: 7334 http://sourceforge.jp/projects/ttssh2/scm/svn/commits/7334 Author: zmatsuo Date: 2018-12-18 23:46:51 +0900 (Tue, 18 Dec 2018) Log Message: ----------- フォント設定 Modified Paths: -------------- branches/cmake/teraterm/ttpmacro/ttmacro.cpp -------------- next part -------------- Modified: branches/cmake/teraterm/ttpmacro/ttmacro.cpp =================================================================== --- branches/cmake/teraterm/ttpmacro/ttmacro.cpp 2018-12-18 14:46:36 UTC (rev 7333) +++ branches/cmake/teraterm/ttpmacro/ttmacro.cpp 2018-12-18 14:46:51 UTC (rev 7334) @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 1994-1998 T. Teranishi * (C) 2006-2017 TeraTerm Project * All rights reserved. @@ -44,6 +44,7 @@ #include "compat_win.h" #include "ttmdlg.h" #include "tmfc.h" +#include "dlglib.h" #ifdef _DEBUG #define new new(_NORMAL_BLOCK, __FILE__, __LINE__) @@ -63,14 +64,14 @@ pSetDllDir setDllDir; pSetDefDllDir setDefDllDir; - if ((module = GetModuleHandle("kernel32.dll")) != NULL) { + if ((module = GetModuleHandleA("kernel32.dll")) != NULL) { if ((setDefDllDir = (pSetDefDllDir)GetProcAddress(module, "SetDefaultDllDirectories")) != NULL) { - // SetDefaultDllDirectories() \x82\xAA\x8Eg\x82\xA6\x82\xE9\x8Fꍇ\x82́A\x8C\x9F\x8D\xF5\x83p\x83X\x82\xF0 %WINDOWS%\system32 \x82݂̂ɐݒ肷\x82\xE9 + // SetDefaultDllDirectories() が使える場合は、検索パスを %WINDOWS%\system32 のみに設定する (*setDefDllDir)((DWORD)0x00000800); // LOAD_LIBRARY_SEARCH_SYSTEM32 } else if ((setDllDir = (pSetDllDir)GetProcAddress(module, "SetDllDirectoryA")) != NULL) { - // SetDefaultDllDirectories() \x82\xAA\x8Eg\x82\xA6\x82Ȃ\xAD\x82Ă\xE0\x81ASetDllDirectory() \x82\xAA\x8Eg\x82\xA6\x82\xE9\x8Fꍇ\x82\xCD - // \x83J\x83\x8C\x83\x93\x83g\x83f\x83B\x83\x8C\x83N\x83g\x83\x8A\x82\xBE\x82\xAF\x82ł\xE0\x8C\x9F\x8D\xF5\x83p\x83X\x82\xA9\x82\xE7\x82͂\xB8\x82\xB5\x82Ă\xA8\x82\xAD\x81B + // SetDefaultDllDirectories() が使えなくても、SetDllDirectory() が使える場合は + // カレントディレクトリだけでも検索パスからはずしておく。 (*setDllDir)(""); } } @@ -119,8 +120,51 @@ ///////////////////////////////////////////////////////////////////////////// +static void SetDialogFont() +{ + LOGFONTA logfont; + BOOL result; + // 明示的に指定されている場合はそれに従う + result = GetI18nLogfont("Tera Term", "DLG_FONT", &logfont, 72, UILanguageFile); + // 明示されていない場合 + if (result == FALSE) { + // ガイドラインに沿った設定を行う + // https://msdn.microsoft.com/ja-jp/library/windows/desktop/aa511282.aspx + if (IsWindowsVistaOrLater()) { + // Windows Vista以降 Segoe UI + strcpy(logfont.lfFaceName, "Segoe UI"); + logfont.lfCharSet = 0; + logfont.lfHeight = -9; + logfont.lfWidth = 0; + } else if (IsWindows2000OrLater()) { + // Windows®XP および Windows 2000 をターゲットとする場合は、 + // 8 ポイント MS Shell Dlg 2 擬似フォントを使用します。 + // このフォントは Tahoma にマッピングされます。 + strcpy(logfont.lfFaceName, "MS Shell Dlg 2"); + logfont.lfCharSet = 0; + logfont.lfHeight = -8; + logfont.lfWidth = 0; + } else { + // 以前のバージョンをターゲットとする場合は + // 8 ポイント MS Shell Dlg 擬似フォントを使用します + // MS Sans Serif にそれぞれマッピングされます + strcpy(logfont.lfFaceName, "MS Shell Dlg"); + logfont.lfCharSet = 0; + logfont.lfHeight = -8; + logfont.lfWidth = 0; + } + result = TRUE; + } + + if (result) { + TTSetDlgFont(logfont.lfFaceName, logfont.lfHeight, logfont.lfCharSet); + } else { + TTSetDlgFont(NULL, 0, 0); + } +} + int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst, LPSTR lpszCmdLine, int nCmdShow) { @@ -136,6 +180,7 @@ init(); // InitCommonControls(); GetUILanguageFile(UILanguageFile, sizeof(UILanguageFile)); + SetDialogFont(); Busy = TRUE; pCCtrlWindow = new CCtrlWindow(); @@ -154,9 +199,9 @@ bool message_processed = false; if (m_pMainWnd->m_hAccel != NULL) { if (!MetaKey(ts.MetaKey)) { - // matakey\x82\xAA\x89\x9F\x82\xB3\x82\xEA\x82Ă\xA2\x82Ȃ\xA2 + // matakeyが押されていない if (TranslateAccelerator(m_pMainWnd->m_hWnd , m_pMainWnd->m_hAccel, &msg)) { - // \x83A\x83N\x83Z\x83\x89\x83\x8C\x81[\x83^\x81[\x83L\x81[\x82\xF0\x8F\x88\x97\x9D\x82\xB5\x82\xBD + // アクセラレーターキーを処理した message_processed = true; } } @@ -164,7 +209,7 @@ #endif if (IsDialogMessage(hWnd, &msg) != 0) { - /* \x8F\x88\x97\x9D\x82\xB3\x82ꂽ*/ + /* 処理された*/ } else { TranslateMessage(&msg); DispatchMessage(&msg); @@ -177,16 +222,16 @@ #endif while (!PeekMessage(&msg, NULL, NULL, NULL, PM_NOREMOVE)) { - // \x83\x81\x83b\x83Z\x81[\x83W\x82\xAA\x82Ȃ\xA2 + // メッセージがない if (!OnIdle(lCount)) { - // idle\x95s\x97v - if (SleepTick < 500) { // \x8Dő\xE5 501ms\x96\xA2\x96\x9E + // idle不要 + if (SleepTick < 500) { // 最大 501ms未満 SleepTick += 2; } lCount = 0; Sleep(SleepTick); } else { - // \x97vidle + // 要idle SleepTick = 0; lCount++; } @@ -195,7 +240,7 @@ ////////////////////////////////////////////////////////////////////// - // TODO \x82\xB7\x82łɕ\xB6\x82\xE7\x82\xEA\x82Ă\xA2\x82\xE9\x81A\x82\xB1\x82̏\x88\x97\x9D\x95s\x97v? + // TODO すでに閉じられている、この処理不要? if (pCCtrlWindow) { pCCtrlWindow->DestroyWindow(); }