[Ttssh2-commit] [7176] teraterm/ のダイアログ系でMFCを使用しないようにした

scmno****@osdn***** scmno****@osdn*****
2018年 8月 11日 (土) 00:12:20 JST


Revision: 7176
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/7176
Author:   zmatsuo
Date:     2018-08-11 00:12:13 +0900 (Sat, 11 Aug 2018)
Log Message:
-----------
teraterm/ のダイアログ系でMFCを使用しないようにした
 (フォントはテスト的にMeiryo UI 20pointにハードコード)
CMake MinGWを考慮

Modified Paths:
--------------
    branches/cmake/mingw.toolchain.cmake
    branches/cmake/teraterm/common/dlglib.h
    branches/cmake/teraterm/common/ttftypes.h
    branches/cmake/teraterm/common/ttlib.c
    branches/cmake/teraterm/common/ttlib.h
    branches/cmake/teraterm/common/tttypes.h
    branches/cmake/teraterm/teraterm/CMakeLists.txt
    branches/cmake/teraterm/teraterm/addsetting.cpp
    branches/cmake/teraterm/teraterm/addsetting.h
    branches/cmake/teraterm/teraterm/dnddlg.cpp
    branches/cmake/teraterm/teraterm/filesys.cpp
    branches/cmake/teraterm/teraterm/ftdlg.cpp
    branches/cmake/teraterm/teraterm/ftdlg.h
    branches/cmake/teraterm/teraterm/prnabort.cpp
    branches/cmake/teraterm/teraterm/prnabort.h
    branches/cmake/teraterm/teraterm/protodlg.cpp
    branches/cmake/teraterm/teraterm/protodlg.h
    branches/cmake/teraterm/teraterm/teraterm.cpp
    branches/cmake/teraterm/teraterm/vtwin.cpp
    branches/cmake/teraterm/ttpcmn/CMakeLists.txt
    branches/cmake/teraterm/ttpdlg/CMakeLists.txt
    branches/cmake/teraterm/ttpfile/CMakeLists.txt
    branches/cmake/teraterm/ttpmacro/CMakeLists.txt
    branches/cmake/teraterm/ttpset/CMakeLists.txt

Added Paths:
-----------
    branches/cmake/teraterm/common/compat_win.cpp
    branches/cmake/teraterm/common/compat_win.h
    branches/cmake/teraterm/common/dlglib_cpp.cpp
    branches/cmake/teraterm/common/dlglib_tmpl.cpp
    branches/cmake/teraterm/teraterm/tmfc.cpp
    branches/cmake/teraterm/teraterm/tmfc.h

-------------- next part --------------
Modified: branches/cmake/mingw.toolchain.cmake
===================================================================
--- branches/cmake/mingw.toolchain.cmake	2018-08-05 13:33:28 UTC (rev 7175)
+++ branches/cmake/mingw.toolchain.cmake	2018-08-10 15:12:13 UTC (rev 7176)
@@ -23,7 +23,9 @@
   set(CMAKE_RC_COMPILER i686-w64-mingw32-windres)
 endif()
 
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -ffunction-sections" CACHE STRING "")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -ffunction-sections" CACHE STRING "")
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s" CACHE STRING "")
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -s" CACHE STRING "")
 
 set(CMAKE_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE} CACHE PATH "toolchain file")

Added: branches/cmake/teraterm/common/compat_win.cpp
===================================================================
--- branches/cmake/teraterm/common/compat_win.cpp	                        (rev 0)
+++ branches/cmake/teraterm/common/compat_win.cpp	2018-08-10 15:12:13 UTC (rev 7176)
@@ -0,0 +1,20 @@
+
+#include "compat_win.h"
+
+TSetThreadDpiAwarenessContext PSetThreadDpiAwarenessContext;
+
+void WinCompatInit()
+{
+	static bool done = false;
+	if (done) return;
+	done = true;
+
+	char user32_dll[MAX_PATH];
+	GetSystemDirectory(user32_dll, sizeof(user32_dll));
+	strncat_s(user32_dll, sizeof(user32_dll), "\\user32.dll", _TRUNCATE);
+
+	HMODULE dll_handle = LoadLibrary(user32_dll);
+	PSetThreadDpiAwarenessContext =
+		(TSetThreadDpiAwarenessContext)
+		GetProcAddress(dll_handle, "SetThreadDpiAwarenessContext");
+}

Added: branches/cmake/teraterm/common/compat_win.h
===================================================================
--- branches/cmake/teraterm/common/compat_win.h	                        (rev 0)
+++ branches/cmake/teraterm/common/compat_win.h	2018-08-10 15:12:13 UTC (rev 7176)
@@ -0,0 +1,24 @@
+
+#include <windows.h>
+
+extern "C" {
+
+#if !defined(DPI_AWARENESS_CONTEXT_SYSTEM_AWARE)
+#define DPI_AWARENESS_CONTEXT_SYSTEM_AWARE          ((DPI_AWARENESS_CONTEXT)-2)
+#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE     ((DPI_AWARENESS_CONTEXT)-3)
+#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2  ((DPI_AWARENESS_CONTEXT)-4)
+DECLARE_HANDLE(DPI_AWARENESS_CONTEXT);
+#endif
+
+#if !defined(WM_DPICHANGED)
+#define WM_DPICHANGED                   0x02E0
+#endif
+
+typedef DPI_AWARENESS_CONTEXT (WINAPI *TSetThreadDpiAwarenessContext)
+	(DPI_AWARENESS_CONTEXT dpiContext);
+extern TSetThreadDpiAwarenessContext PSetThreadDpiAwarenessContext;
+
+void WinCompatInit();
+
+
+}

Modified: branches/cmake/teraterm/common/dlglib.h
===================================================================
--- branches/cmake/teraterm/common/dlglib.h	2018-08-05 13:33:28 UTC (rev 7175)
+++ branches/cmake/teraterm/common/dlglib.h	2018-08-10 15:12:13 UTC (rev 7176)
@@ -1,4 +1,4 @@
-/*
+/*
  * Copyright (C) 1994-1998 T. Teranishi
  * (C) 2005-2018 TeraTerm Project
  * All rights reserved.
@@ -27,7 +27,11 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-/* Routines for dialog boxes */
+#pragma once
+
+#include <windows.h>
+
+ /* Routines for dialog boxes */
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -52,6 +56,25 @@
 HFONT SetDlgFonts(HWND hDlg, const int nIDDlgItems[], int nIDDlgItemCount,
 				  const char *UILanguageFile, PCHAR key);
 
+////////////////////////////////////////
+DLGTEMPLATE *TTGetDlgTemplate(HINSTANCE hInst, LPCSTR lpTemplateName);
+DLGTEMPLATE *TTGetNewDlgTemplate(
+	HINSTANCE hInst, const DLGTEMPLATE *src,
+	size_t *PrevTemplSize, size_t *NewTemplSize);
+BOOL TTEndDialog(HWND hDlgWnd, INT_PTR nResult);
+HWND TTCreateDialogIndirectParam(
+	HINSTANCE hInstance,
+	LPCTSTR lpTemplateName,
+	HWND hWndParent,
+	DLGPROC lpDialogFunc,
+	LPARAM lParamInit);
+int TTDialogBoxParam(
+	HINSTANCE hInstance,
+	LPCTSTR lpTemplateName,
+	HWND hWndParent,
+	DLGPROC lpDialogFunc,
+	LPARAM lParamInit);
+
 #ifdef __cplusplus
 }
 #endif

Added: branches/cmake/teraterm/common/dlglib_cpp.cpp
===================================================================
--- branches/cmake/teraterm/common/dlglib_cpp.cpp	                        (rev 0)
+++ branches/cmake/teraterm/common/dlglib_cpp.cpp	2018-08-10 15:12:13 UTC (rev 7176)
@@ -0,0 +1,177 @@
+
+#include <windows.h>
+#include "dlglib.h"
+
+extern BOOL CallOnIdle(LONG lCount);
+
+typedef struct {
+	DLGPROC OrigProc;	// Dialog proc
+	LONG_PTR OrigUser;	// DWLP_USER
+	LPARAM ParamInit;
+	int DlgResult;
+} TTDialogData;
+
+static TTDialogData *TTDialogTmpData;
+
+static int TTDoModal(HWND hDlgWnd)
+{
+	LONG lIdleCount = 0;
+	MSG Msg;
+	TTDialogData *data = (TTDialogData *)GetWindowLongPtr(hDlgWnd, DWLP_USER);
+
+	for (;;)
+	{
+		if (!IsWindow(hDlgWnd)) {
+			// ウインドウが閉じられた
+			return IDCANCEL;
+		}
+#if defined(_DEBUG)
+		if (!IsWindowVisible(hDlgWnd)) {
+			// 誤ってEndDialog()が使われた? -> TTEndDialog()を使うこと
+			::ShowWindow(hDlgWnd, SW_SHOWNORMAL);
+		}
+#endif
+		int DlgRet = data->DlgResult;
+		if (DlgRet != 0) {
+			// TTEndDialog()が呼ばれた
+			return DlgRet;
+		}
+
+		if(!::PeekMessage(&Msg, NULL, NULL, NULL, PM_NOREMOVE))
+		{
+			// メッセージがない
+			// OnIdel() を処理する
+			if (!CallOnIdle(lIdleCount++)) {
+				// Idle処理がなくなった
+				lIdleCount = 0;
+				Sleep(10);
+			}
+			continue;
+		}
+		else
+		{
+			// メッセージがある
+
+			// pump message
+			BOOL quit = !::GetMessage(&Msg, NULL, NULL, NULL);
+			if (quit) {
+				// QM_QUIT
+				PostQuitMessage(0);
+				return IDCANCEL;
+			}
+
+			if (!::IsDialogMessage(hDlgWnd, &Msg)) {
+				// ダイアログ以外の処理
+				::TranslateMessage(&Msg);
+				::DispatchMessage(&Msg);
+			}
+		}
+	}
+
+	// ここには来ない
+	return IDOK;
+}
+
+static INT_PTR CALLBACK TTDialogProc(
+	HWND hDlgWnd, UINT msg,
+	WPARAM wParam, LPARAM lParam)
+{
+	TTDialogData *data = (TTDialogData *)GetWindowLongPtr(hDlgWnd, DWLP_USER);
+	if (msg == WM_INITDIALOG) {
+		TTDialogData *data = (TTDialogData *)lParam;
+		LONG_PTR r = SetWindowLongPtr(hDlgWnd, DWLP_USER, 0);
+		DWORD d = GetLastError();
+		SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)lParam);
+		SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)lParam);
+		lParam = data->ParamInit;
+	}
+
+	if (data == NULL) {
+		// WM_INITDIALOGよりも前は設定されていない
+		data = TTDialogTmpData;
+	} else {
+		// TTEndDialog()が呼ばれたとき、DWLP_USER が参照できない
+		TTDialogTmpData = data;
+	}
+
+	SetWindowLongPtr(hDlgWnd, DWLP_DLGPROC, (LONG_PTR)data->OrigProc);
+	SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)data->OrigUser);
+	LRESULT Result = data->OrigProc(hDlgWnd, msg, wParam, lParam);
+	data->OrigProc = (DLGPROC)GetWindowLongPtr(hDlgWnd, DWLP_DLGPROC);
+	data->OrigUser = GetWindowLongPtr(hDlgWnd, DWLP_USER);
+	SetWindowLongPtr(hDlgWnd, DWLP_DLGPROC, (LONG_PTR)TTDialogProc);
+	SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)data);
+
+	if (msg == WM_NCDESTROY) {
+		SetWindowLongPtr(hDlgWnd, DWLP_USER, 0);
+		free(data);
+	}
+
+	return Result;
+}
+
+/**
+ *	EndDialog() 互換関数
+ */
+BOOL TTEndDialog(HWND hDlgWnd, INT_PTR nResult)
+{
+	TTDialogData *data = TTDialogTmpData;
+	data->DlgResult = nResult;
+	return TRUE;
+}
+
+/**
+ *	CreateDialogIndirectParam() 互換関数
+ */
+HWND TTCreateDialogIndirectParam(
+	HINSTANCE hInstance,
+	LPCTSTR lpTemplateName,
+	HWND hWndParent,			// オーナーウィンドウのハンドル
+	DLGPROC lpDialogFunc,		// ダイアログボックスプロシージャへのポインタ
+	LPARAM lParamInit)			// 初期化値
+{
+	TTDialogData *data = (TTDialogData *)malloc(sizeof(TTDialogData));
+	data->OrigProc = lpDialogFunc;
+	data->OrigUser = 0;
+	data->ParamInit = lParamInit;
+	data->DlgResult = 0;
+#if 0
+	HRSRC hResource = ::FindResource(hInstance, lpTemplateName, RT_DIALOG);
+	HANDLE hDlgTemplate = ::LoadResource(hInstance, hResource);
+	DLGTEMPLATE *lpTemplate = (DLGTEMPLATE *)::LockResource(hDlgTemplate);
+#else
+	DLGTEMPLATE *lpTemplate = TTGetDlgTemplate(hInstance, lpTemplateName);
+#endif
+	TTDialogTmpData = data;
+	HWND hDlgWnd = CreateDialogIndirectParam(
+		hInstance, lpTemplate, hWndParent, TTDialogProc, (LPARAM)data);
+	TTDialogTmpData = NULL;
+	ShowWindow(hDlgWnd, SW_SHOW);
+    UpdateWindow(hDlgWnd);
+#if 1
+	free(lpTemplate);
+#endif
+	return hDlgWnd;
+}
+
+/**
+ *	DialogBoxParam() 互換関数
+ *		EndDialog()ではなく、TTEndDialog()を使用すること
+ */
+int TTDialogBoxParam(
+	HINSTANCE hInstance,
+	LPCTSTR lpTemplateName,
+	HWND hWndParent,			// オーナーウィンドウのハンドル
+	DLGPROC lpDialogFunc,		// ダイアログボックスプロシージャへのポインタ
+	LPARAM lParamInit)			// 初期化値
+{
+	HWND hDlgWnd = TTCreateDialogIndirectParam(
+		hInstance, lpTemplateName,
+		hWndParent, lpDialogFunc, lParamInit);
+	EnableWindow(hWndParent, FALSE);
+	int DlgResult = TTDoModal(hDlgWnd);
+	::DestroyWindow(hDlgWnd);
+	EnableWindow(hWndParent, TRUE);
+	return DlgResult;
+}
+

Added: branches/cmake/teraterm/common/dlglib_tmpl.cpp
===================================================================
--- branches/cmake/teraterm/common/dlglib_tmpl.cpp	                        (rev 0)
+++ branches/cmake/teraterm/common/dlglib_tmpl.cpp	2018-08-10 15:12:13 UTC (rev 7176)
@@ -0,0 +1,422 @@
+
+#include "dlglib.h"
+
+#include <wchar.h>
+
+//#define	_countof(ary)	(sizeof(ary)/sizeof(ary[0]))
+
+// https://docs.microsoft.com/ja-jp/windows/desktop/dlgbox/dlgtemplateex
+// https://www.pg-fl.jp/program/tips/dlgmem.htm
+#pragma pack(push, 1)
+typedef struct
+{
+    WORD dlgVer;
+    WORD signature;
+    DWORD helpID;
+    DWORD exStyle;
+    DWORD style;
+    WORD cDlgItems;
+    short x;
+    short y;
+    short cx;
+    short cy;
+
+	// sz_Or_Ord menu;				// name or ordinal of a menu resource
+	// sz_Or_Ord windowClass;		// name or ordinal of a window class
+	// WCHAR title[N];
+	// WORD pointsize;				// only if DS_SETFONT is set
+	// WORD weight;					// only if DS_SETFONT is set
+    // BYTE italic;					// only if DS_SETFONT is set
+    // BYTE charset;				// only if DS_SETFONT is set
+	// WCHAR typeface[stringLen];	// only if DS_SETFONT is set
+
+	// PAD
+
+    // DLGITEMTEMPLATEEX controls[cDlgItems];
+} DLGTEMPLATEEX;
+
+typedef struct
+{
+    DWORD helpID;
+    DWORD exStyle;
+    DWORD style;
+    short x;
+    short y;
+    short cx;
+    short cy;
+    DWORD id;
+
+	// sz_Or_Ord windowClass;	// name or ordinal of a window class
+	// sz_Or_Ord title;			// title string or ordinal of a resource
+	// WORD extraCount;			// bytes following creation data
+} DLGITEMTEMPLATEEX;
+#pragma pack(pop)
+
+#if 0 // !defined(_MSC_VER)
+static inline errno_t wcscpy_s(
+	wchar_t *dest,
+	size_t dest_size,
+	const wchar_t *src)
+{
+	wcscpy(dest, src);
+	return 0;
+}
+#endif
+
+static size_t CopySz(const WORD *src, WORD *dest)
+{
+	size_t size = 0;
+	do {
+		if (dest != NULL) {
+			*dest++ = *src;
+		}
+		size++;
+	} while (*src++ != 0);
+	return size;
+}
+
+static size_t CopySzOrOrd(const WORD *src, WORD *dest)
+{
+	size_t size;
+	if (*src == 0x0000) {
+		if (dest != NULL) {
+			*dest = *src;
+		}
+		size = 1;
+	} else if (*src == 0xffff) {
+		if (dest != NULL) {
+			*dest++ = *src++;
+			*dest++ = *src++;
+		}
+		size = 2;
+	} else {
+		return CopySz(src, dest);
+	}
+	return size;
+}
+
+static size_t CopyDlgItem(const WORD *src, WORD *dest)
+{
+	size_t size = sizeof(DLGITEMTEMPLATE) / sizeof(WORD);
+	if (dest != NULL) {
+		*(DLGITEMTEMPLATE *)dest = *(DLGITEMTEMPLATE *)src;
+		dest += size;
+	}
+	src += size;
+
+	size_t t;
+	t = CopySzOrOrd(src, dest);		// windowClass
+	size += t;
+	src += t; if (dest != NULL) dest += t;
+	t = CopySzOrOrd(src, dest);		// title
+	size += t;
+	src += t; if (dest != NULL) dest += t;
+	const WORD extraCount = *src++;
+	size++;
+	if (dest != NULL) {
+		*dest++ = extraCount;
+	}
+	if (extraCount != 0) {
+		size += extraCount;
+		if (dest != NULL) {
+			memcpy(dest, src, extraCount * sizeof(WORD));
+			dest += extraCount;
+		}
+		src += extraCount;
+	}
+	
+	size = (size + 1) & ~1;
+	return size;
+}
+
+/**
+ *	drc		ダイアログリソースへのポインタ
+ *	dest	コピー先(NULLのときコピーしない)
+ *	logfont	設定するフォント情報(ただし、dest_vがNULLの時は取得)
+ *			NULLのとき設定,取得しない
+ */
+static size_t CopyDlgTemplate(
+	const WORD *src_v,
+	WORD *dest_v,
+	LOGFONTW *logfont)
+{
+	const WORD *src = (const WORD *)src_v;
+	WORD *dest = (WORD *)dest_v;
+	size_t size = sizeof(DLGTEMPLATE) / sizeof(WORD);
+	const DLGTEMPLATE *dlg = (DLGTEMPLATE *)src;
+	if (dest != NULL) {
+		*(DLGTEMPLATE *)dest = *dlg;
+		dest += size;
+	}
+	src += size;
+
+	size_t t;
+	t = CopySzOrOrd(src, dest);	// menu
+	size += t;
+	src += t; if (dest != NULL) dest += t;
+	t = CopySzOrOrd(src, dest);	// windowClass
+	size += t;
+	src += t; if (dest != NULL) dest += t;
+	t = CopySz(src, dest);		// title
+	size += t;
+	src += t; if (dest != NULL) dest += t;
+	size_t dsize = 0;
+	if (dlg->style & DS_SETFONT) {
+		if (dest == NULL) {
+			// 取得
+			if (logfont != NULL) {
+				memset(logfont, 0, sizeof(*logfont));
+				logfont->lfHeight = -(*src++);
+				t = CopySz(src, (WORD *)(&logfont->lfFaceName[0]));
+			} else {
+				src++;
+				t = CopySz(src, NULL);
+			}
+			size += t + 1;
+		} else {
+			// セット
+			if (logfont != NULL) {
+				*dest++ = (WORD)(-logfont->lfHeight);
+				src += 1;
+				t = CopySz((WORD *)(&logfont->lfFaceName[0]), dest);
+				dest += t;
+				dsize = size + t + 1;
+				t = CopySz(src, NULL);
+				size += t + 1;
+			} else {
+				*dest++ = *src++;
+				t = CopySz(src, dest);
+				size += t + 1;
+				dsize = size;
+			}
+		}
+	}
+
+	size = (size + 1) & ~1;
+	src = ((const WORD *)src_v) + size;
+	if (dest != NULL) {
+		dsize = (dsize + 1) & ~1;
+		dest = ((WORD *)dest_v) + dsize;
+		size = dsize;
+	}
+	for (int i = 0; i < dlg->cdit; i++) {
+		t = CopyDlgItem(src, dest);
+		src += t; if (dest != NULL) dest += t;
+		size += t;
+	}
+
+	return size * sizeof(WORD);
+}
+
+static size_t CopyDlgItemEx(const WORD *src, WORD *dest)
+{
+	size_t size = sizeof(DLGITEMTEMPLATEEX) / sizeof(WORD);
+	if (dest != NULL) {
+		*(DLGITEMTEMPLATEEX *)dest = *(DLGITEMTEMPLATEEX *)src;
+		dest += size;
+	}
+	src += size;
+
+	size_t t;
+	t = CopySzOrOrd(src, dest);		// windowClass
+	size += t;
+	src += t; if (dest != NULL) dest += t;
+	t = CopySzOrOrd(src, dest);		// title
+	size += t;
+	src += t; if (dest != NULL) dest += t;
+	const WORD extraCount = *src++;
+	size++;
+	if (dest != NULL) {
+		*dest++ = extraCount;
+	}
+	if (extraCount != 0) {
+		size += extraCount;
+		if (dest != NULL) {
+			memcpy(dest, src, extraCount * sizeof(WORD));
+			dest += extraCount;
+		}
+		src += extraCount;
+	}
+	
+	size = (size + 1) & ~1;
+	return size;
+}
+
+/**
+ *	drc_v	ダイアログリソースへのポインタ
+ *	dest_v	コピー先(NULLのときコピーしない)
+ *	logfont	設定するフォント情報(ただし、dest_vがNULLの時は取得)
+ *			NULLのとき設定,取得しない
+ */
+static size_t CopyDlgTemplateEx(
+	const DLGTEMPLATE *src_v,
+	DLGTEMPLATE *dest_v,
+	LOGFONTW *logfont)
+{
+	const WORD *src = (const WORD *)src_v;
+	WORD *dest = (WORD *)dest_v;
+	if (*src != 1) {
+		return CopyDlgTemplate(src, dest, logfont);
+	}
+	// version 1
+	size_t size = sizeof(DLGTEMPLATEEX) / sizeof(WORD);
+	const DLGTEMPLATEEX *dlg = (DLGTEMPLATEEX *)src;
+	if (dest != NULL) {
+		*(DLGTEMPLATEEX *)dest = *dlg;
+		dest += size;
+	}
+	src += size;
+
+	size_t t;
+	t = CopySzOrOrd(src, dest);	// menu
+	size += t;
+	src += t; if (dest != NULL) dest += t;
+	t = CopySzOrOrd(src, dest);	// windowClass
+	size += t;
+	src += t; if (dest != NULL) dest += t;
+	t = CopySz(src, dest);		// title
+	size += t;
+	src += t; if (dest != NULL) dest += t;
+	size_t dsize = 0;
+	if (dlg->style & DS_SETFONT) {
+		if (dest == NULL) {
+			// 取得
+			if (logfont != NULL) {
+				memset(logfont, 0, sizeof(*logfont));
+				logfont->lfHeight = -(*src++);
+				logfont->lfWeight = *src++;
+				logfont->lfItalic = *((BYTE *)src);
+				logfont->lfCharSet = *(((BYTE *)src)+1);
+				src++;
+				t = CopySz(src, (WORD *)(&logfont->lfFaceName[0]));
+			} else {
+				src++;
+				src++;
+				src++;
+				t = CopySz(src, NULL);
+			}
+			size += t + 3;
+		} else {
+			// セット
+			if (logfont != NULL) {
+				*dest++ = (WORD)(-logfont->lfHeight);
+				*dest++ = (WORD)logfont->lfWeight;
+				*((BYTE *)dest) = logfont->lfItalic;
+				*(((BYTE *)dest)+1) = logfont->lfCharSet;
+				dest++;
+				src += 3;
+				t = CopySz((WORD *)(&logfont->lfFaceName[0]), dest);
+				dest += t;
+				dsize = size + t + 3;
+				t = CopySz(src, NULL);
+				size += t + 3;
+			} else {
+				*dest++ = *src++;
+				*dest++ = *src++;
+				*dest++ = *src++;
+				t = CopySz(src, dest);
+				size += t + 3;
+				dsize = size;
+			}
+		}
+	}
+
+	size = (size + 1) & ~1;
+	src = ((const WORD *)src_v) + size;
+	if (dest != NULL) {
+		dsize = (dsize + 1) & ~1;
+		dest = ((WORD *)dest_v) + dsize;
+		size = dsize;
+	}
+	for (int i = 0; i < dlg->cDlgItems; i++) {
+		t = CopyDlgItemEx(src, dest);
+		src += t; if (dest != NULL) dest += t;
+		size += t;
+	}
+
+	return size * sizeof(WORD);
+}
+
+DLGTEMPLATE *GetNewDlgTemplate(
+	HINSTANCE hInst, const DLGTEMPLATE *src,
+	const WCHAR *FontFaceName, LONG FontHeight, BYTE FontCharSet,
+	size_t *PrevTemplSize, size_t *NewTemplSize)
+{
+	LOGFONTW logfont;
+	const size_t prev_size = CopyDlgTemplateEx(src, NULL, &logfont);
+	DLGTEMPLATE *dest;
+	size_t new_size = 0;
+	if (FontFaceName == NULL) {
+		// simple copy
+		dest = (DLGTEMPLATE *)malloc(prev_size);
+		CopyDlgTemplateEx(src, dest, NULL);
+		new_size = prev_size;
+	} else {
+		// copy with replacing font
+		const size_t new_size_forcast = prev_size +
+			((wcslen(FontFaceName) - wcslen(logfont.lfFaceName)) *
+			 sizeof(WCHAR)) + 4;
+		dest = (DLGTEMPLATE *)malloc(new_size_forcast);
+		logfont.lfCharSet = FontCharSet;
+		logfont.lfHeight = FontHeight;
+		wcscpy_s(logfont.lfFaceName, _countof(logfont.lfFaceName),
+				 FontFaceName);
+		new_size = CopyDlgTemplateEx(src, dest, &logfont);
+	}
+
+	if (PrevTemplSize != NULL) {
+		*PrevTemplSize = prev_size;
+	}
+	if (NewTemplSize != NULL) {
+		*NewTemplSize = new_size;
+	}
+	return dest;
+}
+
+DLGTEMPLATE *GetDlgTemplate(
+	HINSTANCE hInst, LPCSTR lpTemplateName,
+	const WCHAR *FontFaceName, LONG FontHeight, BYTE FontCharSet)
+{
+	HRSRC hResource = ::FindResource(hInst, lpTemplateName, RT_DIALOG);
+	HANDLE hDlgTemplate = ::LoadResource(hInst, hResource);
+	const DLGTEMPLATE *src = (DLGTEMPLATE *)::LockResource(hDlgTemplate);
+
+	DLGTEMPLATE *dest = GetNewDlgTemplate(
+		hInst, src,
+		FontFaceName, FontHeight, FontCharSet,
+		NULL, NULL);
+
+	::FreeResource(hDlgTemplate);
+
+	return dest;
+}
+
+DLGTEMPLATE *TTGetNewDlgTemplate(
+	HINSTANCE hInst, const DLGTEMPLATE *src,
+	size_t *PrevTemplSize, size_t *NewTemplSize)
+{
+	const WCHAR *FontFaceName = L"Meiryo UI";
+//	const WCHAR *FontFaceName = L"Tahoma";
+	LONG FontHeight = 20;
+	BYTE FontCharSet = 128;
+
+	DLGTEMPLATE *DlgTemplate =
+		GetNewDlgTemplate(hInst, src,
+						  FontFaceName, FontHeight, FontCharSet,
+						  PrevTemplSize, NewTemplSize);
+
+	return DlgTemplate;
+}
+
+DLGTEMPLATE *TTGetDlgTemplate(HINSTANCE hInst, LPCSTR lpTemplateName)
+{
+	const WCHAR *FontFaceName = L"Meiryo UI";
+	LONG FontHeight = 20;
+	BYTE FontCharSet = 128;
+
+	DLGTEMPLATE *DlgTemplate =
+		GetDlgTemplate(hInst, lpTemplateName,
+					   FontFaceName, FontHeight, FontCharSet);
+
+	return DlgTemplate;
+}

Modified: branches/cmake/teraterm/common/ttftypes.h
===================================================================
--- branches/cmake/teraterm/common/ttftypes.h	2018-08-05 13:33:28 UTC (rev 7175)
+++ branches/cmake/teraterm/common/ttftypes.h	2018-08-10 15:12:13 UTC (rev 7176)
@@ -133,7 +133,8 @@
   DWORD StartTime;
 
   // log rotate
-  enum rotate_mode RotateMode;
+//  enum rotate_mode RotateMode;
+  int RotateMode;
   LONG RotateSize;
   int RotateStep;
 

Modified: branches/cmake/teraterm/common/ttlib.c
===================================================================
--- branches/cmake/teraterm/common/ttlib.c	2018-08-05 13:33:28 UTC (rev 7175)
+++ branches/cmake/teraterm/common/ttlib.c	2018-08-10 15:12:13 UTC (rev 7176)
@@ -970,7 +970,7 @@
 	strncpy_s(buf, buflen, Temp, _TRUNCATE);
 }
 
-void get_lang_msg(PCHAR key, PCHAR buf, int buf_len, PCHAR def, const char *iniFile)
+void get_lang_msg(const char *key, PCHAR buf, int buf_len, const char *def, const char *iniFile)
 {
 	GetI18nStr("Tera Term", key, buf, buf_len, def, iniFile);
 }

Modified: branches/cmake/teraterm/common/ttlib.h
===================================================================
--- branches/cmake/teraterm/common/ttlib.h	2018-08-05 13:33:28 UTC (rev 7175)
+++ branches/cmake/teraterm/common/ttlib.h	2018-08-10 15:12:13 UTC (rev 7176)
@@ -67,7 +67,7 @@
 void GetDefaultSetupFName(char *home, char *dest, int destlen);
 void GetUILanguageFile(char *buf, int buflen);
 void GetOnOffEntryInifile(char *entry, char *buf, int buflen);
-void get_lang_msg(PCHAR key, PCHAR buf, int buf_len, PCHAR def, const char *iniFile);
+void get_lang_msg(const char *key, PCHAR buf, int buf_len, const char *def, const char *iniFile);
 int get_lang_font(PCHAR key, HWND dlg, PLOGFONT logfont, HFONT *font, const char *iniFile);
 BOOL doSelectFolder(HWND hWnd, char *path, int pathlen, char *def, char *msg);
 void OutputDebugPrintf(char *fmt, ...);

Modified: branches/cmake/teraterm/common/tttypes.h
===================================================================
--- branches/cmake/teraterm/common/tttypes.h	2018-08-05 13:33:28 UTC (rev 7175)
+++ branches/cmake/teraterm/common/tttypes.h	2018-08-10 15:12:13 UTC (rev 7176)
@@ -643,7 +643,8 @@
 	WORD FontQuality;
 	char ScpSendDir[MAXPATHLEN];
 	char BGImageFilePath[MAX_PATH];
-	enum rotate_mode LogRotate;
+//	enum rotate_mode LogRotate;
+	int LogRotate;
 	DWORD LogRotateSize;
 	WORD LogRotateSizeType;
 	WORD LogRotateStep;

Modified: branches/cmake/teraterm/teraterm/CMakeLists.txt
===================================================================
--- branches/cmake/teraterm/teraterm/CMakeLists.txt	2018-08-05 13:33:28 UTC (rev 7175)
+++ branches/cmake/teraterm/teraterm/CMakeLists.txt	2018-08-10 15:12:13 UTC (rev 7176)
@@ -29,10 +29,16 @@
   ../common/ttlib.c
   ../common/ttlib.h
   ../common/dlglib.c
+  ../common/dlglib_cpp.cpp
   ../common/dlglib.h
+  ../common/dlglib_tmpl.cpp
+  ../common/compat_win.cpp
+  ../common/compat_win.h
   #
   addsetting.cpp
   addsetting.h
+  tmfc.cpp
+  tmfc.h
   buffer.c
   buffer.h
   clipboar.c
@@ -109,7 +115,9 @@
 
 set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:nafxcw.lib /NODEFAULTLIB:LIBCMT.lib")
 set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:nafxcwd.lib /NODEFAULTLIB:LIBCMTD.lib")
-set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:imagehlp.dll /DELAYLOAD:user32.dll /DELAYLOAD:shell32.dll")
+if (${MSVC})
+  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:imagehlp.dll /DELAYLOAD:user32.dll /DELAYLOAD:shell32.dll")
+endif()
 
 add_executable(
   teraterm WIN32

Modified: branches/cmake/teraterm/teraterm/addsetting.cpp
===================================================================
--- branches/cmake/teraterm/teraterm/addsetting.cpp	2018-08-05 13:33:28 UTC (rev 7175)
+++ branches/cmake/teraterm/teraterm/addsetting.cpp	2018-08-10 15:12:13 UTC (rev 7176)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008-2017 TeraTerm Project
+ * Copyright (C) 2008-2018 TeraTerm Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -30,10 +30,11 @@
  * Additional settings dialog
  */
 
-#include <afxwin.h>
-#include <afxdlgs.h>
-#include <afxcmn.h>
+#include <stdio.h>
+#include <tchar.h>
+#include <Windows.h>
 #include <commctrl.h>
+#include <time.h>
 
 #include "addsetting.h"
 #include "teraterm.h"
@@ -41,7 +42,16 @@
 #include "ttwinman.h"
 #include "ttcommon.h"
 #include "ttftypes.h"
+#include "dlglib.h"
+#include "compat_win.h"
 
+#ifndef max
+#define max(a,b)            (((a) > (b)) ? (a) : (b))
+#endif
+#ifndef min
+#define min(a,b)            (((a) < (b)) ? (a) : (b))
+#endif
+
 mouse_cursor_t MouseCursor[] = {
 	{"ARROW", IDC_ARROW},
 	{"IBEAM", IDC_IBEAM},
@@ -77,182 +87,98 @@
 	SendMessage(hWnd, WM_SETTEXT , 0, (LPARAM)buf);
 }
 
-
-
 // CGeneralPropPageDlg \x83_\x83C\x83A\x83\x8D\x83O
 
-IMPLEMENT_DYNAMIC(CGeneralPropPageDlg, CPropertyPage)
-
-CGeneralPropPageDlg::CGeneralPropPageDlg()
-	: CPropertyPage(CGeneralPropPageDlg::IDD)
+CGeneralPropPageDlg::CGeneralPropPageDlg(HINSTANCE inst, TTCPropertySheet *sheet)
+	: TTCPropertyPage(inst, CGeneralPropPageDlg::IDD, sheet)
 {
+	get_lang_msg("DLG_TABSHEET_TITLE_GENERAL", ts.UIMsg, sizeof(ts.UIMsg),
+	             "General", ts.UILanguageFile);
+	m_psp.pszTitle = _tcsdup(ts.UIMsg);
+	m_psp.dwFlags |= PSP_USETITLE;
 }
 
 CGeneralPropPageDlg::~CGeneralPropPageDlg()
 {
-	if (DlgGeneralFont != NULL) {
-		DeleteObject(DlgGeneralFont);
-	}
+	free((void *)m_psp.pszTitle);
 }
 
-BEGIN_MESSAGE_MAP(CGeneralPropPageDlg, CPropertyPage)
-END_MESSAGE_MAP()
-
 // CGeneralPropPageDlg \x83\x81\x83b\x83Z\x81[\x83W \x83n\x83\x93\x83h\x83\x89
 
-BOOL CGeneralPropPageDlg::OnInitDialog()
+void CGeneralPropPageDlg::OnInitDialog()
 {
-	char uimsg[MAX_UIMSG];
-	char buf[64];
-	CButton *btn;
+	TTCPropertyPage::OnInitDialog();
 
-	CPropertyPage::OnInitDialog();
+	static const DlgTextInfo TextInfos[] = {
+		{ IDC_CLICKABLE_URL, "DLG_TAB_GENERAL_CLICKURL" },
+		{ IDC_DISABLE_SENDBREAK, "DLG_TAB_GENERAL_DISABLESENDBREAK" },
+		{ IDC_ACCEPT_BROADCAST, "DLG_TAB_GENERAL_ACCEPTBROADCAST" },
+		{ IDC_MOUSEWHEEL_SCROLL_LINE, "DLG_TAB_GENERAL_MOUSEWHEEL_SCROLL_LINE" },
+		{ IDC_AUTOSCROLL_ONLY_IN_BOTTOM_LINE, "DLG_TAB_GENERAL_AUTOSCROLL_ONLY_IN_BOTTOM_LINE" },
+		{ IDC_CLEAR_ON_RESIZE, "DLG_TAB_GENERAL_CLEAR_ON_RESIZE" },
+		{ IDC_CURSOR_CHANGE_IME, "DLG_TAB_GENERAL_CURSOR_CHANGE_IME" },
+		{ IDC_LIST_HIDDEN_FONTS, "DLG_TAB_GENERAL_LIST_HIDDEN_FONTS" },
+		{ IDC_TITLEFMT_GROUP, "DLG_TAB_GENERAL_TITLEFMT_GROUP" },
+		{ IDC_TITLEFMT_DISPHOSTNAME, "DLG_TAB_GENERAL_TITLEFMT_DISPHOSTNAME" },
+		{ IDC_TITLEFMT_DISPSESSION, "DLG_TAB_GENERAL_TITLEFMT_DISPSESSION" },
+		{ IDC_TITLEFMT_DISPVTTEK, "DLG_TAB_GENERAL_TITLEFMT_DISPVTTEK" },
+		{ IDC_TITLEFMT_SWAPHOSTTITLE, "DLG_TAB_GENERAL_TITLEFMT_SWAPHOSTTITLE" },
+		{ IDC_TITLEFMT_DISPTCPPORT, "DLG_TAB_GENERAL_TITLEFMT_DISPTCPPORT" },
+		{ IDC_TITLEFMT_DISPSERIALSPEED, "DLG_TAB_GENERAL_TITLEFMT_DISPSERIALSPEED" }
+	};
+	SetDlgTexts(m_hWnd, TextInfos, _countof(TextInfos), ts.UILanguageFile);
 
-	font = (HFONT)SendMessage(WM_GETFONT, 0, 0);
-	GetObject(font, sizeof(LOGFONT), &logfont);
-	if (get_lang_font("DLG_TAHOMA_FONT", GetSafeHwnd(), &logfont, &DlgGeneralFont, ts.UILanguageFile)) {
-		SendDlgItemMessage(IDC_CLICKABLE_URL, WM_SETFONT, (WPARAM)DlgGeneralFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_DISABLE_SENDBREAK, WM_SETFONT, (WPARAM)DlgGeneralFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_ACCEPT_BROADCAST, WM_SETFONT, (WPARAM)DlgGeneralFont, MAKELPARAM(TRUE,0)); // 337: 2007/03/20
-		SendDlgItemMessage(IDC_MOUSEWHEEL_SCROLL_LINE, WM_SETFONT, (WPARAM)DlgGeneralFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_SCROLL_LINE, WM_SETFONT, (WPARAM)DlgGeneralFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_AUTOSCROLL_ONLY_IN_BOTTOM_LINE, WM_SETFONT, (WPARAM)DlgGeneralFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_CLEAR_ON_RESIZE, WM_SETFONT, (WPARAM)DlgGeneralFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_CURSOR_CHANGE_IME, WM_SETFONT, (WPARAM)DlgGeneralFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_LIST_HIDDEN_FONTS, WM_SETFONT, (WPARAM)DlgGeneralFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_TITLEFMT_GROUP, WM_SETFONT, (WPARAM)DlgGeneralFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_TITLEFMT_DISPHOSTNAME, WM_SETFONT, (WPARAM)DlgGeneralFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_TITLEFMT_DISPSESSION, WM_SETFONT, (WPARAM)DlgGeneralFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_TITLEFMT_DISPVTTEK, WM_SETFONT, (WPARAM)DlgGeneralFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_TITLEFMT_SWAPHOSTTITLE, WM_SETFONT, (WPARAM)DlgGeneralFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_TITLEFMT_DISPTCPPORT, WM_SETFONT, (WPARAM)DlgGeneralFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_TITLEFMT_DISPSERIALSPEED, WM_SETFONT, (WPARAM)DlgGeneralFont, MAKELPARAM(TRUE,0));
-	}
-	else {
-		DlgGeneralFont = NULL;
-	}
-
-	GetDlgItemText(IDC_CLICKABLE_URL, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_GENERAL_CLICKURL", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_CLICKABLE_URL, ts.UIMsg);
-	GetDlgItemText(IDC_DISABLE_SENDBREAK, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_GENERAL_DISABLESENDBREAK", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_DISABLE_SENDBREAK, ts.UIMsg);
-	GetDlgItemText(IDC_ACCEPT_BROADCAST, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_GENERAL_ACCEPTBROADCAST", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_ACCEPT_BROADCAST, ts.UIMsg);
-	GetDlgItemText(IDC_MOUSEWHEEL_SCROLL_LINE, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_GENERAL_MOUSEWHEEL_SCROLL_LINE", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_MOUSEWHEEL_SCROLL_LINE, ts.UIMsg);
-	GetDlgItemText(IDC_AUTOSCROLL_ONLY_IN_BOTTOM_LINE, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_GENERAL_AUTOSCROLL_ONLY_IN_BOTTOM_LINE", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_AUTOSCROLL_ONLY_IN_BOTTOM_LINE, ts.UIMsg);
-	GetDlgItemText(IDC_CLEAR_ON_RESIZE, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_GENERAL_CLEAR_ON_RESIZE", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_CLEAR_ON_RESIZE, ts.UIMsg);
-	GetDlgItemText(IDC_CURSOR_CHANGE_IME, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_GENERAL_CURSOR_CHANGE_IME", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_CURSOR_CHANGE_IME, ts.UIMsg);
-	GetDlgItemText(IDC_LIST_HIDDEN_FONTS, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_GENERAL_LIST_HIDDEN_FONTS", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_LIST_HIDDEN_FONTS, ts.UIMsg);
-
-	GetDlgItemText(IDC_TITLEFMT_GROUP, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_GENERAL_TITLEFMT_GROUP", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_TITLEFMT_GROUP, ts.UIMsg);
-	GetDlgItemText(IDC_TITLEFMT_DISPHOSTNAME, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_GENERAL_TITLEFMT_DISPHOSTNAME", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_TITLEFMT_DISPHOSTNAME, ts.UIMsg);
-	GetDlgItemText(IDC_TITLEFMT_DISPSESSION, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_GENERAL_TITLEFMT_DISPSESSION", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_TITLEFMT_DISPSESSION, ts.UIMsg);
-	GetDlgItemText(IDC_TITLEFMT_DISPVTTEK, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_GENERAL_TITLEFMT_DISPVTTEK", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_TITLEFMT_DISPVTTEK, ts.UIMsg);
-	GetDlgItemText(IDC_TITLEFMT_SWAPHOSTTITLE, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_GENERAL_TITLEFMT_SWAPHOSTTITLE", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_TITLEFMT_SWAPHOSTTITLE, ts.UIMsg);
-	GetDlgItemText(IDC_TITLEFMT_DISPTCPPORT, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_GENERAL_TITLEFMT_DISPTCPPORT", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_TITLEFMT_DISPTCPPORT, ts.UIMsg);
-	GetDlgItemText(IDC_TITLEFMT_DISPSERIALSPEED, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_GENERAL_TITLEFMT_DISPSERIALSPEED", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_TITLEFMT_DISPSERIALSPEED, ts.UIMsg);
-
 	// (1)DisableAcceleratorSendBreak
-	btn = (CButton *)GetDlgItem(IDC_DISABLE_SENDBREAK);
-	btn->SetCheck(ts.DisableAcceleratorSendBreak);
+	SetCheck(IDC_DISABLE_SENDBREAK, ts.DisableAcceleratorSendBreak);
 
 	// (2)EnableClickableUrl
-	btn = (CButton *)GetDlgItem(IDC_CLICKABLE_URL);
-	btn->SetCheck(ts.EnableClickableUrl);
+	SetCheck(IDC_CLICKABLE_URL, ts.EnableClickableUrl);
 
 	// (3)AcceptBroadcast 337: 2007/03/20
-	btn = (CButton *)GetDlgItem(IDC_ACCEPT_BROADCAST);
-	btn->SetCheck(ts.AcceptBroadcast);
+	SetCheck(IDC_ACCEPT_BROADCAST, ts.AcceptBroadcast);
 
 	// (4)IDC_MOUSEWHEEL_SCROLL_LINE
+	char buf[64];
 	_snprintf_s(buf, sizeof(buf), "%d", ts.MouseWheelScrollLine);
 	SetDlgItemText(IDC_SCROLL_LINE, buf);
 
 	// (5)IDC_AUTOSCROLL_ONLY_IN_BOTTOM_LINE
-	btn = (CButton *)GetDlgItem(IDC_AUTOSCROLL_ONLY_IN_BOTTOM_LINE);
-	btn->SetCheck(ts.AutoScrollOnlyInBottomLine);
+	SetCheck(IDC_AUTOSCROLL_ONLY_IN_BOTTOM_LINE, ts.AutoScrollOnlyInBottomLine);
 
 	// (6)IDC_CLEAR_ON_RESIZE
-	btn = (CButton *)GetDlgItem(IDC_CLEAR_ON_RESIZE);
-	btn->SetCheck((ts.TermFlag & TF_CLEARONRESIZE) != 0);
+	SetCheck(IDC_CLEAR_ON_RESIZE, (ts.TermFlag & TF_CLEARONRESIZE) != 0);
 
 	// (7)IDC_CURSOR_CHANGE_IME
-	btn = (CButton *)GetDlgItem(IDC_CURSOR_CHANGE_IME);
-	btn->SetCheck((ts.WindowFlag & WF_IMECURSORCHANGE) != 0);
+	SetCheck(IDC_CURSOR_CHANGE_IME, (ts.WindowFlag & WF_IMECURSORCHANGE) != 0);
 
 	// (8)IDC_LIST_HIDDEN_FONTS
-	btn = (CButton *)GetDlgItem(IDC_LIST_HIDDEN_FONTS);
-	btn->SetCheck(ts.ListHiddenFonts);
+	SetCheck(IDC_LIST_HIDDEN_FONTS, ts.ListHiddenFonts);
 
 	// (9) Title Format
-	btn = (CButton *)GetDlgItem(IDC_TITLEFMT_DISPHOSTNAME);
-	btn->SetCheck((ts.TitleFormat & 1) != 0);
+	SetCheck(IDC_TITLEFMT_DISPHOSTNAME, (ts.TitleFormat & 1) != 0);
+	SetCheck(IDC_TITLEFMT_DISPSESSION, (ts.TitleFormat & (1<<1)) != 0);
+	SetCheck(IDC_TITLEFMT_DISPVTTEK, (ts.TitleFormat & (1<<2)) != 0);
+	SetCheck(IDC_TITLEFMT_SWAPHOSTTITLE, (ts.TitleFormat & (1<<3)) != 0);
+	SetCheck(IDC_TITLEFMT_DISPTCPPORT, (ts.TitleFormat & (1<<4)) != 0);
+	SetCheck(IDC_TITLEFMT_DISPSERIALSPEED, (ts.TitleFormat & (1<<5)) != 0);
 
-	btn = (CButton *)GetDlgItem(IDC_TITLEFMT_DISPSESSION);
-	btn->SetCheck((ts.TitleFormat & (1<<1)) != 0);
-
-	btn = (CButton *)GetDlgItem(IDC_TITLEFMT_DISPVTTEK);
-	btn->SetCheck((ts.TitleFormat & (1<<2)) != 0);
-
-	btn = (CButton *)GetDlgItem(IDC_TITLEFMT_SWAPHOSTTITLE);
-	btn->SetCheck((ts.TitleFormat & (1<<3)) != 0);
-
-	btn = (CButton *)GetDlgItem(IDC_TITLEFMT_DISPTCPPORT);
-	btn->SetCheck((ts.TitleFormat & (1<<4)) != 0);
-
-	btn = (CButton *)GetDlgItem(IDC_TITLEFMT_DISPSERIALSPEED);
-	btn->SetCheck((ts.TitleFormat & (1<<5)) != 0);
-
 	// \x83_\x83C\x83A\x83\x8D\x83O\x82Ƀt\x83H\x81[\x83J\x83X\x82𓖂Ă\xE9 (2004.12.7 yutaka)
 	::SetFocus(::GetDlgItem(GetSafeHwnd(), IDC_CLICKABLE_URL));
-
-	return FALSE;
 }
 
 void CGeneralPropPageDlg::OnOK()
 {
-	CButton *btn;
 	char buf[64];
 	int val;
 
 	// (1)
-	btn = (CButton *)GetDlgItem(IDC_DISABLE_SENDBREAK);
-	ts.DisableAcceleratorSendBreak = btn->GetCheck();
+	ts.DisableAcceleratorSendBreak = GetCheck(IDC_DISABLE_SENDBREAK);
 
 	// (2)
-	btn = (CButton *)GetDlgItem(IDC_CLICKABLE_URL);
-	ts.EnableClickableUrl = btn->GetCheck();
+	ts.EnableClickableUrl = GetCheck(IDC_CLICKABLE_URL);
 
 	// (3) 337: 2007/03/20
-	btn = (CButton *)GetDlgItem(IDC_ACCEPT_BROADCAST);
-	ts.AcceptBroadcast = btn->GetCheck();
+	ts.AcceptBroadcast = GetCheck(IDC_ACCEPT_BROADCAST);
 
 	// (4)IDC_MOUSEWHEEL_SCROLL_LINE
 	GetDlgItemText(IDC_SCROLL_LINE, buf, sizeof(buf));
@@ -261,101 +187,68 @@
 		ts.MouseWheelScrollLine = val;
 
 	// (5)IDC_AUTOSCROLL_ONLY_IN_BOTTOM_LINE
-	btn = (CButton *)GetDlgItem(IDC_AUTOSCROLL_ONLY_IN_BOTTOM_LINE);
-	ts.AutoScrollOnlyInBottomLine = btn->GetCheck();
+	ts.AutoScrollOnlyInBottomLine = GetCheck(IDC_AUTOSCROLL_ONLY_IN_BOTTOM_LINE);
 
 	// (6)IDC_CLEAR_ON_RESIZE
-	btn = (CButton *)GetDlgItem(IDC_CLEAR_ON_RESIZE);
-	if (((ts.TermFlag & TF_CLEARONRESIZE) != 0) != btn->GetCheck()) {
+	if (((ts.TermFlag & TF_CLEARONRESIZE) != 0) != GetCheck(IDC_CLEAR_ON_RESIZE)) {
 		ts.TermFlag ^= TF_CLEARONRESIZE;
 	}
 
 	// (7)IDC_CURSOR_CHANGE_IME
-	btn = (CButton *)GetDlgItem(IDC_CURSOR_CHANGE_IME);
-	if (((ts.WindowFlag & WF_IMECURSORCHANGE) != 0) != btn->GetCheck()) {
+	if (((ts.WindowFlag & WF_IMECURSORCHANGE) != 0) != GetCheck(IDC_CURSOR_CHANGE_IME)) {
 		ts.WindowFlag ^= WF_IMECURSORCHANGE;
 	}
 
 	// (8)IDC_LIST_HIDDEN_FONTS
-	btn = (CButton *)GetDlgItem(IDC_LIST_HIDDEN_FONTS);
-	ts.ListHiddenFonts = btn->GetCheck();
+	ts.ListHiddenFonts = GetCheck(IDC_LIST_HIDDEN_FONTS);
 
 	// (9) Title Format
-	btn = (CButton *)GetDlgItem(IDC_TITLEFMT_DISPHOSTNAME);
-	ts.TitleFormat = (btn->GetCheck() == BST_CHECKED);
-	btn = (CButton *)GetDlgItem(IDC_TITLEFMT_DISPSESSION);
-	ts.TitleFormat |= ((btn->GetCheck() == BST_CHECKED) << 1);
-	btn = (CButton *)GetDlgItem(IDC_TITLEFMT_DISPVTTEK);
-	ts.TitleFormat |= ((btn->GetCheck() == BST_CHECKED) << 2);
-	btn = (CButton *)GetDlgItem(IDC_TITLEFMT_SWAPHOSTTITLE);
-	ts.TitleFormat |= ((btn->GetCheck() == BST_CHECKED) << 3);
-	btn = (CButton *)GetDlgItem(IDC_TITLEFMT_DISPTCPPORT);
-	ts.TitleFormat |= ((btn->GetCheck() == BST_CHECKED) << 4);
-	btn = (CButton *)GetDlgItem(IDC_TITLEFMT_DISPSERIALSPEED);
-	ts.TitleFormat |= ((btn->GetCheck() == BST_CHECKED) << 5);
+	ts.TitleFormat = GetCheck(IDC_TITLEFMT_DISPHOSTNAME) == BST_CHECKED;
+	ts.TitleFormat |= (GetCheck(IDC_TITLEFMT_DISPSESSION) == BST_CHECKED) << 1;
+	ts.TitleFormat |= (GetCheck(IDC_TITLEFMT_DISPVTTEK) == BST_CHECKED) << 2;
+	ts.TitleFormat |= (GetCheck(IDC_TITLEFMT_SWAPHOSTTITLE) == BST_CHECKED) << 3;
+	ts.TitleFormat |= (GetCheck(IDC_TITLEFMT_DISPTCPPORT) == BST_CHECKED) << 4;
+	ts.TitleFormat |= (GetCheck(IDC_TITLEFMT_DISPSERIALSPEED) == BST_CHECKED) << 5;
 }
 
-
-
 // CSequencePropPageDlg \x83_\x83C\x83A\x83\x8D\x83O
 
-IMPLEMENT_DYNAMIC(CSequencePropPageDlg, CPropertyPage)
-
-CSequencePropPageDlg::CSequencePropPageDlg()
-	: CPropertyPage(CSequencePropPageDlg::IDD)
+CSequencePropPageDlg::CSequencePropPageDlg(HINSTANCE inst, TTCPropertySheet *sheet)
+	: TTCPropertyPage(inst, CSequencePropPageDlg::IDD, sheet)
 {
+	get_lang_msg("DLG_TABSHEET_TITLE_SEQUENCE", ts.UIMsg, sizeof(ts.UIMsg),
+	             "Control Sequence", ts.UILanguageFile);
+	m_psp.pszTitle = _tcsdup(ts.UIMsg);
+	m_psp.dwFlags |= PSP_USETITLE;
 }
 
 CSequencePropPageDlg::~CSequencePropPageDlg()
 {
-	if (DlgSequenceFont != NULL) {
-		DeleteObject(DlgSequenceFont);
-	}
+	free((void *)m_psp.pszTitle);
 }
 
-BEGIN_MESSAGE_MAP(CSequencePropPageDlg, CPropertyPage)
-END_MESSAGE_MAP()
-
 // CSequencePropPageDlg \x83\x81\x83b\x83Z\x81[\x83W \x83n\x83\x93\x83h\x83\x89
 
-BOOL CSequencePropPageDlg::OnInitDialog()
+void CSequencePropPageDlg::OnInitDialog()
 {
-	char uimsg[MAX_UIMSG];
-	CButton *btn, *btn2;
-	CComboBox *cmb;
+	TTCPropertyPage::OnInitDialog();
 
-	CPropertyPage::OnInitDialog();
+	static const DlgTextInfo TextInfos[] = {
+		{ IDC_ACCEPT_MOUSE_EVENT_TRACKING, "DLG_TAB_SEQUENCE_ACCEPT_MOUSE_EVENT_TRACKING" },
+		{ IDC_DISABLE_MOUSE_TRACKING_CTRL, "DLG_TAB_SEQUENCE_DISABLE_MOUSE_TRACKING_CTRL" },
+		{ IDC_ACCEPT_TITLE_CHANGING_LABEL, "DLG_TAB_SEQUENCE_ACCEPT_TITLE_CHANGING" },
 
-	font = (HFONT)SendMessage(WM_GETFONT, 0, 0);
-	GetObject(font, sizeof(LOGFONT), &logfont);
-	if (get_lang_font("DLG_TAHOMA_FONT", GetSafeHwnd(), &logfont, &DlgSequenceFont, ts.UILanguageFile)) {
-		SendDlgItemMessage(IDC_ACCEPT_MOUSE_EVENT_TRACKING, WM_SETFONT, (WPARAM)DlgSequenceFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_DISABLE_MOUSE_TRACKING_CTRL, WM_SETFONT, (WPARAM)DlgSequenceFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_ACCEPT_TITLE_CHANGING_LABEL, WM_SETFONT, (WPARAM)DlgSequenceFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_ACCEPT_TITLE_CHANGING, WM_SETFONT, (WPARAM)DlgSequenceFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_TITLE_REPORT_LABEL, WM_SETFONT, (WPARAM)DlgSequenceFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_TITLE_REPORT, WM_SETFONT, (WPARAM)DlgSequenceFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_WINDOW_CTRL, WM_SETFONT, (WPARAM)DlgSequenceFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_WINDOW_REPORT, WM_SETFONT, (WPARAM)DlgSequenceFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_CURSOR_CTRL_SEQ, WM_SETFONT, (WPARAM)DlgSequenceFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_CLIPBOARD_ACCESS_LABEL, WM_SETFONT, (WPARAM)DlgSequenceFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_CLIPBOARD_ACCESS, WM_SETFONT, (WPARAM)DlgSequenceFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_CLIPBOARD_NOTIFY, WM_SETFONT, (WPARAM)DlgSequenceFont, MAKELPARAM(TRUE,0));
-	}
-	else {
-		DlgSequenceFont = NULL;
-	}
+		{ IDC_CURSOR_CTRL_SEQ, "DLG_TAB_SEQUENCE_CURSOR_CTRL" },
+		{ IDC_WINDOW_CTRL, "DLG_TAB_SEQUENCE_WINDOW_CTRL" },
+		{ IDC_WINDOW_REPORT, "DLG_TAB_SEQUENCE_WINDOW_REPORT" },
+		{ IDC_TITLE_REPORT_LABEL, "DLG_TAB_SEQUENCE_TITLE_REPORT" },
 
-	GetDlgItemText(IDC_ACCEPT_MOUSE_EVENT_TRACKING, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_SEQUENCE_ACCEPT_MOUSE_EVENT_TRACKING", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_ACCEPT_MOUSE_EVENT_TRACKING, ts.UIMsg);
-	GetDlgItemText(IDC_DISABLE_MOUSE_TRACKING_CTRL, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_SEQUENCE_DISABLE_MOUSE_TRACKING_CTRL", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_DISABLE_MOUSE_TRACKING_CTRL, ts.UIMsg);
-	GetDlgItemText(IDC_ACCEPT_TITLE_CHANGING_LABEL, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_SEQUENCE_ACCEPT_TITLE_CHANGING", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_ACCEPT_TITLE_CHANGING_LABEL, ts.UIMsg);
+		{ IDC_CLIPBOARD_ACCESS_LABEL, "DLG_TAB_SEQUENCE_CLIPBOARD_ACCESS" },
 
+		{ IDC_CLIPBOARD_NOTIFY, "DLG_TAB_SEQUENCE_CLIPBOARD_NOTIFY" },
+	};
+	SetDlgTexts(m_hWnd, TextInfos, _countof(TextInfos), ts.UILanguageFile);
+
 	get_lang_msg("DLG_TAB_SEQUENCE_ACCEPT_TITLE_CHANGING_OFF", ts.UIMsg, sizeof(ts.UIMsg), "off", ts.UILanguageFile);
 	SendDlgItemMessage(IDC_ACCEPT_TITLE_CHANGING, CB_ADDSTRING, 0, (LPARAM)ts.UIMsg);
 	get_lang_msg("DLG_TAB_SEQUENCE_ACCEPT_TITLE_CHANGING_OVERWRITE", ts.UIMsg, sizeof(ts.UIMsg), "overwrite", ts.UILanguageFile);
@@ -365,19 +258,6 @@
 	get_lang_msg("DLG_TAB_SEQUENCE_ACCEPT_TITLE_CHANGING_LAST", ts.UIMsg, sizeof(ts.UIMsg), "last", ts.UILanguageFile);
 	SendDlgItemMessage(IDC_ACCEPT_TITLE_CHANGING, CB_ADDSTRING, 0, (LPARAM)ts.UIMsg);
 
-	GetDlgItemText(IDC_CURSOR_CTRL_SEQ, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_SEQUENCE_CURSOR_CTRL", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_CURSOR_CTRL_SEQ, ts.UIMsg);
-	GetDlgItemText(IDC_WINDOW_CTRL, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_SEQUENCE_WINDOW_CTRL", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_WINDOW_CTRL, ts.UIMsg);
-	GetDlgItemText(IDC_WINDOW_REPORT, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_SEQUENCE_WINDOW_REPORT", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_WINDOW_REPORT, ts.UIMsg);
-	GetDlgItemText(IDC_TITLE_REPORT_LABEL, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_SEQUENCE_TITLE_REPORT", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_TITLE_REPORT_LABEL, ts.UIMsg);
-
 	get_lang_msg("DLG_TAB_SEQUENCE_TITLE_REPORT_IGNORE", ts.UIMsg, sizeof(ts.UIMsg), "ignore", ts.UILanguageFile);
 	SendDlgItemMessage(IDC_TITLE_REPORT, CB_ADDSTRING, 0, (LPARAM)ts.UIMsg);
 	get_lang_msg("DLG_TAB_SEQUENCE_TITLE_REPORT_ACCEPT", ts.UIMsg, sizeof(ts.UIMsg), "accept", ts.UILanguageFile);
@@ -385,10 +265,6 @@
 	get_lang_msg("DLG_TAB_SEQUENCE_TITLE_REPORT_EMPTY", ts.UIMsg, sizeof(ts.UIMsg), "empty", ts.UILanguageFile);
 	SendDlgItemMessage(IDC_TITLE_REPORT, CB_ADDSTRING, 0, (LPARAM)ts.UIMsg);
 
-	GetDlgItemText(IDC_CLIPBOARD_ACCESS_LABEL, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_SEQUENCE_CLIPBOARD_ACCESS", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_CLIPBOARD_ACCESS_LABEL, ts.UIMsg);
-
 	get_lang_msg("DLG_TAB_SEQUENCE_CLIPBOARD_ACCESS_OFF", ts.UIMsg, sizeof(ts.UIMsg), "off", ts.UILanguageFile);
 	SendDlgItemMessage(IDC_CLIPBOARD_ACCESS, CB_ADDSTRING, 0, (LPARAM)ts.UIMsg);
 	get_lang_msg("DLG_TAB_SEQUENCE_CLIPBOARD_ACCESS_WRITE", ts.UIMsg, sizeof(ts.UIMsg), "write only", ts.UILanguageFile);
@@ -398,128 +274,73 @@
 	get_lang_msg("DLG_TAB_SEQUENCE_CLIPBOARD_ACCESS_ON", ts.UIMsg, sizeof(ts.UIMsg), "read/write", ts.UILanguageFile);
 	SendDlgItemMessage(IDC_CLIPBOARD_ACCESS, CB_ADDSTRING, 0, (LPARAM)ts.UIMsg);
 
-	GetDlgItemText(IDC_CLIPBOARD_NOTIFY, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_SEQUENCE_CLIPBOARD_NOTIFY", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_CLIPBOARD_NOTIFY, ts.UIMsg);
-
 	// (1)IDC_ACCEPT_MOUSE_EVENT_TRACKING
-	btn = (CButton *)GetDlgItem(IDC_ACCEPT_MOUSE_EVENT_TRACKING);
-	btn2 = (CButton *)GetDlgItem(IDC_DISABLE_MOUSE_TRACKING_CTRL);
-	btn->SetCheck(ts.MouseEventTracking);
-	if (ts.MouseEventTracking) {
-		btn2->EnableWindow(TRUE);
-	} else {
-		btn2->EnableWindow(FALSE);
-	}
+	SetCheck(IDC_ACCEPT_MOUSE_EVENT_TRACKING, ts.MouseEventTracking);
+	EnableDlgItem(IDC_DISABLE_MOUSE_TRACKING_CTRL, ts.MouseEventTracking ? TRUE : FALSE);
 
 	// (2)IDC_DISABLE_MOUSE_TRACKING_CTRL
-	btn2->SetCheck(ts.DisableMouseTrackingByCtrl);
+	SetCheck(IDC_DISABLE_MOUSE_TRACKING_CTRL, ts.DisableMouseTrackingByCtrl);
 
 	// (3)IDC_ACCEPT_TITLE_CHANGING
-	cmb = (CComboBox *)GetDlgItem(IDC_ACCEPT_TITLE_CHANGING);
-	cmb->SetCurSel(ts.AcceptTitleChangeRequest);
+	SetCurSel(IDC_ACCEPT_TITLE_CHANGING, ts.AcceptTitleChangeRequest);
 
 	// (4)IDC_TITLE_REPORT
-	cmb = (CComboBox *)GetDlgItem(IDC_TITLE_REPORT);
-	switch (ts.WindowFlag & WF_TITLEREPORT) {
-		case IdTitleReportIgnore:
-			cmb->SetCurSel(0);
-			break;
-		case IdTitleReportAccept:
-			cmb->SetCurSel(1);
-			break;
-		default: // IdTitleReportEmpty
-			cmb->SetCurSel(2);
-			break;
-	}
+	SetCurSel(IDC_TITLE_REPORT,
+			  (ts.WindowFlag & WF_TITLEREPORT) == IdTitleReportIgnore ? 0 :
+			  (ts.WindowFlag & WF_TITLEREPORT) == IdTitleReportAccept ? 1
+			  /*(ts.WindowFlag & WF_TITLEREPORT) == IdTitleReportEmptye ? */ : 2);
 
 	// (5)IDC_WINDOW_CTRL
-	btn = (CButton *)GetDlgItem(IDC_WINDOW_CTRL);
-	btn->SetCheck((ts.WindowFlag & WF_WINDOWCHANGE) != 0);
+	SetCheck(IDC_WINDOW_CTRL, (ts.WindowFlag & WF_WINDOWCHANGE) != 0);
 
 	// (6)IDC_WINDOW_REPORT
-	btn = (CButton *)GetDlgItem(IDC_WINDOW_REPORT);
-	btn->SetCheck((ts.WindowFlag & WF_WINDOWREPORT) != 0);
+	SetCheck(IDC_WINDOW_REPORT, (ts.WindowFlag & WF_WINDOWREPORT) != 0);
 
 	// (7)IDC_CURSOR_CTRL_SEQ
-	btn = (CButton *)GetDlgItem(IDC_CURSOR_CTRL_SEQ);
-	btn->SetCheck((ts.WindowFlag & WF_CURSORCHANGE) != 0);
+	SetCheck(IDC_CURSOR_CTRL_SEQ, (ts.WindowFlag & WF_CURSORCHANGE) != 0);
 
 	// (8)IDC_CLIPBOARD_ACCESS
-	cmb = (CComboBox *)GetDlgItem(IDC_CLIPBOARD_ACCESS);
-	switch (ts.CtrlFlag & CSF_CBRW) {
-		case CSF_CBRW:
-			cmb->SetCurSel(3);
-			break;
-		case CSF_CBREAD:
-			cmb->SetCurSel(2);
-			break;
-		case CSF_CBWRITE:
-			cmb->SetCurSel(1);
-			break;
-		default: // off
-			cmb->SetCurSel(0);
-			break;
-	}
+	SetCurSel(IDC_CLIPBOARD_ACCESS,
+			  (ts.CtrlFlag & CSF_CBRW) == CSF_CBRW ? 3 :
+			  (ts.CtrlFlag & CSF_CBRW) == CSF_CBREAD ? 2 :
+			  (ts.CtrlFlag & CSF_CBRW) == CSF_CBWRITE ? 1 :
+			  0);	// off
 
 	// (9)IDC_CLIPBOARD_NOTIFY
-	btn = (CButton *)GetDlgItem(IDC_CLIPBOARD_NOTIFY);
-	btn->SetCheck(ts.NotifyClipboardAccess);
-	if (HasBalloonTipSupport()) {
-		btn->EnableWindow(TRUE);
-	}
-	else {
-		btn->EnableWindow(FALSE);
-	}
+	SetCheck(IDC_CLIPBOARD_NOTIFY, ts.NotifyClipboardAccess);
+	EnableDlgItem(IDC_CLIPBOARD_NOTIFY, HasBalloonTipSupport() ? TRUE : FALSE);
 
 	// \x83_\x83C\x83A\x83\x8D\x83O\x82Ƀt\x83H\x81[\x83J\x83X\x82𓖂Ă\xE9 (2004.12.7 yutaka)
 	::SetFocus(::GetDlgItem(GetSafeHwnd(), IDC_ACCEPT_MOUSE_EVENT_TRACKING));
-
-	return FALSE;
 }
 
 BOOL CSequencePropPageDlg::OnCommand(WPARAM wParam, LPARAM lParam)
 {
-	CButton *btn, *btn2;
-
 	switch (wParam) {
 		case IDC_ACCEPT_MOUSE_EVENT_TRACKING | (BN_CLICKED << 16):
-			btn = (CButton *)GetDlgItem(IDC_ACCEPT_MOUSE_EVENT_TRACKING);
-			btn2 = (CButton *)GetDlgItem(IDC_DISABLE_MOUSE_TRACKING_CTRL);
-			if (btn->GetCheck()) {
-				btn2->EnableWindow(TRUE);
-			} else {
-				btn2->EnableWindow(FALSE);
-			}
+			EnableDlgItem(IDC_DISABLE_MOUSE_TRACKING_CTRL, 
+						  GetCheck(IDC_ACCEPT_MOUSE_EVENT_TRACKING) ? TRUE : FALSE);
 			return TRUE;
 	}
-	return CPropertyPage::OnCommand(wParam, lParam);
+	return TTCPropertyPage::OnCommand(wParam, lParam);
 }
 
 void CSequencePropPageDlg::OnOK()
 {
-	CButton *btn;
-	CComboBox *cmb;
-	int sel;
-
 	// (1)IDC_ACCEPT_MOUSE_EVENT_TRACKING
-	btn = (CButton *)GetDlgItem(IDC_ACCEPT_MOUSE_EVENT_TRACKING);
-	ts.MouseEventTracking = btn->GetCheck();
+	ts.MouseEventTracking = GetCheck(IDC_ACCEPT_MOUSE_EVENT_TRACKING);
 
 	// (2)IDC_DISABLE_MOUSE_TRACKING_CTRL
-	btn = (CButton *)GetDlgItem(IDC_DISABLE_MOUSE_TRACKING_CTRL);
-	ts.DisableMouseTrackingByCtrl = btn->GetCheck();
+	ts.DisableMouseTrackingByCtrl = GetCheck(IDC_DISABLE_MOUSE_TRACKING_CTRL);
 
 	// (3)IDC_ACCEPT_TITLE_CHANGING
-	cmb = (CComboBox *)GetDlgItem(IDC_ACCEPT_TITLE_CHANGING);
-	sel = cmb->GetCurSel();
+	int sel = GetCurSel(IDC_ACCEPT_TITLE_CHANGING);
 	if (0 <= sel && sel <= IdTitleChangeRequestMax) {
 		ts.AcceptTitleChangeRequest = sel;
 	}
 
 	// (4)IDC_TITLE_REPORT
-	cmb = (CComboBox *)GetDlgItem(IDC_TITLE_REPORT);
-	switch (cmb->GetCurSel()) {
+	switch (GetCurSel(IDC_TITLE_REPORT)) {
 		case 0:
 			ts.WindowFlag &= ~WF_TITLEREPORT;
 			break;
@@ -535,26 +356,22 @@
 	}
 
 	// (5)IDC_WINDOW_CTRL
-	btn = (CButton *)GetDlgItem(IDC_WINDOW_CTRL);
-	if (((ts.WindowFlag & WF_WINDOWCHANGE) != 0) != btn->GetCheck()) {
+	if (((ts.WindowFlag & WF_WINDOWCHANGE) != 0) != GetCheck(IDC_WINDOW_CTRL)) {
 		ts.WindowFlag ^= WF_WINDOWCHANGE;
 	}
 
 	// (6)IDC_WINDOW_REPORT
-	btn = (CButton *)GetDlgItem(IDC_WINDOW_REPORT);
-	if (((ts.WindowFlag & WF_WINDOWREPORT) != 0) != btn->GetCheck()) {
+	if (((ts.WindowFlag & WF_WINDOWREPORT) != 0) != GetCheck(IDC_WINDOW_REPORT)) {
 		ts.WindowFlag ^= WF_WINDOWREPORT;
 	}
 
 	// (7)IDC_CURSOR_CTRL_SEQ
-	btn = (CButton *)GetDlgItem(IDC_CURSOR_CTRL_SEQ);
-	if (((ts.WindowFlag & WF_CURSORCHANGE) != 0) != btn->GetCheck()) {
+	if (((ts.WindowFlag & WF_CURSORCHANGE) != 0) != GetCheck(IDC_CURSOR_CTRL_SEQ)) {
 		ts.WindowFlag ^= WF_CURSORCHANGE;
 	}
 
 	// (8)IDC_CLIPBOARD_ACCESS
-	cmb = (CComboBox *)GetDlgItem(IDC_CLIPBOARD_ACCESS);
-	switch (cmb->GetCurSel()) {
+	switch (GetCurSel(IDC_CLIPBOARD_ACCESS)) {
 		case 0: // off
 			ts.CtrlFlag &= ~CSF_CBRW;
 			break;
@@ -574,151 +391,86 @@
 	}
 
 	// (9)IDC_CLIPBOARD_ACCESS
-	btn = (CButton *)GetDlgItem(IDC_CLIPBOARD_NOTIFY);
-	ts.NotifyClipboardAccess = btn->GetCheck();
+	ts.NotifyClipboardAccess = GetCheck(IDC_CLIPBOARD_NOTIFY);
 }
 
 
-
 // CCopypastePropPageDlg \x83_\x83C\x83A\x83\x8D\x83O
 
-IMPLEMENT_DYNAMIC(CCopypastePropPageDlg, CPropertyPage)
-
-CCopypastePropPageDlg::CCopypastePropPageDlg()
-	: CPropertyPage(CCopypastePropPageDlg::IDD)
+CCopypastePropPageDlg::CCopypastePropPageDlg(HINSTANCE inst, TTCPropertySheet *sheet)
+	: TTCPropertyPage(inst, CCopypastePropPageDlg::IDD, sheet)
 {
+	get_lang_msg("DLG_TABSHEET_TITLE_COPYPASTE", ts.UIMsg, sizeof(ts.UIMsg),
+	             "Copy and Paste", ts.UILanguageFile);
+	m_psp.pszTitle = _tcsdup(ts.UIMsg);
+	m_psp.dwFlags |= PSP_USETITLE;
 }
 
 CCopypastePropPageDlg::~CCopypastePropPageDlg()
 {
-	if (DlgCopypasteFont != NULL) {
-		DeleteObject(DlgCopypasteFont);
-	}
+	free((void *)m_psp.pszTitle);
 }
 
-BEGIN_MESSAGE_MAP(CCopypastePropPageDlg, CPropertyPage)
-END_MESSAGE_MAP()
-
 // CCopypastePropPageDlg \x83\x81\x83b\x83Z\x81[\x83W \x83n\x83\x93\x83h\x83\x89
 
-BOOL CCopypastePropPageDlg::OnInitDialog()
+void CCopypastePropPageDlg::OnInitDialog()
 {
-	char uimsg[MAX_UIMSG];
-	CButton *btn, *btn2;
-	CEdit *edit;
-	char buf[64];
+	TTCPropertyPage::OnInitDialog();
 
-	CPropertyPage::OnInitDialog();
+	static const DlgTextInfo TextInfos[] = {
+		{ IDC_LINECOPY, "DLG_TAB_COPYPASTE_CONTINUE" },
+		{ IDC_DISABLE_PASTE_RBUTTON, "DLG_TAB_COPYPASTE_MOUSEPASTE" },
+		{ IDC_CONFIRM_PASTE_RBUTTON, "DLG_TAB_COPYPASTE_CONFIRMPASTE" },
+		{ IDC_DISABLE_PASTE_MBUTTON, "DLG_TAB_COPYPASTE_MOUSEPASTEM" },
+		{ IDC_SELECT_LBUTTON, "DLG_TAB_COPYPASTE_SELECTLBUTTON" },
+		{ IDC_TRIMNLCHAR, "DLG_TAB_COPYPASTE_TRIM_TRAILING_NL" },
+		{ IDC_NORMALIZE_LINEBREAK, "DLG_TAB_COPYPASTE_NORMALIZE_LINEBREAK" },
+		{ IDC_CONFIRM_CHANGE_PASTE, "DLG_TAB_COPYPASTE_CONFIRM_CHANGE_PASTE" },
+		{ IDC_CONFIRM_STRING_FILE_LABEL, "DLG_TAB_COPYPASTE_STRINGFILE" },
+		{ IDC_DELIMITER, "DLG_TAB_COPYPASTE_DELIMITER" },
+		{ IDC_PASTEDELAY_LABEL, "DLG_TAB_COPYPASTE_PASTEDELAY" },
+		{ IDC_PASTEDELAY_LABEL2, "DLG_TAB_COPYPASTE_PASTEDELAY2" }
+	};
+	SetDlgTexts(m_hWnd, TextInfos, _countof(TextInfos), ts.UILanguageFile);
 
-	font = (HFONT)SendMessage(WM_GETFONT, 0, 0);
-	GetObject(font, sizeof(LOGFONT), &logfont);
-	if (get_lang_font("DLG_TAHOMA_FONT", GetSafeHwnd(), &logfont, &DlgCopypasteFont, ts.UILanguageFile)) {
-		SendDlgItemMessage(IDC_LINECOPY, WM_SETFONT, (WPARAM)DlgCopypasteFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_DISABLE_PASTE_RBUTTON, WM_SETFONT, (WPARAM)DlgCopypasteFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_CONFIRM_PASTE_RBUTTON, WM_SETFONT, (WPARAM)DlgCopypasteFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_DISABLE_PASTE_MBUTTON, WM_SETFONT, (WPARAM)DlgCopypasteFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_SELECT_LBUTTON, WM_SETFONT, (WPARAM)DlgCopypasteFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_TRIMNLCHAR, WM_SETFONT, (WPARAM)DlgCopypasteFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_NORMALIZE_LINEBREAK, WM_SETFONT, (WPARAM)DlgCopypasteFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_CONFIRM_CHANGE_PASTE, WM_SETFONT, (WPARAM)DlgCopypasteFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_CONFIRM_STRING_FILE_LABEL, WM_SETFONT, (WPARAM)DlgCopypasteFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_CONFIRM_STRING_FILE, WM_SETFONT, (WPARAM)DlgCopypasteFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_CONFIRM_STRING_FILE_PATH, WM_SETFONT, (WPARAM)DlgCopypasteFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_DELIMITER, WM_SETFONT, (WPARAM)DlgCopypasteFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_DELIM_LIST, WM_SETFONT, (WPARAM)DlgCopypasteFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_PASTEDELAY_LABEL, WM_SETFONT, (WPARAM)DlgCopypasteFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_PASTEDELAY_EDIT, WM_SETFONT, (WPARAM)DlgCopypasteFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_PASTEDELAY_LABEL2, WM_SETFONT, (WPARAM)DlgCopypasteFont, MAKELPARAM(TRUE,0));
-	}
-	else {
-		DlgCopypasteFont = NULL;
-	}
-
-	GetDlgItemText(IDC_LINECOPY, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_COPYPASTE_CONTINUE", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_LINECOPY, ts.UIMsg);
-	GetDlgItemText(IDC_DISABLE_PASTE_RBUTTON, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_COPYPASTE_MOUSEPASTE", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_DISABLE_PASTE_RBUTTON, ts.UIMsg);
-	GetDlgItemText(IDC_CONFIRM_PASTE_RBUTTON, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_COPYPASTE_CONFIRMPASTE", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_CONFIRM_PASTE_RBUTTON, ts.UIMsg);
-	GetDlgItemText(IDC_DISABLE_PASTE_MBUTTON, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_COPYPASTE_MOUSEPASTEM", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_DISABLE_PASTE_MBUTTON, ts.UIMsg);
-	GetDlgItemText(IDC_SELECT_LBUTTON, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_COPYPASTE_SELECTLBUTTON", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_SELECT_LBUTTON, ts.UIMsg);
-	GetDlgItemText(IDC_TRIMNLCHAR, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_COPYPASTE_TRIM_TRAILING_NL", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_TRIMNLCHAR, ts.UIMsg);
-	GetDlgItemText(IDC_NORMALIZE_LINEBREAK, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_COPYPASTE_NORMALIZE_LINEBREAK", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_NORMALIZE_LINEBREAK, ts.UIMsg);
-	GetDlgItemText(IDC_CONFIRM_CHANGE_PASTE, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_COPYPASTE_CONFIRM_CHANGE_PASTE", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_CONFIRM_CHANGE_PASTE, ts.UIMsg);
-	GetDlgItemText(IDC_CONFIRM_STRING_FILE_LABEL, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_COPYPASTE_STRINGFILE", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_CONFIRM_STRING_FILE_LABEL, ts.UIMsg);
-	GetDlgItemText(IDC_DELIMITER, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_COPYPASTE_DELIMITER", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_DELIMITER, ts.UIMsg);
-	GetDlgItemText(IDC_PASTEDELAY_LABEL, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_COPYPASTE_PASTEDELAY", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_PASTEDELAY_LABEL, ts.UIMsg);
-	GetDlgItemText(IDC_PASTEDELAY_LABEL2, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_COPYPASTE_PASTEDELAY2", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_PASTEDELAY_LABEL2, ts.UIMsg);
-
 	// (1)Enable continued-line copy
-	btn = (CButton *)GetDlgItem(IDC_LINECOPY);
-	btn->SetCheck(ts.EnableContinuedLineCopy);
+	SetCheck(IDC_LINECOPY, ts.EnableContinuedLineCopy);
 
 	// (2)DisablePasteMouseRButton
-	btn = (CButton *)GetDlgItem(IDC_DISABLE_PASTE_RBUTTON);
-	btn2 = (CButton *)GetDlgItem(IDC_CONFIRM_PASTE_RBUTTON);
 	if (ts.PasteFlag & CPF_DISABLE_RBUTTON) {
-		btn->SetCheck(BST_CHECKED);
-		btn2->EnableWindow(FALSE);
+		SetCheck(IDC_DISABLE_PASTE_RBUTTON, BST_CHECKED);
+		EnableDlgItem(IDC_CONFIRM_PASTE_RBUTTON, FALSE);
 	} else {
-		btn->SetCheck(BST_UNCHECKED);
-		btn2->EnableWindow(TRUE);
+		SetCheck(IDC_DISABLE_PASTE_RBUTTON, BST_UNCHECKED);
+		EnableDlgItem(IDC_CONFIRM_PASTE_RBUTTON, TRUE);
 	}
 
 	// (3)ConfirmPasteMouseRButton
-	btn2->SetCheck((ts.PasteFlag & CPF_CONFIRM_RBUTTON)?BST_CHECKED:BST_UNCHECKED);
+	SetCheck(IDC_CONFIRM_PASTE_RBUTTON, (ts.PasteFlag & CPF_CONFIRM_RBUTTON)?BST_CHECKED:BST_UNCHECKED);
 
 	// (4)DisablePasteMouseMButton
-	btn = (CButton *)GetDlgItem(IDC_DISABLE_PASTE_MBUTTON);
-	btn->SetCheck((ts.PasteFlag & CPF_DISABLE_MBUTTON)?BST_CHECKED:BST_UNCHECKED);
+	SetCheck(IDC_DISABLE_PASTE_MBUTTON, (ts.PasteFlag & CPF_DISABLE_MBUTTON)?BST_CHECKED:BST_UNCHECKED);
 
 	// (5)SelectOnlyByLButton
-	btn = (CButton *)GetDlgItem(IDC_SELECT_LBUTTON);
-	btn->SetCheck(ts.SelectOnlyByLButton);
+	SetCheck(IDC_SELECT_LBUTTON, ts.SelectOnlyByLButton);
 
 	// (6)TrimTrailingNLonPaste
-	btn = (CButton *)GetDlgItem(IDC_TRIMNLCHAR);
-	btn->SetCheck((ts.PasteFlag & CPF_TRIM_TRAILING_NL)?BST_CHECKED:BST_UNCHECKED);
+	SetCheck(IDC_TRIMNLCHAR, (ts.PasteFlag & CPF_TRIM_TRAILING_NL)?BST_CHECKED:BST_UNCHECKED);
 
 	// (7)NormalizeLineBreak
-	btn = (CButton *)GetDlgItem(IDC_NORMALIZE_LINEBREAK);
-	btn->SetCheck((ts.PasteFlag & CPF_NORMALIZE_LINEBREAK)?BST_CHECKED:BST_UNCHECKED);
+	SetCheck(IDC_NORMALIZE_LINEBREAK, (ts.PasteFlag & CPF_NORMALIZE_LINEBREAK)?BST_CHECKED:BST_UNCHECKED);
 
 	// (8)ConfirmChangePaste
-	btn = (CButton *)GetDlgItem(IDC_CONFIRM_CHANGE_PASTE);
-	btn->SetCheck((ts.PasteFlag & CPF_CONFIRM_CHANGEPASTE)?BST_CHECKED:BST_UNCHECKED);
+	SetCheck(IDC_CONFIRM_CHANGE_PASTE, (ts.PasteFlag & CPF_CONFIRM_CHANGEPASTE)?BST_CHECKED:BST_UNCHECKED);
 
 	// \x83t\x83@\x83C\x83\x8B\x83p\x83X
 	SetDlgItemText(IDC_CONFIRM_STRING_FILE, ts.ConfirmChangePasteStringFile);
-	edit = (CEdit *)GetDlgItem(IDC_CONFIRM_STRING_FILE);
-	btn = (CButton *)GetDlgItem(IDC_CONFIRM_STRING_FILE_PATH);
 	if (ts.PasteFlag & CPF_CONFIRM_CHANGEPASTE) {
-		edit->EnableWindow(TRUE);
-		btn->EnableWindow(TRUE);
+		EnableDlgItem(IDC_CONFIRM_STRING_FILE, TRUE);
+		EnableDlgItem(IDC_CONFIRM_STRING_FILE_PATH, TRUE);
 	} else {
-		edit->EnableWindow(FALSE);
-		btn->EnableWindow(FALSE);
+		EnableDlgItem(IDC_CONFIRM_STRING_FILE, FALSE);
+		EnableDlgItem(IDC_CONFIRM_STRING_FILE_PATH, FALSE);
 	}
 
 	// (9)delimiter characters
@@ -725,42 +477,31 @@
 	SetDlgItemText(IDC_DELIM_LIST, ts.DelimList);
 
 	// (10)PasteDelayPerLine
+	char buf[64];
 	_snprintf_s(buf, sizeof(buf), "%d", ts.PasteDelayPerLine);
 	SetDlgItemText(IDC_PASTEDELAY_EDIT, buf);
 
 	// \x83_\x83C\x83A\x83\x8D\x83O\x82Ƀt\x83H\x81[\x83J\x83X\x82𓖂Ă\xE9
 	::SetFocus(::GetDlgItem(GetSafeHwnd(), IDC_LINECOPY));
-
-	return FALSE;
 }
 
 BOOL CCopypastePropPageDlg::OnCommand(WPARAM wParam, LPARAM lParam)
 {
-	CButton *btn, *btn2;
-	CEdit *edit;
 	char uimsg[MAX_UIMSG];
 
 	switch (wParam) {
 		case IDC_DISABLE_PASTE_RBUTTON | (BN_CLICKED << 16):
-			btn = (CButton *)GetDlgItem(IDC_DISABLE_PASTE_RBUTTON);
-			btn2 = (CButton *)GetDlgItem(IDC_CONFIRM_PASTE_RBUTTON);
-			if (btn->GetCheck()) {
-				btn2->EnableWindow(FALSE);
-			} else {
-				btn2->EnableWindow(TRUE);
-			}
+			EnableDlgItem(IDC_CONFIRM_PASTE_RBUTTON,
+						  GetCheck(IDC_DISABLE_PASTE_RBUTTON) ? FALSE : TRUE);
 			return TRUE;
 
 		case IDC_CONFIRM_CHANGE_PASTE | (BN_CLICKED << 16):
-			btn2 = (CButton *)GetDlgItem(IDC_CONFIRM_CHANGE_PASTE);
-			btn = (CButton *)GetDlgItem(IDC_CONFIRM_STRING_FILE_PATH);
-			edit = (CEdit *)GetDlgItem(IDC_CONFIRM_STRING_FILE);
-			if (btn2->GetCheck()) {
-				edit->EnableWindow(TRUE);
-				btn->EnableWindow(TRUE);
+			if (GetCheck(IDC_CONFIRM_CHANGE_PASTE)) {
+				EnableDlgItem(IDC_CONFIRM_STRING_FILE, TRUE);
+				EnableDlgItem(IDC_CONFIRM_STRING_FILE_PATH, TRUE);
 			} else {
-				edit->EnableWindow(FALSE);
-				btn->EnableWindow(FALSE);
+				EnableDlgItem(IDC_CONFIRM_STRING_FILE, FALSE);
+				EnableDlgItem(IDC_CONFIRM_STRING_FILE_PATH, FALSE);
 			}
 			return TRUE;
 
@@ -768,7 +509,7 @@
 			{
 				OPENFILENAME ofn;
 
-				ZeroMemory(&ofn, sizeof(ofn));
+				memset(&ofn, 0, sizeof(ofn));
 				ofn.lStructSize = get_OPENFILENAME_SIZE();
 				ofn.hwndOwner = GetSafeHwnd();
 				get_lang_msg("FILEDLG_SELECT_CONFIRM_STRING_APP_FILTER", ts.UIMsg, sizeof(ts.UIMsg),
@@ -787,22 +528,19 @@
 			return TRUE;
 	}
 
-	return CPropertyPage::OnCommand(wParam, lParam);
+	return TTCPropertyPage::OnCommand(wParam, lParam);
 }
 
 void CCopypastePropPageDlg::OnOK()
 {
-	CButton *btn;
 	char buf[64];
 	int val;
 
 	// (1)
-	btn = (CButton *)GetDlgItem(IDC_LINECOPY);
-	ts.EnableContinuedLineCopy = btn->GetCheck();
+	ts.EnableContinuedLineCopy = GetCheck(IDC_LINECOPY);
 
 	// (2)
-	btn = (CButton *)GetDlgItem(IDC_DISABLE_PASTE_RBUTTON);
-	if (btn->GetCheck()) {
+	if (GetCheck(IDC_DISABLE_PASTE_RBUTTON)) {
 		ts.PasteFlag |= CPF_DISABLE_RBUTTON;
 	}
 	else {
@@ -810,8 +548,7 @@
 	}
 
 	// (3)
-	btn = (CButton *)GetDlgItem(IDC_CONFIRM_PASTE_RBUTTON);
-	if (btn->GetCheck()) {
+	if (GetCheck(IDC_CONFIRM_PASTE_RBUTTON)) {
 		ts.PasteFlag |= CPF_CONFIRM_RBUTTON;
 	}
 	else {
@@ -819,8 +556,7 @@
 	}
 
 	// (4)
-	btn = (CButton *)GetDlgItem(IDC_DISABLE_PASTE_MBUTTON);
-	if (btn->GetCheck()) {
+	if (GetCheck(IDC_DISABLE_PASTE_MBUTTON)) {
 		ts.PasteFlag |= CPF_DISABLE_MBUTTON;
 	}
 	else {
@@ -828,12 +564,10 @@
 	}
 
 	// (5)
-	btn = (CButton *)GetDlgItem(IDC_SELECT_LBUTTON);
-	ts.SelectOnlyByLButton = btn->GetCheck();
+	ts.SelectOnlyByLButton = GetCheck(IDC_SELECT_LBUTTON);
 
 	// (6)
-	btn = (CButton *)GetDlgItem(IDC_TRIMNLCHAR);
-	if (btn->GetCheck()) {
+	if (GetCheck(IDC_TRIMNLCHAR)) {
 		ts.PasteFlag |= CPF_TRIM_TRAILING_NL;
 	}
 	else {
@@ -841,8 +575,7 @@
 	}
 
 	// (7)
-	btn = (CButton *)GetDlgItem(IDC_NORMALIZE_LINEBREAK);
-	if (btn->GetCheck()) {
+	if (GetCheck(IDC_NORMALIZE_LINEBREAK)) {
 		ts.PasteFlag |= CPF_NORMALIZE_LINEBREAK;
 	}
 	else {
@@ -850,8 +583,7 @@
 	}
 
 	// (8)IDC_CONFIRM_CHANGE_PASTE
-	btn = (CButton *)GetDlgItem(IDC_CONFIRM_CHANGE_PASTE);
-	if (btn->GetCheck()) {
+	if (GetCheck(IDC_CONFIRM_CHANGE_PASTE)) {
 		ts.PasteFlag |= CPF_CONFIRM_CHANGEPASTE;
 	}
 	else {
@@ -869,128 +601,51 @@
 }
 
 
-
 // CVisualPropPageDlg \x83_\x83C\x83A\x83\x8D\x83O
 
-IMPLEMENT_DYNAMIC(CVisualPropPageDlg, CPropertyPage)
-
-CVisualPropPageDlg::CVisualPropPageDlg()
-	: CPropertyPage(CVisualPropPageDlg::IDD)
+CVisualPropPageDlg::CVisualPropPageDlg(HINSTANCE inst, TTCPropertySheet *sheet)
+	: TTCPropertyPage(inst, CVisualPropPageDlg::IDD, sheet)
 {
-
+	get_lang_msg("DLG_TABSHEET_TITLE_VISUAL", ts.UIMsg, sizeof(ts.UIMsg),
+	             "Visual", ts.UILanguageFile);
+	m_psp.pszTitle = _tcsdup(ts.UIMsg);
+	m_psp.dwFlags |= PSP_USETITLE;
 }
 
 CVisualPropPageDlg::~CVisualPropPageDlg()
 {
-	if (DlgVisualFont != NULL) {
-		DeleteObject(DlgVisualFont);
-	}
+	free((void *)m_psp.pszTitle);
 }
 
-BEGIN_MESSAGE_MAP(CVisualPropPageDlg, CPropertyPage)
-END_MESSAGE_MAP()
-
 // CVisualPropPageDlg \x83\x81\x83b\x83Z\x81[\x83W \x83n\x83\x93\x83h\x83\x89
 
-BOOL CVisualPropPageDlg::OnInitDialog()
+void CVisualPropPageDlg::OnInitDialog()
 {
 	char buf[MAXPATHLEN];
-	char uimsg[MAX_UIMSG];
-	CListBox *listbox;
-	CButton *btn;
-	CComboBox *cmb;
-	int i;
 
-	CPropertyPage::OnInitDialog();
+	TTCPropertyPage::OnInitDialog();
 
-	font = (HFONT)SendMessage(WM_GETFONT, 0, 0);
-	GetObject(font, sizeof(LOGFONT), &logfont);
-	if (get_lang_font("DLG_TAHOMA_FONT", GetSafeHwnd(), &logfont, &DlgVisualFont, ts.UILanguageFile)) {
-		SendDlgItemMessage(IDC_ALPHABLEND, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_ALPHA_BLEND, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_ETERM_LOOKFEEL, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_MOUSE, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_MOUSE_CURSOR, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_FONT_QUALITY_LABEL, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_FONT_QUALITY, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_ANSICOLOR, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_ANSI_COLOR, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_RED, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_COLOR_RED, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_GREEN, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_COLOR_GREEN, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_BLUE, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_COLOR_BLUE, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_SAMPLE_COLOR, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_ENABLE_ATTR_COLOR_BOLD, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_ENABLE_ATTR_COLOR_BLINK, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_ENABLE_ATTR_COLOR_REVERSE, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_ENABLE_URL_COLOR, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_ENABLE_ANSI_COLOR, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_URL_UNDERLINE, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_BGIMG_CHECK, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_BGIMG_EDIT, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_BGIMG_BUTTON, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_RESTART, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_BGIMG_BRIGHTNESS, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE, 0));
-		SendDlgItemMessage(IDC_EDIT_BGIMG_BRIGHTNESS, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE, 0));
-	}
-	else {
-		DlgVisualFont = NULL;
-	}
+	static const DlgTextInfo TextInfos[] = {
+		{ IDC_ALPHABLEND, "DLG_TAB_VISUAL_ALPHA" },
+		{ IDC_ETERM_LOOKFEEL, "DLG_TAB_VISUAL_ETERM" },
+		{ IDC_BGIMG_CHECK, "DLG_TAB_VISUAL_BGIMG" },
+		{ IDC_BGIMG_BRIGHTNESS, "DLG_TAB_VISUAL_BGIMG_BRIGHTNESS" },
+		{ IDC_MOUSE, "DLG_TAB_VISUAL_MOUSE" },
+		{ IDC_FONT_QUALITY_LABEL, "DLG_TAB_VISUAL_FONT_QUALITY" },
+		{ IDC_ANSICOLOR, "DLG_TAB_VISUAL_ANSICOLOR" },
+		{ IDC_RED, "DLG_TAB_VISUAL_RED" },
+		{ IDC_GREEN, "DLG_TAB_VISUAL_GREEN" },
+		{ IDC_BLUE, "DLG_TAB_VISUAL_BLUE" },
+		{ IDC_ENABLE_ATTR_COLOR_BOLD, "DLG_TAB_VISUAL_BOLD" },
+		{ IDC_ENABLE_ATTR_COLOR_BLINK, "DLG_TAB_VISUAL_BLINK" },
+		{ IDC_ENABLE_ATTR_COLOR_REVERSE, "DLG_TAB_VISUAL_REVERSE" },
+		{ IDC_ENABLE_URL_COLOR, "DLG_TAB_VISUAL_URL" },
+		{ IDC_ENABLE_ANSI_COLOR, "DLG_TAB_VISUAL_ANSI" },
+		{ IDC_URL_UNDERLINE, "DLG_TAB_VISUAL_URLUL" },
+		{ IDC_RESTART, "DLG_TAB_VISUAL_RESTART" },
+	};
+	SetDlgTexts(m_hWnd, TextInfos, _countof(TextInfos), ts.UILanguageFile);
 
-	GetDlgItemText(IDC_ALPHABLEND, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_VISUAL_ALPHA", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_ALPHABLEND, ts.UIMsg);
-	GetDlgItemText(IDC_ETERM_LOOKFEEL, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_VISUAL_ETERM", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_ETERM_LOOKFEEL, ts.UIMsg);
-	GetDlgItemText(IDC_BGIMG_CHECK, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_VISUAL_BGIMG", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_BGIMG_CHECK, ts.UIMsg);
-	GetDlgItemText(IDC_BGIMG_BRIGHTNESS, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_VISUAL_BGIMG_BRIGHTNESS", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_BGIMG_BRIGHTNESS, ts.UIMsg);
-	GetDlgItemText(IDC_MOUSE, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_VISUAL_MOUSE", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_MOUSE, ts.UIMsg);
-	GetDlgItemText(IDC_FONT_QUALITY_LABEL, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_VISUAL_FONT_QUALITY", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_FONT_QUALITY_LABEL, ts.UIMsg);
-	GetDlgItemText(IDC_ANSICOLOR, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_VISUAL_ANSICOLOR", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_ANSICOLOR, ts.UIMsg);
-	GetDlgItemText(IDC_RED, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_VISUAL_RED", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_RED, ts.UIMsg);
-	GetDlgItemText(IDC_GREEN, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_VISUAL_GREEN", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_GREEN, ts.UIMsg);
-	GetDlgItemText(IDC_BLUE, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_VISUAL_BLUE", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_BLUE, ts.UIMsg);
-	GetDlgItemText(IDC_ENABLE_ATTR_COLOR_BOLD, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_VISUAL_BOLD", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_ENABLE_ATTR_COLOR_BOLD, ts.UIMsg);
-	GetDlgItemText(IDC_ENABLE_ATTR_COLOR_BLINK, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_VISUAL_BLINK", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_ENABLE_ATTR_COLOR_BLINK, ts.UIMsg);
-	GetDlgItemText(IDC_ENABLE_ATTR_COLOR_REVERSE, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_VISUAL_REVERSE", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_ENABLE_ATTR_COLOR_REVERSE, ts.UIMsg);
-	GetDlgItemText(IDC_ENABLE_URL_COLOR, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_VISUAL_URL", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_ENABLE_URL_COLOR, ts.UIMsg);
-	GetDlgItemText(IDC_ENABLE_ANSI_COLOR, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_VISUAL_ANSI", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_ENABLE_ANSI_COLOR, ts.UIMsg);
-	GetDlgItemText(IDC_URL_UNDERLINE, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_VISUAL_URLUL", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_URL_UNDERLINE, ts.UIMsg);
-	GetDlgItemText(IDC_RESTART, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_VISUAL_RESTART", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_RESTART, ts.UIMsg);
-
 	get_lang_msg("DLG_TAB_VISUAL_FONT_QUALITY_DEFAULT", ts.UIMsg, sizeof(ts.UIMsg), "Default", ts.UILanguageFile);
 	SendDlgItemMessage(IDC_FONT_QUALITY, CB_ADDSTRING, 0, (LPARAM)ts.UIMsg);
 	get_lang_msg("DLG_TAB_VISUAL_FONT_QUALITY_NONANTIALIASED", ts.UIMsg, sizeof(ts.UIMsg), "Non-Antialiased", ts.UILanguageFile);
@@ -1005,8 +660,7 @@
 	SetDlgItemText(IDC_ALPHA_BLEND, buf);
 
 	// (2)[BG] BGEnable
-	btn = (CButton *)GetDlgItem(IDC_ETERM_LOOKFEEL);
-	btn->SetCheck(ts.EtermLookfeel.BGEnable);
+	SetCheck(IDC_ETERM_LOOKFEEL, ts.EtermLookfeel.BGEnable);
 
 	// Eterm look-feel\x82̔w\x8Ci\x89摜\x8Ew\x92\xE8\x81B
 	SetDlgItemText(IDC_BGIMG_EDIT, ts.BGImageFilePath);
@@ -1015,134 +669,119 @@
 	SetDlgItemText(IDC_EDIT_BGIMG_BRIGHTNESS, buf);
 
 	if (ts.EtermLookfeel.BGEnable) {
-		GetDlgItem(IDC_BGIMG_CHECK)->EnableWindow(TRUE);
+		EnableDlgItem(IDC_BGIMG_CHECK, TRUE);
 
-		btn = (CButton *)GetDlgItem(IDC_BGIMG_CHECK);
 		if (strcmp(ts.EtermLookfeel.BGThemeFile, BG_THEME_IMAGEFILE) == 0) {
-			btn->SetCheck(BST_CHECKED);
-			GetDlgItem(IDC_BGIMG_EDIT)->EnableWindow(TRUE);
-			GetDlgItem(IDC_BGIMG_BUTTON)->EnableWindow(TRUE);
+			SetCheck(IDC_BGIMG_CHECK, BST_CHECKED);
+			EnableDlgItem(IDC_BGIMG_EDIT, TRUE);
+			EnableDlgItem(IDC_BGIMG_BUTTON, TRUE);
 
-			GetDlgItem(IDC_BGIMG_BRIGHTNESS)->EnableWindow(TRUE);
-			GetDlgItem(IDC_EDIT_BGIMG_BRIGHTNESS)->EnableWindow(TRUE);
+			EnableDlgItem(IDC_BGIMG_BRIGHTNESS, TRUE);
+			EnableDlgItem(IDC_EDIT_BGIMG_BRIGHTNESS, TRUE);
 		} else {
-			btn->SetCheck(BST_UNCHECKED);
-			GetDlgItem(IDC_BGIMG_EDIT)->EnableWindow(FALSE);
-			GetDlgItem(IDC_BGIMG_BUTTON)->EnableWindow(FALSE);
+			SetCheck(IDC_BGIMG_CHECK, BST_UNCHECKED);
+			EnableDlgItem(IDC_BGIMG_EDIT, FALSE);
+			EnableDlgItem(IDC_BGIMG_BUTTON, FALSE);
 
-			GetDlgItem(IDC_BGIMG_BRIGHTNESS)->EnableWindow(FALSE);
-			GetDlgItem(IDC_EDIT_BGIMG_BRIGHTNESS)->EnableWindow(FALSE);
+			EnableDlgItem(IDC_BGIMG_BRIGHTNESS, FALSE);
+			EnableDlgItem(IDC_EDIT_BGIMG_BRIGHTNESS, FALSE);
 		}
 	} else {
-		GetDlgItem(IDC_BGIMG_CHECK)->EnableWindow(FALSE);
-		GetDlgItem(IDC_BGIMG_EDIT)->EnableWindow(FALSE);
-		GetDlgItem(IDC_BGIMG_BUTTON)->EnableWindow(FALSE);
+		EnableDlgItem(IDC_BGIMG_CHECK, FALSE);
+		EnableDlgItem(IDC_BGIMG_EDIT, FALSE);
+		EnableDlgItem(IDC_BGIMG_BUTTON, FALSE);
 
-		GetDlgItem(IDC_BGIMG_BRIGHTNESS)->EnableWindow(FALSE);
-		GetDlgItem(IDC_EDIT_BGIMG_BRIGHTNESS)->EnableWindow(FALSE);
+		EnableDlgItem(IDC_BGIMG_BRIGHTNESS, FALSE);
+		EnableDlgItem(IDC_EDIT_BGIMG_BRIGHTNESS, FALSE);
 	}
 
 	// (3)Mouse cursor type
-	listbox = (CListBox *)GetDlgItem(IDC_MOUSE_CURSOR);
-	for (i = 0 ; MouseCursor[i].name ; i++) {
-		listbox->InsertString(i, MouseCursor[i].name);
+	int sel = 0;
+	for (int i = 0 ; MouseCursor[i].name ; i++) {
+		const TCHAR *name = MouseCursor[i].name;
+		SendDlgItemMessage(IDC_MOUSE_CURSOR, LB_INSERTSTRING, i, (LPARAM)name);
+		if (_tcscmp(name, ts.MouseCursorName) == 0) {
+			sel = i;
+		}
 	}
-	listbox->SelectString(0, ts.MouseCursorName);
+	SendDlgItemMessage(IDC_MOUSE_CURSOR, LB_SETCURSEL, sel, 0);
 
 	// (4)Font quality
-	cmb = (CComboBox *)GetDlgItem(IDC_FONT_QUALITY);
 	switch (ts.FontQuality) {
 		case DEFAULT_QUALITY:
-			cmb->SetCurSel(0);
+			SetCurSel(IDC_FONT_QUALITY, 0);
 			break;
 		case NONANTIALIASED_QUALITY:
-			cmb->SetCurSel(1);
+			SetCurSel(IDC_FONT_QUALITY, 1);
 			break;
 		case ANTIALIASED_QUALITY:
-			cmb->SetCurSel(2);
+			SetCurSel(IDC_FONT_QUALITY, 2);
 			break;
 		default: // CLEARTYPE_QUALITY
-			cmb->SetCurSel(3);
+			SetCurSel(IDC_FONT_QUALITY, 3);
 			break;
 	}
 
 	// (5)ANSI color
-	listbox = (CListBox *)GetDlgItem(IDC_ANSI_COLOR);
-	for (i = 0 ; i < 16 ; i++) {
+	for (int i = 0 ; i < 16 ; i++) {
 		_snprintf_s(buf, sizeof(buf), _TRUNCATE, "%d", i);
-		listbox->InsertString(i, buf);
+		SendDlgItemMessage(IDC_ANSI_COLOR, LB_INSERTSTRING, i, (LPARAM)buf);
 	}
 	SetupRGBbox(GetSafeHwnd(), 0);
-#if 0
-	SendMessage(WM_CTLCOLORSTATIC,
-	            (WPARAM)label_hdc,
-	            (LPARAM)GetDlgItem(IDC_SAMPLE_COLOR));
-#endif
+	SendDlgItemMessage(IDC_ANSI_COLOR, LB_SETCURSEL, 0, 0);
+	InvalidateRect(GetDlgItem(m_hWnd, IDC_SAMPLE_COLOR), NULL, TRUE);
 
 	// (6)Bold Attr Color
-	btn = (CButton *)GetDlgItem(IDC_ENABLE_ATTR_COLOR_BOLD);
-	btn->SetCheck((ts.ColorFlag&CF_BOLDCOLOR) != 0);
+	SetCheck(IDC_ENABLE_ATTR_COLOR_BOLD, (ts.ColorFlag&CF_BOLDCOLOR) != 0);
 
 	// (7)Blink Attr Color
-	btn = (CButton *)GetDlgItem(IDC_ENABLE_ATTR_COLOR_BLINK);
-	btn->SetCheck((ts.ColorFlag&CF_BLINKCOLOR) != 0);
+	SetCheck(IDC_ENABLE_ATTR_COLOR_BLINK, (ts.ColorFlag&CF_BLINKCOLOR) != 0);
 
 	// (8)Reverse Attr Color
-	btn = (CButton *)GetDlgItem(IDC_ENABLE_ATTR_COLOR_REVERSE);
-	btn->SetCheck((ts.ColorFlag&CF_REVERSECOLOR) != 0);
+	SetCheck(IDC_ENABLE_ATTR_COLOR_REVERSE, (ts.ColorFlag&CF_REVERSECOLOR) != 0);
 
 	// (9)URL Color
-	btn = (CButton *)GetDlgItem(IDC_ENABLE_URL_COLOR);
-	btn->SetCheck((ts.ColorFlag&CF_URLCOLOR) != 0);
+	SetCheck(IDC_ENABLE_URL_COLOR, (ts.ColorFlag&CF_URLCOLOR) != 0);
 
 	// (10)Color
-	btn = (CButton *)GetDlgItem(IDC_ENABLE_ANSI_COLOR);
-	btn->SetCheck((ts.ColorFlag&CF_ANSICOLOR) != 0);
+	SetCheck(IDC_ENABLE_ANSI_COLOR, (ts.ColorFlag&CF_ANSICOLOR) != 0);
 
 	// (11)URL Underline
-	btn = (CButton *)GetDlgItem(IDC_URL_UNDERLINE);
-	btn->SetCheck((ts.FontFlag&FF_URLUNDERLINE) != 0);
+	SetCheck(IDC_URL_UNDERLINE, (ts.FontFlag&FF_URLUNDERLINE) != 0);
 
 	// \x83_\x83C\x83A\x83\x8D\x83O\x82Ƀt\x83H\x81[\x83J\x83X\x82𓖂Ă\xE9
 	::SetFocus(::GetDlgItem(GetSafeHwnd(), IDC_ALPHA_BLEND));
-
-	return FALSE;
 }
 
 BOOL CVisualPropPageDlg::OnCommand(WPARAM wParam, LPARAM lParam)
 {
-	CListBox *listbox;
 	int sel;
-	char buf[MAXPATHLEN];
-	CButton *btn;
 
 	switch (wParam) {
-		case IDC_ETERM_LOOKFEEL:
+	case IDC_ETERM_LOOKFEEL:
 			// \x83`\x83F\x83b\x83N\x82\xB3\x82ꂽ\x82\xE7 Enable/Disable \x82\xF0\x83g\x83O\x83\x8B\x82\xB7\x82\xE9\x81B
-			btn = (CButton *)GetDlgItem(IDC_ETERM_LOOKFEEL);
-			if (btn->GetCheck()) {
-				GetDlgItem(IDC_BGIMG_CHECK)->EnableWindow(TRUE);
-				btn = (CButton *)GetDlgItem(IDC_BGIMG_CHECK);
-				if (btn->GetCheck()) {
-					GetDlgItem(IDC_BGIMG_EDIT)->EnableWindow(TRUE);
-					GetDlgItem(IDC_BGIMG_BUTTON)->EnableWindow(TRUE);
+			if (GetCheck(IDC_ETERM_LOOKFEEL)) {
+				EnableDlgItem(IDC_BGIMG_CHECK, TRUE);
+				if (GetCheck(IDC_BGIMG_CHECK)) {
+					EnableDlgItem(IDC_BGIMG_EDIT, TRUE);
+					EnableDlgItem(IDC_BGIMG_BUTTON, TRUE);
 
-					GetDlgItem(IDC_BGIMG_BRIGHTNESS)->EnableWindow(TRUE);
-					GetDlgItem(IDC_EDIT_BGIMG_BRIGHTNESS)->EnableWindow(TRUE);
+					EnableDlgItem(IDC_BGIMG_BRIGHTNESS, TRUE);
+					EnableDlgItem(IDC_EDIT_BGIMG_BRIGHTNESS, TRUE);
 				} else {
-					GetDlgItem(IDC_BGIMG_EDIT)->EnableWindow(FALSE);
-					GetDlgItem(IDC_BGIMG_BUTTON)->EnableWindow(FALSE);
+					EnableDlgItem(IDC_BGIMG_EDIT, FALSE);
+					EnableDlgItem(IDC_BGIMG_BUTTON, FALSE);
 
-					GetDlgItem(IDC_BGIMG_BRIGHTNESS)->EnableWindow(FALSE);
-					GetDlgItem(IDC_EDIT_BGIMG_BRIGHTNESS)->EnableWindow(FALSE);
+					EnableDlgItem(IDC_BGIMG_BRIGHTNESS, FALSE);
+					EnableDlgItem(IDC_EDIT_BGIMG_BRIGHTNESS, FALSE);
 				}
 			} else {
-				GetDlgItem(IDC_BGIMG_CHECK)->EnableWindow(FALSE);
-				GetDlgItem(IDC_BGIMG_EDIT)->EnableWindow(FALSE);
-				GetDlgItem(IDC_BGIMG_BUTTON)->EnableWindow(FALSE);
+				EnableDlgItem(IDC_BGIMG_CHECK, FALSE);
+				EnableDlgItem(IDC_BGIMG_EDIT, FALSE);
+				EnableDlgItem(IDC_BGIMG_BUTTON, FALSE);
 
-				GetDlgItem(IDC_BGIMG_BRIGHTNESS)->EnableWindow(FALSE);
-				GetDlgItem(IDC_EDIT_BGIMG_BRIGHTNESS)->EnableWindow(FALSE);
+				EnableDlgItem(IDC_BGIMG_BRIGHTNESS, FALSE);
+				EnableDlgItem(IDC_EDIT_BGIMG_BRIGHTNESS, FALSE);
 
 				// \x96\xB3\x8C\x{27B0B3}\x82ꂽ\x82\xE7\x81ABGThemeFile \x82\xF0\x8C\xB3\x82ɖ߂\xB7\x81B
 				strncpy_s(ts.EtermLookfeel.BGThemeFile, BG_THEME_IMAGEFILE_DEFAULT, sizeof(ts.EtermLookfeel.BGThemeFile));
@@ -1153,21 +792,20 @@
 			return TRUE;
 
 		case IDC_BGIMG_CHECK:
-			btn = (CButton *)GetDlgItem(IDC_BGIMG_CHECK);
-			if (btn->GetCheck()) {
-				GetDlgItem(IDC_BGIMG_EDIT)->EnableWindow(TRUE);
-				GetDlgItem(IDC_BGIMG_BUTTON)->EnableWindow(TRUE);
+			if (GetCheck(IDC_BGIMG_CHECK)) {
+				EnableDlgItem(IDC_BGIMG_EDIT, TRUE);
+				EnableDlgItem(IDC_BGIMG_BUTTON, TRUE);
 
-				GetDlgItem(IDC_BGIMG_BRIGHTNESS)->EnableWindow(TRUE);
-				GetDlgItem(IDC_EDIT_BGIMG_BRIGHTNESS)->EnableWindow(TRUE);
+				EnableDlgItem(IDC_BGIMG_BRIGHTNESS, TRUE);
+				EnableDlgItem(IDC_EDIT_BGIMG_BRIGHTNESS, TRUE);
 
 				strncpy_s(ts.EtermLookfeel.BGThemeFile, BG_THEME_IMAGEFILE, sizeof(ts.EtermLookfeel.BGThemeFile));
 			} else {
-				GetDlgItem(IDC_BGIMG_EDIT)->EnableWindow(FALSE);
-				GetDlgItem(IDC_BGIMG_BUTTON)->EnableWindow(FALSE);
+				EnableDlgItem(IDC_BGIMG_EDIT, FALSE);
+				EnableDlgItem(IDC_BGIMG_BUTTON, FALSE);
 
-				GetDlgItem(IDC_BGIMG_BRIGHTNESS)->EnableWindow(FALSE);
-				GetDlgItem(IDC_EDIT_BGIMG_BRIGHTNESS)->EnableWindow(FALSE);
+				EnableDlgItem(IDC_BGIMG_BRIGHTNESS, FALSE);
+				EnableDlgItem(IDC_EDIT_BGIMG_BRIGHTNESS, FALSE);
 
 				// \x96\xB3\x8C\x{27B0B3}\x82ꂽ\x82\xE7\x81ABGThemeFile \x82\xF0\x8C\xB3\x82ɖ߂\xB7\x81B
 				strncpy_s(ts.EtermLookfeel.BGThemeFile, BG_THEME_IMAGEFILE_DEFAULT, sizeof(ts.EtermLookfeel.BGThemeFile));
@@ -1180,25 +818,29 @@
 		case IDC_BGIMG_BUTTON | (BN_CLICKED << 16):
 			// \x94w\x8Ci\x89摜\x82\xF0\x83_\x83C\x83A\x83\x8D\x83O\x82Ŏw\x92肷\x82\xE9\x81B
 			{
-				CString         filter("Image Files(*.jpg;*.jpeg;*.bmp)|*.jpg;*.jpeg;*.bmp|All Files(*.*)|*.*||");
-				CFileDialog     selDlg(TRUE, NULL, NULL, OFN_HIDEREADONLY, filter);
-				if (selDlg.DoModal() == IDOK) {
-					// \x94w\x8Ci\x89摜\x8Ew\x92肪\x88Ӑ}\x93I\x82ɍs\x82\xED\x82ꂽ\x82\xE7\x81ABGThemeFile \x82\xF0\x8CŒ艻\x82\xB7\x82\xE9\x81B
-					SetDlgItemText(IDC_BGIMG_EDIT, selDlg.GetPathName());
+				OPENFILENAME ofn;
+				char szFile[MAX_PATH];
+
+				memset(&ofn, 0, sizeof(ofn));
+				memset(szFile, 0, sizeof(szFile));
+				ofn.lStructSize = get_OPENFILENAME_SIZE();
+				ofn.hwndOwner = m_pSheet->m_hWnd;
+				ofn.lpstrFilter = "Image Files(*.jpg;*.jpeg;*.bmp)\0*.jpg;*.jpeg;*.bmp\0All Files(*.*)\0*.*\0";
+				ofn.lpstrFile = szFile;
+				ofn.nMaxFile = _countof(szFile);
+				ofn.lpstrTitle = "select image file";
+				ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
+				if (GetOpenFileName(&ofn) != 0) {
+					SetDlgItemText(IDC_BGIMG_EDIT, szFile);
 				}
 			}
 			return TRUE;
 
 		case IDC_ANSI_COLOR | (LBN_SELCHANGE << 16):
-			listbox = (CListBox *)GetDlgItem(IDC_ANSI_COLOR);
-			sel = listbox->GetCurSel();
+			sel = SendDlgItemMessage(IDC_ANSI_COLOR, LB_GETCURSEL, 0, 0);
 			if (sel != -1) {
 				SetupRGBbox(GetSafeHwnd(), sel);
-#if 0
-				SendMessage(WM_CTLCOLORSTATIC,
-				            (WPARAM)label_hdc,
-				            (LPARAM)GetDlgItem(IDC_SAMPLE_COLOR));
-#endif
+				InvalidateRect(GetDlgItem(m_hWnd, IDC_SAMPLE_COLOR), NULL, TRUE);
 			}
 			return TRUE;
 
@@ -1207,9 +849,9 @@
 		case IDC_COLOR_BLUE | (EN_KILLFOCUS << 16):
 			{
 				BYTE r, g, b;
+				char buf[8];
 
-				listbox = (CListBox *)GetDlgItem(IDC_ANSI_COLOR);
-				sel = listbox->GetCurSel();
+				sel = GetCurSel(IDC_ANSI_COLOR);
 				if (sel < 0 && sel > sizeof(ts.ANSIColor)-1) {
 					return TRUE;
 				}
@@ -1227,62 +869,41 @@
 
 				// 255\x82𒴂\xA6\x82\xBDRGB\x92l\x82͕␳\x82\xB3\x82\xEA\x82\xE9\x82̂ŁA\x82\xBB\x82\xEA\x82\xF0Edit\x82ɕ\\x8E\xA6\x82\xB7\x82\xE9 (2007.2.18 maya)
 				SetupRGBbox(GetSafeHwnd(), sel);
-#if 0
-				SendMessage(WM_CTLCOLORSTATIC,
-				            (WPARAM)label_hdc,
-				            (LPARAM)GetDlgItem(IDC_SAMPLE_COLOR));
-#endif
+
+				InvalidateRect(GetDlgItem(m_hWnd, IDC_SAMPLE_COLOR), NULL, TRUE);
 			}
 
 			return TRUE;
-#if 0
-		case WM_CTLCOLORSTATIC:
-			{
-				HDC hDC = (HDC)wp;
-				HWND hWnd = (HWND)lp;
+	}
 
-				//if (label_hdc == NULL) {
-					hDC = GetWindowDC(GetDlgItem(hDlgWnd, IDC_SAMPLE_COLOR));
-				//	label_hdc = hDC;
-				//}
+	return TTCPropertyPage::OnCommand(wParam, lParam);
+}
 
-				if ( hWnd == GetDlgItem(hDlgWnd, IDC_SAMPLE_COLOR) ) {
-					BYTE r, g, b;
+HBRUSH CVisualPropPageDlg::OnCtlColor(HDC hDC, HWND hWnd)
+{
+	if ( hWnd == GetDlgItem(m_hWnd, IDC_SAMPLE_COLOR) ) {
+		BYTE r, g, b;
+		char buf[8];
 
-					hWnd = GetDlgItem(hDlgWnd, IDC_COLOR_RED);
-					SendMessage(hWnd, WM_GETTEXT , sizeof(buf), (LPARAM)buf);
-					r = atoi(buf);
+		GetDlgItemText(IDC_COLOR_RED, buf, sizeof(buf));
+		r = atoi(buf);
 
-					hWnd = GetDlgItem(hDlgWnd, IDC_COLOR_GREEN);
-					SendMessage(hWnd, WM_GETTEXT , sizeof(buf), (LPARAM)buf);
-					g = atoi(buf);
+		GetDlgItemText(IDC_COLOR_GREEN, buf, sizeof(buf));
+		g = atoi(buf);
 
-					hWnd = GetDlgItem(hDlgWnd, IDC_COLOR_BLUE);
-					SendMessage(hWnd, WM_GETTEXT , sizeof(buf), (LPARAM)buf);
-					b = atoi(buf);
+		GetDlgItemText(IDC_COLOR_BLUE, buf, sizeof(buf));
+		b = atoi(buf);
 
-					OutputDebugPrintf("%06x\n", RGB(r, g, b));
+		SetBkMode(hDC, TRANSPARENT);
+		SetTextColor(hDC, RGB(r, g, b) );
 
-					SetBkMode(hDC, TRANSPARENT);
-					SetTextColor(hDC, RGB(r, g, b) );
-					ReleaseDC(hDlgWnd, hDC);
-
-					return (BOOL)(HBRUSH)GetStockObject(NULL_BRUSH);
-				}
-				return FALSE;
-			}
-			break ;
-#endif
+		return (HBRUSH)GetStockObject(NULL_BRUSH);
 	}
-
-	return CPropertyPage::OnCommand(wParam, lParam);
+	return TTCPropertyPage::OnCtlColor(hDC, hWnd);
 }
 
 void CVisualPropPageDlg::OnOK()
 {
-	CListBox *listbox;
-	CButton *btn;
-	CComboBox *cmb;
 	int sel;
 	int beforeAlphaBlend;
 	char buf[MAXPATHLEN];
@@ -1301,12 +922,10 @@
 	// (2)
 	// \x83O\x83\x8D\x81[\x83o\x83\x8B\x95ϐ\x94 BGEnable \x82𒼐ڏ\x91\x82\xAB\x8A\xB7\x82\xA6\x82\xE9\x82ƁA\x83v\x83\x8D\x83O\x83\x89\x83\x80\x82\xAA\x97\x8E\x82\xBF\x82邱\x82Ƃ\xAA
 	// \x82\xA0\x82\xE9\x82̂ŃR\x83s\x81[\x82\xF0\x8FC\x90\xB3\x82\xB7\x82\xE9\x82݂̂Ƃ\xB7\x82\xE9\x81B(2005.4.24 yutaka)
-	btn = (CButton *)GetDlgItem(IDC_ETERM_LOOKFEEL);
-	if (ts.EtermLookfeel.BGEnable != btn->GetCheck()) {
+	if (ts.EtermLookfeel.BGEnable != GetCheck(IDC_ETERM_LOOKFEEL)) {
 		flag_changed = 1;
-		ts.EtermLookfeel.BGEnable = btn->GetCheck();
+		ts.EtermLookfeel.BGEnable = GetCheck(IDC_ETERM_LOOKFEEL);
 	}
-
 	if (ts.EtermLookfeel.BGEnable) {
 		GetDlgItemText(IDC_BGIMG_EDIT, ts.BGImageFilePath, sizeof(ts.BGImageFilePath));
 	} else {
@@ -1321,15 +940,13 @@
 	}
 
 	// (3)
-	listbox = (CListBox *)GetDlgItem(IDC_MOUSE_CURSOR);
-	sel = listbox->GetCurSel();
+	sel = SendDlgItemMessage(IDC_MOUSE_CURSOR, LB_GETCURSEL, 0, 0);
 	if (sel >= 0 && sel < MOUSE_CURSOR_MAX) {
 		strncpy_s(ts.MouseCursorName, sizeof(ts.MouseCursorName), MouseCursor[sel].name, _TRUNCATE);
 	}
 
 	// (4)Font quality
-	cmb = (CComboBox *)GetDlgItem(IDC_FONT_QUALITY);
-	switch (cmb->GetCurSel()) {
+	switch (GetCurSel(IDC_FONT_QUALITY)) {
 		case 0:
 			ts.FontQuality = DEFAULT_QUALITY;
 			break;
@@ -1347,22 +964,19 @@
 	}
 
 	// (6) Attr Bold Color
-	btn = (CButton *)GetDlgItem(IDC_ENABLE_ATTR_COLOR_BOLD);
-	if (((ts.ColorFlag & CF_BOLDCOLOR) != 0) != btn->GetCheck()) {
+	if (((ts.ColorFlag & CF_BOLDCOLOR) != 0) != GetCheck(IDC_ENABLE_ATTR_COLOR_BOLD)) {
 		ts.ColorFlag ^= CF_BOLDCOLOR;
 	}
 
 	// (7) Attr Blink Color
-	btn = (CButton *)GetDlgItem(IDC_ENABLE_ATTR_COLOR_BLINK);
-	if (((ts.ColorFlag & CF_BLINKCOLOR) != 0) != btn->GetCheck()) {
+	if (((ts.ColorFlag & CF_BLINKCOLOR) != 0) != GetCheck(IDC_ENABLE_ATTR_COLOR_BLINK)) {
 		ts.ColorFlag ^= CF_BLINKCOLOR;
 	}
 
 	// (8) Attr Reverse Color
-	btn = (CButton *)GetDlgItem(IDC_ENABLE_ATTR_COLOR_REVERSE);
 	if (ts.ColorFlag & CF_REVERSEVIDEO) { // Reverse Video\x83\x82\x81[\x83h(DECSCNM)\x8E\x9E\x82͏\x88\x97\x9D\x82\xF0\x95ς\xA6\x82\xE9
 		if (ts.ColorFlag & CF_REVERSECOLOR) {
-			if (!btn->GetCheck()) {
+			if (!GetCheck(IDC_ENABLE_ATTR_COLOR_REVERSE)) {
 				TmpColor = ts.VTColor[0];
 				ts.VTColor[0] = ts.VTReverseColor[1];
 				ts.VTReverseColor[1] = ts.VTColor[1];
@@ -1371,7 +985,7 @@
 				ts.ColorFlag ^= CF_REVERSECOLOR;
 			}
 		}
-		else if (btn->GetCheck()) {
+		else if (GetCheck(IDC_ENABLE_ATTR_COLOR_REVERSE)) {
 			TmpColor = ts.VTColor[0];
 			ts.VTColor[0] = ts.VTReverseColor[0];
 			ts.VTReverseColor[0] = ts.VTColor[1];
@@ -1380,25 +994,22 @@
 			ts.ColorFlag ^= CF_REVERSECOLOR;
 		}
 	}
-	else if (((ts.ColorFlag & CF_REVERSECOLOR) != 0) != btn->GetCheck()) {
+	else if (((ts.ColorFlag & CF_REVERSECOLOR) != 0) != GetCheck(IDC_ENABLE_ATTR_COLOR_REVERSE)) {
 		ts.ColorFlag ^= CF_REVERSECOLOR;
 	}
 
 	// (9) URL Color
-	btn = (CButton *)GetDlgItem(IDC_ENABLE_URL_COLOR);
-	if (((ts.ColorFlag & CF_URLCOLOR) != 0) != btn->GetCheck()) {
+	if (((ts.ColorFlag & CF_URLCOLOR) != 0) != GetCheck(IDC_ENABLE_URL_COLOR)) {
 		ts.ColorFlag ^= CF_URLCOLOR;
 	}
 
 	// (10) Color
-	btn = (CButton *)GetDlgItem(IDC_ENABLE_ANSI_COLOR);
-	if (((ts.ColorFlag & CF_ANSICOLOR) != 0) != btn->GetCheck()) {
+	if (((ts.ColorFlag & CF_ANSICOLOR) != 0) != GetCheck(IDC_ENABLE_ANSI_COLOR)) {
 		ts.ColorFlag ^= CF_ANSICOLOR;
 	}
 
 	// (11) URL Underline
-	btn = (CButton *)GetDlgItem(IDC_URL_UNDERLINE);
-	if (((ts.FontFlag & FF_URLUNDERLINE) != 0) != btn->GetCheck()) {
+	if (((ts.FontFlag & FF_URLUNDERLINE) != 0) != GetCheck(IDC_URL_UNDERLINE)) {
 		ts.FontFlag ^= FF_URLUNDERLINE;
 	}
 
@@ -1423,32 +1034,28 @@
 
 // CLogPropPageDlg \x83_\x83C\x83A\x83\x8D\x83O
 
-IMPLEMENT_DYNAMIC(CLogPropPageDlg, CPropertyPage)
-
-CLogPropPageDlg::CLogPropPageDlg()
-	: CPropertyPage(CLogPropPageDlg::IDD)
+CLogPropPageDlg::CLogPropPageDlg(HINSTANCE inst, TTCPropertySheet *sheet)
+	: TTCPropertyPage(inst, CLogPropPageDlg::IDD, sheet)
 {
-
+	get_lang_msg("DLG_TABSHEET_TITLE_Log", ts.UIMsg, sizeof(ts.UIMsg),
+	             "Log", ts.UILanguageFile);
+	m_psp.pszTitle = _tcsdup(ts.UIMsg);
+	m_psp.dwFlags |= PSP_USETITLE;
 }
 
 CLogPropPageDlg::~CLogPropPageDlg()
 {
-	if (DlgLogFont != NULL) {
-		DeleteObject(DlgLogFont);
-	}
+	free((void *)m_psp.pszTitle);
 }
 
-BEGIN_MESSAGE_MAP(CLogPropPageDlg, CPropertyPage)
-END_MESSAGE_MAP()
-
 // CLogPropPageDlg \x83\x81\x83b\x83Z\x81[\x83W \x83n\x83\x93\x83h\x83\x89
 
 #define LOG_ROTATE_SIZETYPE_NUM 3
-static char *LogRotateSizeType[] = {
+static const char *LogRotateSizeType[] = {
 	"Byte", "KB", "MB"
 };
 
-static char *GetLogRotateSizeType(int val)
+static const char *GetLogRotateSizeType(int val)
 {
 	if (val >= LOG_ROTATE_SIZETYPE_NUM)
 		val = 0;
@@ -1456,95 +1063,31 @@
 	return LogRotateSizeType[val];
 }
 
-BOOL CLogPropPageDlg::OnInitDialog()
+void CLogPropPageDlg::OnInitDialog()
 {
-	char uimsg[MAX_UIMSG];
-	CButton *btn;
-	CComboBox *combo;
-	int i, TmpLogRotateSize;
+	TTCPropertyPage::OnInitDialog();
 
-	CPropertyPage::OnInitDialog();
-
-	font = (HFONT)SendMessage(WM_GETFONT, 0, 0);
-	GetObject(font, sizeof(LOGFONT), &logfont);
-	if (get_lang_font("DLG_TAHOMA_FONT", GetSafeHwnd(), &logfont, &DlgLogFont, ts.UILanguageFile)) {
-		SendDlgItemMessage(IDC_VIEWLOG_LABEL, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_VIEWLOG_EDITOR, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_VIEWLOG_PATH, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_DEFAULTNAME_LABEL, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_DEFAULTNAME_EDITOR, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_DEFAULTPATH_LABEL, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_DEFAULTPATH_EDITOR, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_DEFAULTPATH_PUSH, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_AUTOSTART, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
-
+	static const DlgTextInfo TextInfos[] = {
+		{ IDC_VIEWLOG_LABEL, "DLG_TAB_LOG_EDITOR" },
+		{ IDC_DEFAULTNAME_LABEL, "DLG_TAB_LOG_FILENAME" },
+		{ IDC_DEFAULTPATH_LABEL, "DLG_TAB_LOG_FILEPATH" },
+		{ IDC_AUTOSTART, "DLG_TAB_LOG_AUTOSTART" },
 		// Log rotate
-		SendDlgItemMessage(IDC_LOG_ROTATE, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_ROTATE_SIZE_TEXT, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_ROTATE_SIZE, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_ROTATE_SIZE_TYPE, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_ROTATE_STEP_TEXT, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_ROTATE_STEP, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
-
+		{ IDC_LOG_ROTATE, "DLG_TAB_LOG_ROTATE" },
+		{ IDC_ROTATE_SIZE_TEXT, "DLG_TAB_LOG_ROTATE_SIZE_TEXT" },
+		{ IDC_ROTATE_STEP_TEXT, "DLG_TAB_LOG_ROTATESTEP" },
 		// Log options
-		SendDlgItemMessage(IDC_LOG_OPTION_GROUP, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_OPT_BINARY, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_OPT_APPEND, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_OPT_PLAINTEXT, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_OPT_TIMESTAMP, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_OPT_HIDEDLG, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_OPT_INCBUF, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
-	}
-	else {
-		DlgLogFont = NULL;
-	}
+		// FIXME: \x83\x81\x83b\x83Z\x81[\x83W\x83J\x83^\x83\x8D\x83O\x82͊\xF9\x91\xB6\x82̃\x8D\x83O\x83I\x83v\x83V\x83\x87\x83\x93\x82̂\xE0\x82̂𗬗p\x82\xB5\x82\xBD\x82\xAA\x81A\x83A\x83N\x83Z\x83\x89\x83\x8C\x81[\x83^\x83L\x81[\x82\xAA\x8Fd\x95\xA1\x82\xB7\x82邩\x82\xE0\x82\xB5\x82\xEA\x82Ȃ\xA2\x81B
+		{ IDC_LOG_OPTION_GROUP, "DLG_FOPT" },
+		{ IDC_OPT_BINARY, "DLG_FOPT_BINARY" },
+		{ IDC_OPT_APPEND, "DLG_FOPT_APPEND" },
+		{ IDC_OPT_PLAINTEXT, "DLG_FOPT_PLAIN" },
+		{ IDC_OPT_HIDEDLG, "DLG_FOPT_HIDEDIALOG" },
+		{ IDC_OPT_INCBUF, "DLG_FOPT_ALLBUFFINFIRST" },
+		{ IDC_OPT_TIMESTAMP, "DLG_FOPT_TIMESTAMP" },
+	};
+	SetDlgTexts(m_hWnd, TextInfos, _countof(TextInfos), ts.UILanguageFile);
 
-	GetDlgItemText(IDC_VIEWLOG_LABEL, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_LOG_EDITOR", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_VIEWLOG_LABEL, ts.UIMsg);
-	GetDlgItemText(IDC_DEFAULTNAME_LABEL, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_LOG_FILENAME", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_DEFAULTNAME_LABEL, ts.UIMsg);
-	GetDlgItemText(IDC_DEFAULTPATH_LABEL, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_LOG_FILEPATH", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_DEFAULTPATH_LABEL, ts.UIMsg);
-	GetDlgItemText(IDC_AUTOSTART, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_LOG_AUTOSTART", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_AUTOSTART, ts.UIMsg);
-	// Log rotate
-	GetDlgItemText(IDC_LOG_ROTATE, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_LOG_ROTATE", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_LOG_ROTATE, ts.UIMsg);
-	GetDlgItemText(IDC_ROTATE_SIZE_TEXT, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_LOG_ROTATE_SIZE_TEXT", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_ROTATE_SIZE_TEXT, ts.UIMsg);
-	GetDlgItemText(IDC_ROTATE_STEP_TEXT, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_LOG_ROTATESTEP", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_ROTATE_STEP_TEXT, ts.UIMsg);
-	// Log options
-	// FIXME: \x83\x81\x83b\x83Z\x81[\x83W\x83J\x83^\x83\x8D\x83O\x82͊\xF9\x91\xB6\x82̃\x8D\x83O\x83I\x83v\x83V\x83\x87\x83\x93\x82̂\xE0\x82̂𗬗p\x82\xB5\x82\xBD\x82\xAA\x81A\x83A\x83N\x83Z\x83\x89\x83\x8C\x81[\x83^\x83L\x81[\x82\xAA\x8Fd\x95\xA1\x82\xB7\x82邩\x82\xE0\x82\xB5\x82\xEA\x82Ȃ\xA2\x81B
-	GetDlgItemText(IDC_LOG_OPTION_GROUP, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_FOPT", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_LOG_OPTION_GROUP, ts.UIMsg);
-	GetDlgItemText(IDC_OPT_BINARY, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_FOPT_BINARY", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_OPT_BINARY, ts.UIMsg);
-	GetDlgItemText(IDC_OPT_APPEND, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_FOPT_APPEND", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_OPT_APPEND, ts.UIMsg);
-	GetDlgItemText(IDC_OPT_PLAINTEXT, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_FOPT_PLAIN", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_OPT_PLAINTEXT, ts.UIMsg);
-	GetDlgItemText(IDC_OPT_HIDEDLG, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_FOPT_HIDEDIALOG", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_OPT_HIDEDLG, ts.UIMsg);
-	GetDlgItemText(IDC_OPT_INCBUF, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_FOPT_ALLBUFFINFIRST", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_OPT_INCBUF, ts.UIMsg);
-	GetDlgItemText(IDC_OPT_TIMESTAMP, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_FOPT_TIMESTAMP", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_OPT_TIMESTAMP, ts.UIMsg);
-
 	get_lang_msg("DLG_FOPT_TIMESTAMP_LOCAL", ts.UIMsg, sizeof(ts.UIMsg), "Local Time", ts.UILanguageFile);
 	SendDlgItemMessage(IDC_OPT_TIMESTAMP_TYPE, CB_ADDSTRING, 0, (LPARAM)ts.UIMsg);
 	get_lang_msg("DLG_FOPT_TIMESTAMP_UTC", ts.UIMsg, sizeof(ts.UIMsg), "UTC", ts.UILanguageFile);
@@ -1565,66 +1108,55 @@
 	SetDlgItemText(IDC_DEFAULTPATH_EDITOR, ts.LogDefaultPath);
 
 	/* Auto start logging (2007.5.31 maya) */
-	btn = (CButton *)GetDlgItem(IDC_AUTOSTART);
-	btn->SetCheck(ts.LogAutoStart);
+	SetCheck(IDC_AUTOSTART, ts.LogAutoStart);
 
 	// Log rotate
-	btn = (CButton *)GetDlgItem(IDC_LOG_ROTATE);
-	btn->SetCheck(ts.LogRotate != ROTATE_NONE);
+	SetCheck(IDC_LOG_ROTATE, ts.LogRotate != ROTATE_NONE);
 
-	combo = (CComboBox *)GetDlgItem(IDC_ROTATE_SIZE_TYPE);
-	for (i = 0 ; i < LOG_ROTATE_SIZETYPE_NUM ; i++) {
-		combo->AddString(LogRotateSizeType[i]);
+	for (int i = 0 ; i < LOG_ROTATE_SIZETYPE_NUM ; i++) {
+		SendDlgItemMessage(IDC_ROTATE_SIZE_TYPE, CB_ADDSTRING, 0, (LPARAM)LogRotateSizeType[i]);
 	}
-
-	TmpLogRotateSize = ts.LogRotateSize;
-	for (i = 0 ; i < ts.LogRotateSizeType ; i++)
+	int TmpLogRotateSize = ts.LogRotateSize;
+	for (int i = 0 ; i < ts.LogRotateSizeType ; i++)
 		TmpLogRotateSize /= 1024;
 	SetDlgItemInt(IDC_ROTATE_SIZE, TmpLogRotateSize, FALSE);
-	combo->SelectString(-1, GetLogRotateSizeType(ts.LogRotateSizeType));
+	SendDlgItemMessage(IDC_ROTATE_SIZE_TYPE, CB_SELECTSTRING, -1, (LPARAM)GetLogRotateSizeType(ts.LogRotateSizeType));
 	SetDlgItemInt(IDC_ROTATE_STEP, ts.LogRotateStep, FALSE);
 	if (ts.LogRotate == ROTATE_NONE) {
-		GetDlgItem(IDC_ROTATE_SIZE_TEXT)->EnableWindow(FALSE);
-		GetDlgItem(IDC_ROTATE_SIZE)->EnableWindow(FALSE);
-		GetDlgItem(IDC_ROTATE_SIZE_TYPE)->EnableWindow(FALSE);
-		GetDlgItem(IDC_ROTATE_STEP_TEXT)->EnableWindow(FALSE);
-		GetDlgItem(IDC_ROTATE_STEP)->EnableWindow(FALSE);
+		EnableDlgItem(IDC_ROTATE_SIZE_TEXT, FALSE);
+		EnableDlgItem(IDC_ROTATE_SIZE, FALSE);
+		EnableDlgItem(IDC_ROTATE_SIZE_TYPE, FALSE);
+		EnableDlgItem(IDC_ROTATE_STEP_TEXT, FALSE);
+		EnableDlgItem(IDC_ROTATE_STEP, FALSE);
 	} else {
-		GetDlgItem(IDC_ROTATE_SIZE_TEXT)->EnableWindow(TRUE);
-		GetDlgItem(IDC_ROTATE_SIZE)->EnableWindow(TRUE);
-		GetDlgItem(IDC_ROTATE_SIZE_TYPE)->EnableWindow(TRUE);
-		GetDlgItem(IDC_ROTATE_STEP_TEXT)->EnableWindow(TRUE);
-		GetDlgItem(IDC_ROTATE_STEP)->EnableWindow(TRUE);
+		EnableDlgItem(IDC_ROTATE_SIZE_TEXT, TRUE);
+		EnableDlgItem(IDC_ROTATE_SIZE, TRUE);
+		EnableDlgItem(IDC_ROTATE_SIZE_TYPE, TRUE);
+		EnableDlgItem(IDC_ROTATE_STEP_TEXT, TRUE);
+		EnableDlgItem(IDC_ROTATE_STEP, TRUE);
 	}
 
 	// Log options
-	btn = (CButton *)GetDlgItem(IDC_OPT_BINARY);
-	btn->SetCheck(ts.LogBinary != 0);
+	SetCheck(IDC_OPT_BINARY, ts.LogBinary != 0);
 	if (ts.LogBinary) {
-		GetDlgItem(IDC_OPT_PLAINTEXT)->EnableWindow(FALSE);
-		GetDlgItem(IDC_OPT_TIMESTAMP)->EnableWindow(FALSE);
+		EnableDlgItem(IDC_OPT_PLAINTEXT, FALSE);
+		EnableDlgItem(IDC_OPT_TIMESTAMP, FALSE);
 	} else {
-		GetDlgItem(IDC_OPT_PLAINTEXT)->EnableWindow(TRUE);
-		GetDlgItem(IDC_OPT_TIMESTAMP)->EnableWindow(TRUE);
+		EnableDlgItem(IDC_OPT_PLAINTEXT, TRUE);
+		EnableDlgItem(IDC_OPT_TIMESTAMP, TRUE);
 	}
-	btn = (CButton *)GetDlgItem(IDC_OPT_APPEND);
-	btn->SetCheck(ts.Append != 0);
-	btn = (CButton *)GetDlgItem(IDC_OPT_PLAINTEXT);
-	btn->SetCheck(ts.LogTypePlainText != 0);
-	btn = (CButton *)GetDlgItem(IDC_OPT_HIDEDLG);
-	btn->SetCheck(ts.LogHideDialog != 0);
-	btn = (CButton *)GetDlgItem(IDC_OPT_INCBUF);
-	btn->SetCheck(ts.LogAllBuffIncludedInFirst != 0);
-	btn = (CButton *)GetDlgItem(IDC_OPT_TIMESTAMP);
-	btn->SetCheck(ts.LogTimestamp != 0);
+	SetCheck(IDC_OPT_APPEND, ts.Append != 0);
+	SetCheck(IDC_OPT_PLAINTEXT, ts.LogTypePlainText != 0);
+	SetCheck(IDC_OPT_HIDEDLG, ts.LogHideDialog != 0);
+	SetCheck(IDC_OPT_INCBUF, ts.LogAllBuffIncludedInFirst != 0);
+	SetCheck(IDC_OPT_TIMESTAMP, ts.LogTimestamp != 0);
 
-	combo = (CComboBox *)GetDlgItem(IDC_OPT_TIMESTAMP_TYPE);
-	combo->SetCurSel(ts.LogTimestampType);
+	SetCurSel(IDC_OPT_TIMESTAMP_TYPE, ts.LogTimestampType);
 	if (ts.LogBinary || !ts.LogTimestamp) {
-		GetDlgItem(IDC_OPT_TIMESTAMP_TYPE)->EnableWindow(FALSE);
+		EnableDlgItem(IDC_OPT_TIMESTAMP_TYPE, FALSE);
 	}
 	else {
-		GetDlgItem(IDC_OPT_TIMESTAMP_TYPE)->EnableWindow(TRUE);
+		EnableDlgItem(IDC_OPT_TIMESTAMP_TYPE, TRUE);
 	}
 /*
 	switch (ts.LogTimestampType) {
@@ -1645,8 +1177,6 @@
 
 	// \x83_\x83C\x83A\x83\x8D\x83O\x82Ƀt\x83H\x81[\x83J\x83X\x82𓖂Ă\xE9
 	::SetFocus(::GetDlgItem(GetSafeHwnd(), IDC_VIEWLOG_EDITOR));
-
-	return FALSE;
 }
 
 BOOL CLogPropPageDlg::OnCommand(WPARAM wParam, LPARAM lParam)
@@ -1690,20 +1220,18 @@
 
 		case IDC_LOG_ROTATE | (BN_CLICKED << 16):
 			{
-				CButton *btn;
-				btn = (CButton *)GetDlgItem(IDC_LOG_ROTATE);
-				if (btn->GetCheck()) {
-					GetDlgItem(IDC_ROTATE_SIZE_TEXT)->EnableWindow(TRUE);
-					GetDlgItem(IDC_ROTATE_SIZE)->EnableWindow(TRUE);
-					GetDlgItem(IDC_ROTATE_SIZE_TYPE)->EnableWindow(TRUE);
-					GetDlgItem(IDC_ROTATE_STEP_TEXT)->EnableWindow(TRUE);
-					GetDlgItem(IDC_ROTATE_STEP)->EnableWindow(TRUE);
+				if (GetCheck(IDC_LOG_ROTATE)) {
+					EnableDlgItem(IDC_ROTATE_SIZE_TEXT, TRUE);
+					EnableDlgItem(IDC_ROTATE_SIZE, TRUE);
+					EnableDlgItem(IDC_ROTATE_SIZE_TYPE, TRUE);
+					EnableDlgItem(IDC_ROTATE_STEP_TEXT, TRUE);
+					EnableDlgItem(IDC_ROTATE_STEP, TRUE);
 				} else {
-					GetDlgItem(IDC_ROTATE_SIZE_TEXT)->EnableWindow(FALSE);
-					GetDlgItem(IDC_ROTATE_SIZE)->EnableWindow(FALSE);
-					GetDlgItem(IDC_ROTATE_SIZE_TYPE)->EnableWindow(FALSE);
-					GetDlgItem(IDC_ROTATE_STEP_TEXT)->EnableWindow(FALSE);
-					GetDlgItem(IDC_ROTATE_STEP)->EnableWindow(FALSE);
+					EnableDlgItem(IDC_ROTATE_SIZE_TEXT, FALSE);
+					EnableDlgItem(IDC_ROTATE_SIZE, FALSE);
+					EnableDlgItem(IDC_ROTATE_SIZE_TYPE, FALSE);
+					EnableDlgItem(IDC_ROTATE_STEP_TEXT, FALSE);
+					EnableDlgItem(IDC_ROTATE_STEP, FALSE);
 				}
 
 			}
@@ -1711,19 +1239,16 @@
 
 		case IDC_OPT_BINARY | (BN_CLICKED << 16):
 			{
-				CButton *btn;
-				btn = (CButton *)GetDlgItem(IDC_OPT_BINARY);
-				if (btn->GetCheck()) {
-					GetDlgItem(IDC_OPT_PLAINTEXT)->EnableWindow(FALSE);
-					GetDlgItem(IDC_OPT_TIMESTAMP)->EnableWindow(FALSE);
-					GetDlgItem(IDC_OPT_TIMESTAMP_TYPE)->EnableWindow(FALSE);
+				if (GetCheck(IDC_OPT_BINARY)) {
+					EnableDlgItem(IDC_OPT_PLAINTEXT, FALSE);
+					EnableDlgItem(IDC_OPT_TIMESTAMP, FALSE);
+					EnableDlgItem(IDC_OPT_TIMESTAMP_TYPE, FALSE);
 				} else {
-					GetDlgItem(IDC_OPT_PLAINTEXT)->EnableWindow(TRUE);
-					GetDlgItem(IDC_OPT_TIMESTAMP)->EnableWindow(TRUE);
+					EnableDlgItem(IDC_OPT_PLAINTEXT, TRUE);
+					EnableDlgItem(IDC_OPT_TIMESTAMP, TRUE);
 
-					btn = (CButton *)GetDlgItem(IDC_OPT_TIMESTAMP);
-					if (btn->GetCheck()) {
-						GetDlgItem(IDC_OPT_TIMESTAMP_TYPE)->EnableWindow(TRUE);
+					if (GetCheck(IDC_OPT_TIMESTAMP)) {
+						EnableDlgItem(IDC_OPT_TIMESTAMP_TYPE, TRUE);
 					}
 				}
 			}
@@ -1731,18 +1256,16 @@
 
 		case IDC_OPT_TIMESTAMP | (BN_CLICKED << 16):
 			{
-				CButton *btn;
-				btn = (CButton *)GetDlgItem(IDC_OPT_TIMESTAMP);
-				if (btn->GetCheck()) {
-					GetDlgItem(IDC_OPT_TIMESTAMP_TYPE)->EnableWindow(TRUE);
+				if (GetCheck(IDC_OPT_TIMESTAMP)) {
+					EnableDlgItem(IDC_OPT_TIMESTAMP_TYPE, TRUE);
 				} else {
-					GetDlgItem(IDC_OPT_TIMESTAMP_TYPE)->EnableWindow(FALSE);
+					EnableDlgItem(IDC_OPT_TIMESTAMP_TYPE, FALSE);
 				}
 			}
 			return TRUE;
 	}
 
-	return CPropertyPage::OnCommand(wParam, lParam);
+	return TTCPropertyPage::OnCommand(wParam, lParam);
 }
 
 void CLogPropPageDlg::OnOK()
@@ -1751,10 +1274,6 @@
 	time_t time_local;
 	struct tm *tm_local;
 	char uimsg[MAX_UIMSG];
-	CButton *btn;
-	CString str;
-	CComboBox *cmb;
-	int i;
 
 	// Viewlog Editor path (2005.1.29 yutaka)
 	GetDlgItemText(IDC_VIEWLOG_EDITOR, ts.ViewlogEditor, sizeof(ts.ViewlogEditor));
@@ -1768,6 +1287,7 @@
 		MessageBox(ts.UIMsg, uimsg, MB_ICONEXCLAMATION);
 		return;
 	}
+
 	// \x8C\xBB\x8Dݎ\x9E\x8D\x8F\x82\xF0\x8E擾
 	time(&time_local);
 	tm_local = localtime(&time_local);
@@ -1792,25 +1312,21 @@
 	GetDlgItemText(IDC_DEFAULTPATH_EDITOR, ts.LogDefaultPath, sizeof(ts.LogDefaultPath));
 
 	/* Auto start logging (2007.5.31 maya) */
-	btn = (CButton *)GetDlgItem(IDC_AUTOSTART);
-	ts.LogAutoStart = btn->GetCheck();
+	ts.LogAutoStart = GetCheck(IDC_AUTOSTART);
 
 	/* Log Rotate */
-	btn = (CButton *)GetDlgItem(IDC_LOG_ROTATE);
-	if (btn->GetCheck()) {  /* on */
+	if (GetCheck(IDC_LOG_ROTATE)) {  /* on */
 		ts.LogRotate = ROTATE_SIZE;
-
-		((CComboBox*)GetDlgItem(IDC_ROTATE_SIZE_TYPE))->GetWindowText(str);
-		for (i = 0 ; i < LOG_ROTATE_SIZETYPE_NUM ; i++) {
-			if (strcmp(str, LogRotateSizeType[i]) == 0)
+		GetDlgItemText(IDC_ROTATE_SIZE_TYPE, buf, _countof(buf));
+		ts.LogRotateSizeType = 0;
+		for (int i = 0 ; i < LOG_ROTATE_SIZETYPE_NUM ; i++) {
+			if (strcmp(buf, LogRotateSizeType[i]) == 0) {
+				ts.LogRotateSizeType = i;
 				break;
+			}
 		}
-		if (i >= LOG_ROTATE_SIZETYPE_NUM)
-			i = 0;
-		ts.LogRotateSizeType = i;
-
 		ts.LogRotateSize = GetDlgItemInt(IDC_ROTATE_SIZE);
-		for (i = 0 ; i < ts.LogRotateSizeType ; i++)
+		for (int i = 0 ; i < ts.LogRotateSizeType ; i++)
 			ts.LogRotateSize *= 1024;
 
 		ts.LogRotateStep = GetDlgItemInt(IDC_ROTATE_STEP);
@@ -1821,8 +1337,7 @@
 	}
 
 	// Log Options
-	btn = (CButton *)GetDlgItem(IDC_OPT_BINARY);
-	if (btn->GetCheck()) {
+	if (GetCheck(IDC_OPT_BINARY)) {
 		ts.LogBinary = 1;
 	}
 	else {
@@ -1829,8 +1344,7 @@
 		ts.LogBinary = 0;
 	}
 
-	btn = (CButton *)GetDlgItem(IDC_OPT_APPEND);
-	if (btn->GetCheck()) {
+	if (GetCheck(IDC_OPT_APPEND)) {
 		ts.Append = 1;
 	}
 	else {
@@ -1837,8 +1351,7 @@
 		ts.Append = 0;
 	}
 
-	btn = (CButton *)GetDlgItem(IDC_OPT_PLAINTEXT);
-	if (btn->GetCheck()) {
+	if (GetCheck(IDC_OPT_PLAINTEXT)) {
 		ts.LogTypePlainText = 1;
 	}
 	else {
@@ -1845,8 +1358,7 @@
 		ts.LogTypePlainText = 0;
 	}
 
-	btn = (CButton *)GetDlgItem(IDC_OPT_HIDEDLG);
-	if (btn->GetCheck()) {
+	if (GetCheck(IDC_OPT_HIDEDLG)) {
 		ts.LogHideDialog = 1;
 	}
 	else {
@@ -1853,8 +1365,7 @@
 		ts.LogHideDialog = 0;
 	}
 
-	btn = (CButton *)GetDlgItem(IDC_OPT_INCBUF);
-	if (btn->GetCheck()) {
+	if (GetCheck(IDC_OPT_INCBUF)) {
 		ts.LogAllBuffIncludedInFirst = 1;
 	}
 	else {
@@ -1861,8 +1372,7 @@
 		ts.LogAllBuffIncludedInFirst = 0;
 	}
 
-	btn = (CButton *)GetDlgItem(IDC_OPT_TIMESTAMP);
-	if (btn->GetCheck()) {
+	if (GetCheck(IDC_OPT_TIMESTAMP)) {
 		ts.LogTimestamp = 1;
 	}
 	else {
@@ -1869,72 +1379,38 @@
 		ts.LogTimestamp = 0;
 	}
 
-	cmb = (CComboBox *)GetDlgItem(IDC_OPT_TIMESTAMP_TYPE);
-	ts.LogTimestampType = cmb->GetCurSel();
+	ts.LogTimestampType = GetCurSel(IDC_OPT_TIMESTAMP_TYPE);
 }
 
+/////////////////////////////
 
 // CCygwinPropPageDlg \x83_\x83C\x83A\x83\x8D\x83O
 
-IMPLEMENT_DYNAMIC(CCygwinPropPageDlg, CPropertyPage)
-
-CCygwinPropPageDlg::CCygwinPropPageDlg()
-	: CPropertyPage(CCygwinPropPageDlg::IDD)
+CCygwinPropPageDlg::CCygwinPropPageDlg(HINSTANCE inst, TTCPropertySheet *sheet)
+	: TTCPropertyPage(inst, CCygwinPropPageDlg::IDD, sheet)
 {
+	get_lang_msg("DLG_TABSHEET_TITLE_CYGWIN", ts.UIMsg, sizeof(ts.UIMsg),
+	             "Cygwin", ts.UILanguageFile);
+	m_psp.pszTitle = _tcsdup(ts.UIMsg);
+	m_psp.dwFlags |= PSP_USETITLE;
 }
 
 CCygwinPropPageDlg::~CCygwinPropPageDlg()
 {
-	if (DlgCygwinFont != NULL) {
-		DeleteObject(DlgCygwinFont);
-	}
+	free((void *)m_psp.pszTitle);
 }
 
-BEGIN_MESSAGE_MAP(CCygwinPropPageDlg, CPropertyPage)
-END_MESSAGE_MAP()
-
 // CCygwinPropPageDlg \x83\x81\x83b\x83Z\x81[\x83W \x83n\x83\x93\x83h\x83\x89
 
-BOOL CCygwinPropPageDlg::OnInitDialog()
+void CCygwinPropPageDlg::OnInitDialog()
 {
-	char uimsg[MAX_UIMSG];
-	CButton *btn;
+	TTCPropertyPage::OnInitDialog();
 
-	CPropertyPage::OnInitDialog();
+	static const DlgTextInfo TextInfos[] = {
+		{ IDC_CYGWIN_PATH_LABEL, "DLG_TAB_CYGWIN_PATH" }
+	};
+	SetDlgTexts(m_hWnd, TextInfos, _countof(TextInfos), ts.UILanguageFile);
 
-	font = (HFONT)SendMessage(WM_GETFONT, 0, 0);
-	GetObject(font, sizeof(LOGFONT), &logfont);
-	if (get_lang_font("DLG_TAHOMA_FONT", GetSafeHwnd(), &logfont, &DlgCygwinFont, ts.UILanguageFile)) {
-		SendDlgItemMessage(IDC_CYGWIN_PATH_LABEL, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_CYGWIN_PATH, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_SELECT_FILE, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_CYGWIN, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_TERM_LABEL, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_TERM_EDIT, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_TERMTYPE_LABEL, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_TERM_TYPE, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_PORTSTART_LABEL, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_PORT_START, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_PORTRANGE_LABEL, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_PORT_RANGE, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_SHELL_LABEL, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_SHELL, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_ENV1_LABEL, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_ENV1, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_ENV2_LABEL, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_ENV2, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_LOGIN_SHELL, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_HOME_CHDIR, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_AGENT_PROXY, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
-	}
-	else {
-		DlgCygwinFont = NULL;
-	}
-
-	GetDlgItemText(IDC_CYGWIN_PATH_LABEL, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_TAB_CYGWIN_PATH", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(IDC_CYGWIN_PATH_LABEL, ts.UIMsg);
-
 	memcpy(&settings, &ts.CygtermSettings, sizeof(cygterm_t));
 
 	SetDlgItemText(IDC_TERM_EDIT, settings.term);
@@ -1944,20 +1420,16 @@
 	SetDlgItemText(IDC_SHELL, settings.shell);
 	SetDlgItemText(IDC_ENV1, settings.env1);
 	SetDlgItemText(IDC_ENV2, settings.env2);
-	btn = (CButton *)GetDlgItem(IDC_LOGIN_SHELL);
-	btn->SetCheck(settings.login_shell);
-	btn = (CButton *)GetDlgItem(IDC_HOME_CHDIR);
-	btn->SetCheck(settings.home_chdir);
-	btn = (CButton *)GetDlgItem(IDC_AGENT_PROXY);
-	btn->SetCheck(settings.agent_proxy);
 
+	SetCheck(IDC_LOGIN_SHELL, settings.login_shell);
+	SetCheck(IDC_HOME_CHDIR, settings.home_chdir);
+	SetCheck(IDC_AGENT_PROXY, settings.agent_proxy);
+
 	// Cygwin install path
 	SetDlgItemText(IDC_CYGWIN_PATH, ts.CygwinDirectory);
 
 	// \x83_\x83C\x83A\x83\x8D\x83O\x82Ƀt\x83H\x81[\x83J\x83X\x82𓖂Ă\xE9
 	::SetFocus(::GetDlgItem(GetSafeHwnd(), IDC_CYGWIN_PATH));
-
-	return FALSE;
 }
 
 BOOL CCygwinPropPageDlg::OnCommand(WPARAM wParam, LPARAM lParam)
@@ -1976,13 +1448,11 @@
 			return TRUE;
 	}
 
-	return CPropertyPage::OnCommand(wParam, lParam);
+	return TTCPropertyPage::OnCommand(wParam, lParam);
 }
 
 void CCygwinPropPageDlg::OnOK()
 {
-	CButton *btn;
-
 	// writing to CygTerm config file
 	GetDlgItemText(IDC_TERM_EDIT, settings.term, sizeof(settings.term));
 	GetDlgItemText(IDC_TERM_TYPE, settings.term_type, sizeof(settings.term_type));
@@ -1991,13 +1461,11 @@
 	GetDlgItemText(IDC_SHELL, settings.shell, sizeof(settings.shell));
 	GetDlgItemText(IDC_ENV1, settings.env1, sizeof(settings.env1));
 	GetDlgItemText(IDC_ENV2, settings.env2, sizeof(settings.env2));
-	btn = (CButton *)GetDlgItem(IDC_LOGIN_SHELL);
-	settings.login_shell = btn->GetCheck();
-	btn = (CButton *)GetDlgItem(IDC_HOME_CHDIR);
-	settings.home_chdir = btn->GetCheck();
-	btn = (CButton *)GetDlgItem(IDC_AGENT_PROXY);
-	settings.agent_proxy = btn->GetCheck();
 
+	settings.login_shell = GetCheck(IDC_LOGIN_SHELL);
+	settings.home_chdir = GetCheck(IDC_HOME_CHDIR);
+	settings.agent_proxy = GetCheck(IDC_AGENT_PROXY);
+
 	memcpy(&ts.CygtermSettings, &settings, sizeof(cygterm_t));
 
 	// \x90ݒ\xE8\x82\xF0\x8F\x91\x82\xAB\x8D\x9E\x82ނ\xBD\x82߃t\x83\x89\x83O\x82𗧂ĂĂ\xA8\x82\xAD\x81B
@@ -2007,90 +1475,42 @@
 	GetDlgItemText(IDC_CYGWIN_PATH, ts.CygwinDirectory, sizeof(ts.CygwinDirectory));
 }
 
-
-
 // CAddSettingPropSheetDlg
-
-IMPLEMENT_DYNAMIC(CAddSettingPropSheetDlg, CPropertySheet)
-
-CAddSettingPropSheetDlg::CAddSettingPropSheetDlg(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
-	:CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
+CAddSettingPropSheetDlg::CAddSettingPropSheetDlg(HINSTANCE hInstance, LPCTSTR pszCaption, HWND hParentWnd) :
+	TTCPropertySheet(hInstance, pszCaption, hParentWnd)
 {
-	AddPage(&m_GeneralPage);
-	AddPage(&m_SequencePage);
-	AddPage(&m_CopypastePage);
-	AddPage(&m_VisualPage);
-	AddPage(&m_LogPage);
-	AddPage(&m_CygwinPage);
+	m_GeneralPage = new CGeneralPropPageDlg(hInstance, this);
+	m_SequencePage = new CSequencePropPageDlg(hInstance, this);
+	m_CopypastePage = new CCopypastePropPageDlg(hInstance, this);
+	m_VisualPage = new CVisualPropPageDlg(hInstance, this);
+	m_LogPage = new CLogPropPageDlg(hInstance, this);
+	m_CygwinPage = new CCygwinPropPageDlg(hInstance, this);
+		
+	hPsp[0] = CreatePropertySheetPage(&m_GeneralPage->m_psp);
+	hPsp[1] = CreatePropertySheetPage(&m_SequencePage->m_psp);
+	hPsp[2] = CreatePropertySheetPage(&m_CopypastePage->m_psp);
+	hPsp[3] = CreatePropertySheetPage(&m_VisualPage->m_psp);
+	hPsp[4] = CreatePropertySheetPage(&m_LogPage->m_psp);
+	hPsp[5] = CreatePropertySheetPage(&m_CygwinPage->m_psp);
+	m_psh.nPages = 6;
+	m_psh.phpage = hPsp;
 
-	m_psh.dwFlags |= PSH_NOAPPLYNOW;
+	get_lang_msg("DLG_TABSHEET_TITLE", ts.UIMsg, sizeof(ts.UIMsg),
+	             "Tera Term: Additional settings", ts.UILanguageFile);
+	m_psh.pszCaption = _tcsdup(ts.UIMsg);
 }
 
-CAddSettingPropSheetDlg::CAddSettingPropSheetDlg(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
-	:CPropertySheet(pszCaption, pParentWnd, iSelectPage)
-{
-	AddPage(&m_GeneralPage);
-	AddPage(&m_SequencePage);
-	AddPage(&m_CopypastePage);
-	AddPage(&m_VisualPage);
-	AddPage(&m_LogPage);
-	AddPage(&m_CygwinPage);
-
-	m_psh.dwFlags |= PSH_NOAPPLYNOW;
-}
-
 CAddSettingPropSheetDlg::~CAddSettingPropSheetDlg()
 {
+	free((void*)m_psh.pszCaption);
+	delete m_GeneralPage;
+	delete m_SequencePage;
+	delete m_CopypastePage;
+	delete m_VisualPage;
+	delete m_LogPage;
+	delete m_CygwinPage;
 }
 
-
-BEGIN_MESSAGE_MAP(CAddSettingPropSheetDlg, CPropertySheet)
-END_MESSAGE_MAP()
-
-
-// CAddSettingPropSheetDlg \x83\x81\x83b\x83Z\x81[\x83W \x83n\x83\x93\x83h\x83\x89
-
-BOOL CAddSettingPropSheetDlg::OnInitDialog()
+void CAddSettingPropSheetDlg::OnInitDialog()
 {
-	CPropertySheet::OnInitDialog();
-
-	get_lang_msg("DLG_TABSHEET_TITLE", ts.UIMsg, sizeof(ts.UIMsg),
-	             "Tera Term: Additional settings", ts.UILanguageFile);
-	SetWindowText(ts.UIMsg);
-
-	CTabCtrl *tab = GetTabControl();
-	TCITEM tc;
-	tc.mask = TCIF_TEXT;
-
-	get_lang_msg("DLG_TABSHEET_TITLE_GENERAL", ts.UIMsg, sizeof(ts.UIMsg),
-	             "General", ts.UILanguageFile);
-	tc.pszText = ts.UIMsg;
-	tab->SetItem(0, &tc);
-
-	get_lang_msg("DLG_TABSHEET_TITLE_SEQUENCE", ts.UIMsg, sizeof(ts.UIMsg),
-	             "Control Sequence", ts.UILanguageFile);
-	tc.pszText = ts.UIMsg;
-	tab->SetItem(1, &tc);
-
-	get_lang_msg("DLG_TABSHEET_TITLE_COPYPASTE", ts.UIMsg, sizeof(ts.UIMsg),
-	             "Copy and Paste", ts.UILanguageFile);
-	tc.pszText = ts.UIMsg;
-	tab->SetItem(2, &tc);
-
-	get_lang_msg("DLG_TABSHEET_TITLE_VISUAL", ts.UIMsg, sizeof(ts.UIMsg),
-	             "Visual", ts.UILanguageFile);
-	tc.pszText = ts.UIMsg;
-	tab->SetItem(3, &tc);
-
-	get_lang_msg("DLG_TABSHEET_TITLE_Log", ts.UIMsg, sizeof(ts.UIMsg),
-	             "Log", ts.UILanguageFile);
-	tc.pszText = ts.UIMsg;
-	tab->SetItem(4, &tc);
-
-	get_lang_msg("DLG_TABSHEET_TITLE_CYGWIN", ts.UIMsg, sizeof(ts.UIMsg),
-	             "Cygwin", ts.UILanguageFile);
-	tc.pszText = ts.UIMsg;
-	tab->SetItem(5, &tc);
-
-	return FALSE;
 }

Modified: branches/cmake/teraterm/teraterm/addsetting.h
===================================================================
--- branches/cmake/teraterm/teraterm/addsetting.h	2018-08-05 13:33:28 UTC (rev 7175)
+++ branches/cmake/teraterm/teraterm/addsetting.h	2018-08-10 15:12:13 UTC (rev 7176)
@@ -1,5 +1,5 @@
 /*
- * (C) 2008-2017 TeraTerm Project
+ * (C) 2008-2018 TeraTerm Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -28,191 +28,109 @@
 
 #pragma once
 
+#include "tmfc.h"
 #include "tt_res.h"
 #include "teraterm.h"
 
-
 typedef struct {
 	char *name;
 	LPCTSTR id;
 } mouse_cursor_t;
 
-
-
 // General Page
-class CGeneralPropPageDlg : public CPropertyPage
+class CGeneralPropPageDlg : public TTCPropertyPage
 {
-	DECLARE_DYNAMIC(CGeneralPropPageDlg)
-
 public:
-	CGeneralPropPageDlg();
+	CGeneralPropPageDlg(HINSTANCE inst, TTCPropertySheet *sheet);
 	virtual ~CGeneralPropPageDlg();
-	BOOL OnInitDialog();
+private:
+	void OnInitDialog();
 	void OnOK();
-
 	enum { IDD = IDD_TABSHEET_GENERAL };
-
-private:
-	HFONT DlgGeneralFont;
-	LOGFONT logfont;
-	HFONT font;
-
-protected:
-	DECLARE_MESSAGE_MAP()
 };
 
-
-
 // Control Sequence Page
-class CSequencePropPageDlg : public CPropertyPage
+class CSequencePropPageDlg : public TTCPropertyPage
 {
-	DECLARE_DYNAMIC(CSequencePropPageDlg)
-
 public:
-	CSequencePropPageDlg();
+	CSequencePropPageDlg(HINSTANCE inst, TTCPropertySheet *sheet);
 	virtual ~CSequencePropPageDlg();
-	BOOL OnInitDialog();
+private:
+	void OnInitDialog();
 	void OnOK();
-
 	enum { IDD = IDD_TABSHEET_SEQUENCE };
-
-private:
-	HFONT DlgSequenceFont;
-	LOGFONT logfont;
-	HFONT font;
-
-protected:
-	DECLARE_MESSAGE_MAP()
-	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
+	BOOL OnCommand(WPARAM wParam, LPARAM lParam);
 };
 
-
-
 // Copypaste Page
-class CCopypastePropPageDlg : public CPropertyPage
+class CCopypastePropPageDlg : public TTCPropertyPage
 {
-	DECLARE_DYNAMIC(CCopypastePropPageDlg)
-
 public:
-	CCopypastePropPageDlg();
+	CCopypastePropPageDlg(HINSTANCE inst, TTCPropertySheet *sheet);
 	virtual ~CCopypastePropPageDlg();
-	BOOL OnInitDialog();
+private:
+	void OnInitDialog();
 	void OnOK();
-
 	enum { IDD = IDD_TABSHEET_COPYPASTE };
-
-private:
-	HFONT DlgCopypasteFont;
-	LOGFONT logfont;
-	HFONT font;
-
-protected:
-	DECLARE_MESSAGE_MAP()
-	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
+	BOOL OnCommand(WPARAM wParam, LPARAM lParam);
 };
 
-
-
 // Visual Page
-class CVisualPropPageDlg : public CPropertyPage
+class CVisualPropPageDlg : public TTCPropertyPage
 {
-	DECLARE_DYNAMIC(CVisualPropPageDlg)
-
 public:
-	CVisualPropPageDlg();
+	CVisualPropPageDlg(HINSTANCE inst, TTCPropertySheet *sheet);
 	virtual ~CVisualPropPageDlg();
-	BOOL OnInitDialog();
+private:
+	void OnInitDialog();
 	void OnOK();
-
+	HBRUSH OnCtlColor(HDC hDC, HWND hWnd);
 	enum { IDD = IDD_TABSHEET_VISUAL };
-
-private:
-	HFONT DlgVisualFont;
-	LOGFONT logfont;
-	HFONT font;
-
-protected:
-	DECLARE_MESSAGE_MAP()
-	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
+	BOOL OnCommand(WPARAM wParam, LPARAM lParam);
 };
 
-
-
 // Log Page
-class CLogPropPageDlg : public CPropertyPage
+class CLogPropPageDlg : public TTCPropertyPage
 {
-	DECLARE_DYNAMIC(CLogPropPageDlg)
-
 public:
-	CLogPropPageDlg();
+	CLogPropPageDlg(HINSTANCE inst, TTCPropertySheet *sheet);
 	virtual ~CLogPropPageDlg();
-	BOOL OnInitDialog();
+private:
+	void OnInitDialog();
 	void OnOK();
-
 	enum { IDD = IDD_TABSHEET_LOG };
-
-private:
-	HFONT DlgLogFont;
-	LOGFONT logfont;
-	HFONT font;
-
-protected:
-	DECLARE_MESSAGE_MAP()
-	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
+	BOOL OnCommand(WPARAM wParam, LPARAM lParam);
 };
 
-
-
 // Cygwin Page
-class CCygwinPropPageDlg : public CPropertyPage
+class CCygwinPropPageDlg : public TTCPropertyPage
 {
-	DECLARE_DYNAMIC(CCygwinPropPageDlg)
-
 public:
-	CCygwinPropPageDlg();
+	CCygwinPropPageDlg(HINSTANCE inst, TTCPropertySheet *sheet);
 	virtual ~CCygwinPropPageDlg();
-	BOOL OnInitDialog();
+private:
+	void OnInitDialog();
 	void OnOK();
-
 	enum { IDD = IDD_TABSHEET_CYGWIN };
-
-private:
-	HFONT DlgCygwinFont;
-	LOGFONT logfont;
-	HFONT font;
 	cygterm_t settings;
-
-protected:
-	DECLARE_MESSAGE_MAP()
-	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
+	BOOL OnCommand(WPARAM wParam, LPARAM lParam);
 };
 
-
-
 // Property Sheet
-class CAddSettingPropSheetDlg : public CPropertySheet
+class CAddSettingPropSheetDlg : public TTCPropertySheet
 {
-	DECLARE_DYNAMIC(CAddSettingPropSheetDlg)
-
 public:
-	CAddSettingPropSheetDlg(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
-	CAddSettingPropSheetDlg(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);
+	CAddSettingPropSheetDlg(HINSTANCE hInstance, LPCTSTR pszCaption, HWND hParentWnd = NULL);
 	virtual ~CAddSettingPropSheetDlg();
-	BOOL OnInitDialog();
-
 private:
-	HFONT DlgAdditionalFont;
-	LOGFONT logfont;
-	HFONT font;
+	void OnInitDialog();
 
-protected:
-	DECLARE_MESSAGE_MAP()
-
-public:
-	CGeneralPropPageDlg   m_GeneralPage;
-	CSequencePropPageDlg  m_SequencePage;
-	CCopypastePropPageDlg m_CopypastePage;
-	CVisualPropPageDlg    m_VisualPage;
-	CLogPropPageDlg       m_LogPage;
-	CCygwinPropPageDlg    m_CygwinPage;
+	HPROPSHEETPAGE hPsp[6];
+	
+	CGeneralPropPageDlg   *m_GeneralPage;
+	CSequencePropPageDlg  *m_SequencePage;
+	CCopypastePropPageDlg *m_CopypastePage;
+	CVisualPropPageDlg    *m_VisualPage;
+	CLogPropPageDlg       *m_LogPage;
+	CCygwinPropPageDlg    *m_CygwinPage;
 };

Modified: branches/cmake/teraterm/teraterm/dnddlg.cpp
===================================================================
--- branches/cmake/teraterm/teraterm/dnddlg.cpp	2018-08-05 13:33:28 UTC (rev 7175)
+++ branches/cmake/teraterm/teraterm/dnddlg.cpp	2018-08-10 15:12:13 UTC (rev 7176)
@@ -56,12 +56,15 @@
 };
 
 struct DrapDropDlgData {
+#if 0
 	HFONT hNewFont;
+#endif
 	DrapDropDlgParam *Param;
 };
 
 static LRESULT CALLBACK OnDragDropDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp)
 {
+#if 0
 	static const int FontIDs[] = {
 		IDC_FILENAME_EDIT,
 		IDC_DAD_STATIC,
@@ -73,6 +76,7 @@
 		IDC_DAD_NOTE,
 		IDOK, IDCANCEL,
 	};
+#endif
 	static const DlgTextInfo TextInfos[] = {
 		{ 0, "DLG_DANDD_TITLE" },
 		{ IDC_DAD_STATIC, "DLG_DANDD_TEXT" },
@@ -101,7 +105,9 @@
 		SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)DlgData);
 		DrapDropDlgParam *Param = (DrapDropDlgParam *)lp;
 		DlgData->Param = Param;
+#if 0
 		DlgData->hNewFont = SetDlgFonts(hDlgWnd, FontIDs, _countof(FontIDs), Param->UILanguageFile, NULL);
+#endif
 		SetDlgTexts(hDlgWnd, TextInfos, _countof(TextInfos), Param->UILanguageFile);
 
 		// target file
@@ -242,16 +248,22 @@
 			DlgData->Param->DropType = DROP_TYPE_CANCEL;
 		}
 		if (wID == IDOK || wID == IDCANCEL) {
+#if 0
 			EndDialog(hDlgWnd, wID);
+#else
+			TTEndDialog(hDlgWnd, wID);
+#endif
 			break;
 		}
 		return FALSE;
 	}
 	case WM_NCDESTROY:
+#if 0
 		if (DlgData->hNewFont != NULL) {
 			DeleteObject(DlgData->hNewFont);
 			DlgData->hNewFont = NULL;
 		}
+#endif
 		free(DlgData);
 		break;
 
@@ -288,10 +300,17 @@
 	Param.ScpSendDirSize = _countof(pts->ScpSendDir);
 	Param.UILanguageFile = pts->UILanguageFile;
 
+#if 0
 	int ret = DialogBoxParam(
 		hInstance, MAKEINTRESOURCE(IDD_DAD_DIALOG),
 		hWndParent, (DLGPROC)OnDragDropDlgProc,
 		(LPARAM)&Param);
+#else
+	int ret = TTDialogBoxParam(
+		hInstance, MAKEINTRESOURCE(IDD_DAD_DIALOG),
+		hWndParent, (DLGPROC)OnDragDropDlgProc,
+		(LPARAM)&Param);
+#endif
 	if (ret != IDOK) {
 		return DROP_TYPE_CANCEL;
 	}

Modified: branches/cmake/teraterm/teraterm/filesys.cpp
===================================================================
--- branches/cmake/teraterm/teraterm/filesys.cpp	2018-08-05 13:33:28 UTC (rev 7175)
+++ branches/cmake/teraterm/teraterm/filesys.cpp	2018-08-10 15:12:13 UTC (rev 7176)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 1994-1998 T. Teranishi
- * (C) 2005-2017 TeraTerm Project
+ * (C) 2005-2018 TeraTerm Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -250,7 +250,7 @@
 
 	if (FTDlg!=NULL)
 	{
-		FTDlg->Create(fv, &cv, &ts);
+		FTDlg->Create(hInst, HVTWin, fv, &cv, &ts);
 		FTDlg->RefreshNum();
 		if (fv->OpId == OpLog) {
 			HWndLog = FTDlg->m_hWnd; // steven add
@@ -1469,8 +1469,6 @@
 {
 	int vsize;
 	PProtoDlg pd;
-	HWND Hpd;
-	char uimsg[MAX_UIMSG];
 
 	ProtoId = IdProto;
 
@@ -1530,29 +1528,8 @@
 		ProtoVar = NULL;
 		return FALSE;
 	}
-	pd->Create(fv,&ts);
+	pd->Create(hInst, HVTWin, fv, &ts);
 
-	Hpd=pd->GetSafeHwnd();
-
-	GetDlgItemText(Hpd, IDC_PROT_FILENAME, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_PROT_FILENAME", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(Hpd, IDC_PROT_FILENAME, ts.UIMsg);
-	GetDlgItemText(Hpd, IDC_PROT_PROT, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_PROT_PROTO", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(Hpd, IDC_PROT_PROT, ts.UIMsg);
-	GetDlgItemText(Hpd, IDC_PROT_PACKET, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_PROT_PACKET", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(Hpd, IDC_PROT_PACKET, ts.UIMsg);
-	GetDlgItemText(Hpd, IDC_PROT_TRANS, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_PROT_TRANS", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(Hpd, IDC_PROT_TRANS, ts.UIMsg);
-	GetDlgItemText(Hpd, IDC_PROT_ELAPSED, uimsg, sizeof(uimsg));
-	get_lang_msg("DLG_PROT_ELAPSED", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(Hpd, IDC_PROT_ELAPSED, ts.UIMsg);
-	GetDlgItemText(Hpd, IDCANCEL, uimsg, sizeof(uimsg));
-	get_lang_msg("BTN_CANCEL", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
-	SetDlgItemText(Hpd, IDCANCEL, ts.UIMsg);
-
 	(*ProtoInit)(ProtoId,FileVar,ProtoVar,&cv,&ts);
 
 	PtDlg = pd;

Modified: branches/cmake/teraterm/teraterm/ftdlg.cpp
===================================================================
--- branches/cmake/teraterm/teraterm/ftdlg.cpp	2018-08-05 13:33:28 UTC (rev 7175)
+++ branches/cmake/teraterm/teraterm/ftdlg.cpp	2018-08-10 15:12:13 UTC (rev 7176)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 1994-1998 T. Teranishi
- * (C) 2007-2017 TeraTerm Project
+ * (C) 2007-2018 TeraTerm Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -28,32 +28,23 @@
  */
 
 /* TERATERM.EXE, file transfer dialog box */
-#include "stdafx.h"
+#include <stdio.h>
+#include <windows.h>
+#include <Commctrl.h>
 #include "teraterm.h"
 #include "tttypes.h"
 #include "ttftypes.h"
 #include "ttlib.h"
+#include "dlglib.h"
 #include "tt_res.h"
 #include "ftdlg.h"
 
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
 /////////////////////////////////////////////////////////////////////////////
 // CFileTransDlg dialog
 
-BEGIN_MESSAGE_MAP(CFileTransDlg, CDialog)
-	//{{AFX_MSG_MAP(CFileTransDlg)
-	//}}AFX_MSG_MAP
-END_MESSAGE_MAP()
-
-BOOL CFileTransDlg::Create(PFileVar pfv, PComVar pcv, PTTSet pts)
+BOOL CFileTransDlg::Create(HINSTANCE hInstance, HWND hParent, PFileVar pfv, PComVar pcv, PTTSet pts)
 {
 	BOOL Ok;
-	WNDCLASS wc;
 	int fuLoad = LR_DEFAULTCOLOR;
 	HWND hwnd;
 
@@ -61,28 +52,14 @@
 	cv = pcv;
 	cv->FilePause &= ~fv->OpId;
 	ts = pts;
-	LOGFONT logfont;
-	HFONT font;
+	Pause = FALSE;
 
-	wc.style = CS_PARENTDC;
-	wc.lpfnWndProc = AfxWndProc;
-	wc.cbClsExtra = 0;
-	wc.cbWndExtra = DLGWINDOWEXTRA;
-	wc.hInstance = AfxGetInstanceHandle();
-	wc.hIcon = NULL;
-	wc.hCursor = LoadCursor(NULL,IDC_ARROW);
-	wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
-	wc.lpszMenuName = NULL;
-	wc.lpszClassName = "FTDlg32";
-	RegisterClass(&wc);
-
-	Pause = FALSE;
-	hwnd = GetForegroundWindow()->GetSafeHwnd();
+	hwnd = GetForegroundWindow();
 	if (fv->OpId == OpLog) { // parent window is desktop
-		Ok = CDialog::Create(CFileTransDlg::IDD, GetDesktopWindow());
+		Ok = TTCDialog::Create(hInstance, GetDesktopWindow(), CFileTransDlg::IDD);
 	}
 	else { // parent window is VT window
-		Ok = CDialog::Create(CFileTransDlg::IDD, NULL);
+		Ok = TTCDialog::Create(hInstance, NULL, CFileTransDlg::IDD);
 	}
 
 	if (!fv->HideDialog) {
@@ -100,22 +77,6 @@
 
 	fv->HWin = GetSafeHwnd();
 
-	font = (HFONT)SendMessage(WM_GETFONT, 0, 0);
-	GetObject(font, sizeof(LOGFONT), &logfont);
-	if (get_lang_font("DLG_SYSTEM_FONT", fv->HWin, &logfont, &DlgFont, ts->UILanguageFile)) {
-		SendDlgItemMessage(IDC_TRANS_FILENAME, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_TRANSFNAME, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_FULLPATH_LABEL, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_EDIT_FULLPATH, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_TRANS_TRANS, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_TRANSBYTES, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_TRANS_ELAPSED, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_TRANS_ETIME, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_TRANSPAUSESTART, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDCANCEL, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_TRANSHELP, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-	}
-
 	return Ok;
 }
 
@@ -183,7 +144,7 @@
 /////////////////////////////////////////////////////////////////////////////
 // CFileTransDlg message handler
 
-BOOL CFileTransDlg::OnInitDialog()
+void CFileTransDlg::OnInitDialog()
 {
 	int fuLoad = LR_DEFAULTCOLOR;
 
@@ -205,19 +166,17 @@
 	if (IsWindowsNT4()) {
 		fuLoad = LR_VGACOLOR;
 	}
-	SmallIcon = LoadImage(AfxGetInstanceHandle(),
+	SmallIcon = LoadImage(m_hInst,
 		MAKEINTRESOURCE(IDI_TTERM),
 		IMAGE_ICON, 16, 16, fuLoad);
 	::PostMessage(GetSafeHwnd(), WM_SETICON, ICON_SMALL,
 		(LPARAM)SmallIcon);
 
-	BigIcon = LoadImage(AfxGetInstanceHandle(),
+	BigIcon = LoadImage(m_hInst,
 			MAKEINTRESOURCE(IDI_TTERM),
 			IMAGE_ICON, 0, 0, fuLoad);
 	::PostMessage(GetSafeHwnd(), WM_SETICON, ICON_BIG,
 		(LPARAM)BigIcon);
-
-	return 1;
 }
 
 void CFileTransDlg::OnCancel( )
@@ -238,7 +197,7 @@
 			::PostMessage(fv->HMainWin,WM_USER_DLGHELP2,0,0);
 			return TRUE;
 		default:
-			return (CDialog::OnCommand(wParam,lParam));
+			return (TTCDialog::OnCommand(wParam,lParam));
 	}
 }
 
@@ -245,14 +204,8 @@
 void CFileTransDlg::PostNcDestroy()
 {
 	// logopen\x82\xC6logclose\x82\xF0\x8CJ\x82\xE8\x95Ԃ\xB7\x82ƁAGDI\x83\x8A\x83\\x81[\x83X\x83\x8A\x81[\x83N\x82ƂȂ\xE9\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B
-	//   - CreateFontIndirect()\x82ō쐬\x82\xB5\x82\xBD\x98_\x97\x9D\x83t\x83H\x83\x93\x83g\x82\xF0\x8D폜\x82\xB7\x82\xE9\x81B
 	//   - LoadImage()\x82ɂ\xE6\x82\xE9\x83A\x83C\x83R\x83\x93\x83\x8A\x83\\x81[\x83X\x82\xF0\x89\xF0\x95\xFA\x82\xB7\x82\xE9\x81B
 	// (2016.10.5 yutaka)
-	if (DlgFont) {
-		DeleteObject(DlgFont);
-		DlgFont = NULL;
-	}
-
 	if (SmallIcon) {
 		DestroyIcon((HICON)SmallIcon);
 		SmallIcon = NULL;
@@ -265,8 +218,3 @@
 
 	delete this;
 }
-
-LRESULT CFileTransDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
-{
-	return DefDlgProc(GetSafeHwnd(),message,wParam,lParam);
-}

Modified: branches/cmake/teraterm/teraterm/ftdlg.h
===================================================================
--- branches/cmake/teraterm/teraterm/ftdlg.h	2018-08-05 13:33:28 UTC (rev 7175)
+++ branches/cmake/teraterm/teraterm/ftdlg.h	2018-08-10 15:12:13 UTC (rev 7176)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 1994-1998 T. Teranishi
- * (C) 2007-2017 TeraTerm Project
+ * (C) 2007-2018 TeraTerm Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -29,55 +29,38 @@
 
 /* TERATERM.EXE, file transfer dialog box */
 
+#include "tmfc.h"
+
 /////////////////////////////////////////////////////////////////////////////
 // CFileTransDlg dialog
 
-class CFileTransDlg : public CDialog
+class CFileTransDlg : public TTCDialog
 {
-private:
-	PFileVar fv;
-	PComVar cv;
-	BOOL Pause;
-#ifndef NO_I18N
-	PTTSet ts;
-	HFONT DlgFont;
-#endif
-	HANDLE SmallIcon;
-	HANDLE BigIcon;
-
 public:
 	CFileTransDlg() {
-		DlgFont = NULL;
 		SmallIcon = NULL;
 		BigIcon = NULL;
 	}
 
-#ifndef NO_I18N
-	BOOL Create(PFileVar pfv, PComVar pcv, PTTSet pts);
-#else
-	BOOL Create(PFileVar pfv, PComVar pcv);
-#endif
+	BOOL Create(HINSTANCE hInstance, HWND hParent, PFileVar pfv, PComVar pcv, PTTSet pts);
 	void ChangeButton(BOOL PauseFlag);
 	void RefreshNum();
 
-	//{{AFX_DATA(CFileTransDlg)
 	enum { IDD = IDD_FILETRANSDLG };
-	//}}AFX_DATA
 
-	//{{AFX_VIRTUAL(CFileTransDlg)
-	protected:
-	virtual void OnCancel( );
+protected:
+	virtual void OnCancel();
 	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
 	virtual void PostNcDestroy();
-	virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
-	//}}AFX_VIRTUAL
+	virtual void OnInitDialog();
 
-protected:
-
-	//{{AFX_MSG(CFileTransDlg)
-	virtual BOOL OnInitDialog();
-	//}}AFX_MSG
-	DECLARE_MESSAGE_MAP()
+private:
+	PFileVar fv;
+	PComVar cv;
+	BOOL Pause;
+	PTTSet ts;
+	HANDLE SmallIcon;
+	HANDLE BigIcon;
 };
 
 typedef CFileTransDlg *PFileTransDlg;

Modified: branches/cmake/teraterm/teraterm/prnabort.cpp
===================================================================
--- branches/cmake/teraterm/teraterm/prnabort.cpp	2018-08-05 13:33:28 UTC (rev 7175)
+++ branches/cmake/teraterm/teraterm/prnabort.cpp	2018-08-10 15:12:13 UTC (rev 7176)
@@ -28,59 +28,20 @@
  */
 
 /* TERATERM.EXE, print-abort dialog box */
-#include <windows.h>
-#include <windowsx.h>
 #include "teraterm.h"
 #include "tttypes.h"
 #include "ttlib.h"
 #include "dlglib.h"
 #include "tt_res.h"
+#include "tmfc.h"
 #include "prnabort.h"
 
-LRESULT CALLBACK CPrnAbortDlg::OnDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp)
+CPrnAbortDlg::CPrnAbortDlg()
 {
-	static const DlgTextInfo TextInfos[] = {
-		{ IDC_PRNABORT_PRINTING, "DLG_PRNABORT_PRINTING" }, 
-		{ IDCANCEL, "BTN_CANCEL" },
-	};
-	static const int FontIDs[] = {
-		IDC_PRNABORT_PRINTING, IDCANCEL
-	};
+}
 
-	CPrnAbortDlg *self = (CPrnAbortDlg *)GetWindowLongPtr(hDlgWnd, DWLP_USER);
-
-	switch (msg) {
-	case WM_INITDIALOG:
-	{
-		CPrnAbortDlg *self = (CPrnAbortDlg *)lp;
-		SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)self);
-		SetDlgTexts(hDlgWnd, TextInfos, _countof(TextInfos), self->m_ts->UILanguageFile);
-		self->m_hNewFont =
-			SetDlgFonts(hDlgWnd, FontIDs, _countof(FontIDs),
-						self->m_ts->UILanguageFile, "DLG_SYSTEM_FONT");
-		return TRUE;
-	}
-
-	case WM_COMMAND:
-	{
-		WORD wID = GET_WM_COMMAND_ID(wp, lp);
-		const WORD wCMD = GET_WM_COMMAND_CMD(wp, lp);
-		if (wID == IDOK) {
-			self->DestroyWindow();
-		}
-		if (wID == IDCANCEL) {
-			self->OnCancel();
-		}
-		return FALSE;
-	}
-	case WM_NCDESTROY:
-		self->PostNcDestroy();
-		return TRUE;
-
-	default:
-		return FALSE;
-	}
-	return TRUE;
+CPrnAbortDlg::~CPrnAbortDlg()
+{
 }
 
 BOOL CPrnAbortDlg::Create(HINSTANCE hInstance, HWND hParent, PBOOL AbortFlag, PTTSet pts)
@@ -89,41 +50,36 @@
 	m_hParentWnd = hParent;
 	m_ts = pts;
 
-	HRSRC hResource = ::FindResource(hInstance, MAKEINTRESOURCE(IDD_PRNABORTDLG), RT_DIALOG);
-	HANDLE hDlgTemplate = ::LoadResource(hInstance, hResource);
-	DLGTEMPLATE *lpTemplate = (DLGTEMPLATE *)::LockResource(hDlgTemplate);
-	HWND hWnd = ::CreateDialogIndirectParam(	
-		hInstance, lpTemplate, hParent,
-		(DLGPROC)OnDlgProc, (LPARAM)this);
-	if (hWnd == NULL)
-	{
-		return FALSE;
-	}
+	TTCDialog::Create(hInstance, hParent, IDD_PRNABORTDLG);
 
-	m_hWnd = hWnd;
-	::EnableWindow(hParent,FALSE);
-	::ShowWindow(hWnd, SW_SHOW);
-	::EnableWindow(m_hWnd,TRUE);
 	return TRUE;
 }
 
+void CPrnAbortDlg::OnInitDialog()
+{
+	TTCDialog::OnInitDialog();
+
+	static const DlgTextInfo TextInfos[] = {
+		{ IDC_PRNABORT_PRINTING, "DLG_PRNABORT_PRINTING" }, 
+		{ IDCANCEL, "BTN_CANCEL" },
+	};
+	static const int FontIDs[] = {
+		IDC_PRNABORT_PRINTING, IDCANCEL
+	};
+	SetDlgTexts(m_hWnd, TextInfos, _countof(TextInfos), m_ts->UILanguageFile);
+	m_hNewFont =
+		SetDlgFonts(m_hWnd, FontIDs, _countof(FontIDs),
+					m_ts->UILanguageFile, "DLG_SYSTEM_FONT");
+}
+
 void CPrnAbortDlg::OnCancel()
 {
 	*m_pAbort = TRUE;
-	DestroyWindow();
+	TTCDialog::OnCancel();
 }
 
 void CPrnAbortDlg::PostNcDestroy()
 {
 	::DeleteObject(m_hNewFont);
-	delete this;
+	TTCDialog::DestroyWindow();
 }
-
-BOOL CPrnAbortDlg::DestroyWindow()
-{
-	::EnableWindow(m_hParentWnd,TRUE);
-	::SetFocus(m_hParentWnd);
-	::DestroyWindow(m_hWnd);
-	return TRUE;
-}
-

Modified: branches/cmake/teraterm/teraterm/prnabort.h
===================================================================
--- branches/cmake/teraterm/teraterm/prnabort.h	2018-08-05 13:33:28 UTC (rev 7175)
+++ branches/cmake/teraterm/teraterm/prnabort.h	2018-08-10 15:12:13 UTC (rev 7176)
@@ -31,22 +31,21 @@
 #pragma once
 
 #include "tttypes.h"	// for TTSet
+#include "tmfc.h"
 
 // CPrnAbortDlg dialog
-class CPrnAbortDlg
+class CPrnAbortDlg : public TTCDialog
 {
 public:
-	HWND m_hWnd;
-	HWND GetSafeHwnd() const {return m_hWnd;}
+	CPrnAbortDlg();
+	~CPrnAbortDlg();
 	BOOL Create(HINSTANCE hInstance, HWND hParent, PBOOL AbortFlag, PTTSet pts);
-	BOOL DestroyWindow();
-	HFONT m_hNewFont;
+	void OnCancel();
+	void OnInitDialog();
+	void PostNcDestroy();
 
 private:
-	void OnCancel();
-	void PostNcDestroy();
-	HWND m_hParentWnd;
 	BOOL *m_pAbort;
 	TTTSet *m_ts;
-	static LRESULT CALLBACK OnDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp);
+	HFONT m_hNewFont;
 };

Modified: branches/cmake/teraterm/teraterm/protodlg.cpp
===================================================================
--- branches/cmake/teraterm/teraterm/protodlg.cpp	2018-08-05 13:33:28 UTC (rev 7175)
+++ branches/cmake/teraterm/teraterm/protodlg.cpp	2018-08-10 15:12:13 UTC (rev 7176)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 1994-1998 T. Teranishi
- * (C) 2007-2017 TeraTerm Project
+ * (C) 2007-2018 TeraTerm Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -28,12 +28,12 @@
  */
 
 /* TERATERM.EXE, file-transfer-protocol dialog box */
-#include "stdafx.h"
 #include "teraterm.h"
 #include "tt_res.h"
 #include "tttypes.h"
 #include "ttftypes.h"
 #include "ttlib.h"
+#include "dlglib.h"
 #include "protodlg.h"
 
 #ifdef _DEBUG
@@ -45,39 +45,14 @@
 /////////////////////////////////////////////////////////////////////////////
 // CProtoDlg dialog
 
-BEGIN_MESSAGE_MAP(CProtoDlg, CDialog)
-	//{{AFX_MSG_MAP(CProtoDlg)
-	//}}AFX_MSG_MAP
-END_MESSAGE_MAP()
-
-BOOL CProtoDlg::Create(PFileVar pfv, PTTSet pts)
+BOOL CProtoDlg::Create(HINSTANCE hInstance, HWND hParent, PFileVar pfv, PTTSet pts)
 {
-	BOOL Ok;
-	LOGFONT logfont;
-	HFONT font;
-
+	m_pts = pts;
 	fv = pfv;
 
-	Ok = CDialog::Create(CProtoDlg::IDD, NULL);
+	BOOL Ok = TTCDialog::Create(hInstance, hParent, CProtoDlg::IDD);
 	fv->HWin = GetSafeHwnd();
 
-	font = (HFONT)SendMessage(WM_GETFONT, 0, 0);
-	GetObject(font, sizeof(LOGFONT), &logfont);
-	if (get_lang_font("DLG_SYSTEM_FONT", GetSafeHwnd(), &logfont, &DlgFont, pts->UILanguageFile)) {
-		SendDlgItemMessage(IDC_PROT_FILENAME, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_PROTOFNAME, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_PROT_PROT, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_PROTOPROT, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_PROT_PACKET, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_PROTOPKTNUM, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_PROT_TRANS, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_PROTOBYTECOUNT, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_PROT_ELAPSED, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_PROTOELAPSEDTIME, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_PROTOPERCENT, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDCANCEL, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-	}
-
 	return Ok;
 }
 
@@ -84,8 +59,24 @@
 /////////////////////////////////////////////////////////////////////////////
 // CProtoDlg message handler
 
-void CProtoDlg::OnCancel( )
+void CProtoDlg::OnInitDialog()
 {
+	TTTSet *ts = m_pts;
+
+	static const DlgTextInfo TextInfos[] = {
+		{ IDC_PROT_FILENAME, "DLG_PROT_FILENAME" },
+		{ IDC_PROT_PROT, "DLG_PROT_PROTO" },
+		{ IDC_PROT_PACKET, "DLG_PROT_PACKET"},
+		{ IDC_PROT_TRANS, "DLG_PROT_TRANS" },
+		{ IDC_PROT_ELAPSED, "DLG_PROT_ELAPSED" },
+		{ IDCANCEL, "BTN_CANCEL" },
+	};
+	SetDlgTexts(m_hWnd, TextInfos, _countof(TextInfos), m_pts->UILanguageFile);
+}
+
+
+void CProtoDlg::OnCancel()
+{
 	::PostMessage(fv->HMainWin,WM_USER_PROTOCANCEL,0,0);
 }
 
@@ -96,7 +87,7 @@
 			::PostMessage(fv->HMainWin,WM_USER_PROTOCANCEL,0,0);
 			return TRUE;
 		default:
-			return (CDialog::OnCommand(wParam,lParam));
+			return (TTCDialog::OnCommand(wParam,lParam));
 	}
 }
 

Modified: branches/cmake/teraterm/teraterm/protodlg.h
===================================================================
--- branches/cmake/teraterm/teraterm/protodlg.h	2018-08-05 13:33:28 UTC (rev 7175)
+++ branches/cmake/teraterm/teraterm/protodlg.h	2018-08-10 15:12:13 UTC (rev 7176)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 1994-1998 T. Teranishi
- * (C) 2007-2017 TeraTerm Project
+ * (C) 2007-2018 TeraTerm Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -28,39 +28,25 @@
  */
 
 /* TERATERM.EXE, file-transfer-protocol dialog box */
+#include "tmfc.h"
+#include "tttypes.h"
 
 // CProtoDlg dialog
-class CProtoDlg : public CDialog
+class CProtoDlg : public TTCDialog
 {
-private:
-  PFileVar fv;
-#ifndef NO_I18N
-	HFONT DlgFont;
-#endif
 
 public:
-#ifndef NO_I18N
-	BOOL Create(PFileVar pfv, PTTSet pts);
-#else
-	BOOL Create(PFileVar pfv);
-#endif
+	BOOL Create(HINSTANCE hInstance, HWND hParent, PFileVar pfv, PTTSet pts);
 
-	//{{AFX_DATA(CProtoDlg)
 	enum { IDD = IDD_PROTDLG };
-	//}}AFX_DATA
-
-	//{{AFX_VIRTUAL(CProtoDlg)
-	protected:
+protected:
 	virtual void OnCancel( );
 	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
+	virtual void OnInitDialog();
 	virtual void PostNcDestroy();
-	//}}AFX_VIRTUAL
-
-protected:
-
-	//{{AFX_MSG(CProtoDlg)
-	//}}AFX_MSG
-	DECLARE_MESSAGE_MAP()
+private:
+	PFileVar fv;
+	TTTSet *m_pts;
 };
 
 typedef CProtoDlg *PProtoDlg;

Modified: branches/cmake/teraterm/teraterm/teraterm.cpp
===================================================================
--- branches/cmake/teraterm/teraterm/teraterm.cpp	2018-08-05 13:33:28 UTC (rev 7175)
+++ branches/cmake/teraterm/teraterm/teraterm.cpp	2018-08-10 15:12:13 UTC (rev 7176)
@@ -45,6 +45,7 @@
 #include "tekwin.h"
 #include "ttdde.h"
 #include "keyboard.h"
+#include "compat_win.h"
 
 #include "teraapp.h"
 
@@ -81,6 +82,11 @@
 			(*setDllDir)("");
 		}
 	}
+
+	WinCompatInit();
+	if (PSetThreadDpiAwarenessContext) {
+		PSetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
+	}
 }
 
 // CTeraApp instance

Added: branches/cmake/teraterm/teraterm/tmfc.cpp
===================================================================
--- branches/cmake/teraterm/teraterm/tmfc.cpp	                        (rev 0)
+++ branches/cmake/teraterm/teraterm/tmfc.cpp	2018-08-10 15:12:13 UTC (rev 7176)
@@ -0,0 +1,411 @@
+/*
+ * Copyright (C) 2018 TeraTerm Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Tera term Micro Framework class
+ */
+#include "tmfc.h"
+
+#include <windowsx.h>
+#include "dlglib.h"
+
+LRESULT TTCWnd::SendMessage(UINT msg, WPARAM wp, LPARAM lp)
+{
+	return ::SendMessage(m_hWnd, msg, wp, lp);
+}
+
+LRESULT TTCWnd::SendDlgItemMessage(int id, UINT msg, WPARAM wp, LPARAM lp)
+{
+	return ::SendDlgItemMessage(m_hWnd, id, msg, wp, lp);
+}
+
+void TTCWnd::GetDlgItemText(int id, TCHAR *buf, size_t size)
+{
+	::GetDlgItemText(m_hWnd, id, buf, size);
+}
+
+void TTCWnd::SetDlgItemText(int id, const TCHAR *str)
+{
+	::SetDlgItemText(m_hWnd, id, str);
+}
+
+// nCheck	BST_UNCHECKED / BST_CHECKED / BST_INDETERMINATE 
+void TTCWnd::SetCheck(int id, int nCheck)
+{
+	::SendMessage(::GetDlgItem(m_hWnd, id), BM_SETCHECK, nCheck, 0);
+}
+
+UINT TTCWnd::GetCheck(int id)
+{
+	return ::IsDlgButtonChecked(m_hWnd, id);
+}
+
+void TTCWnd::SetCurSel(int id, int no)
+{
+	::SendMessage(::GetDlgItem(m_hWnd, id), CB_SETCURSEL, no, 0);
+}
+
+int TTCWnd::GetCurSel(int id)
+{
+	LRESULT lResult = ::SendMessage(::GetDlgItem(m_hWnd, id), CB_GETCURSEL, 0, 0);
+	return (int)lResult;
+}
+
+void TTCWnd::EnableDlgItem(int id, BOOL enable)
+{
+	::EnableWindow(::GetDlgItem(m_hWnd, id), enable);
+}
+
+void TTCWnd::SetDlgItemInt(int id, UINT val, BOOL bSigned)
+{
+	::SetDlgItemInt(m_hWnd, id, val, bSigned);
+}
+
+UINT TTCWnd::GetDlgItemInt(int id, BOOL* lpTrans, BOOL bSigned) const
+{
+	return ::GetDlgItemInt(m_hWnd, id, lpTrans, bSigned);
+}
+
+void TTCWnd::ShowWindow(int nCmdShow)
+{
+	::ShowWindow(m_hWnd, nCmdShow);
+}
+
+void TTCWnd::SetWindowText(TCHAR *str)
+{
+	::SetWindowText(m_hWnd, str);
+}
+
+static void ModifyStyleCom(
+	HWND hWnd, int nStyleOffset,
+	DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0)
+{
+	const DWORD dwStyle = ::GetWindowLong(hWnd, nStyleOffset);
+	const DWORD dwNewStyle = (dwStyle & ~dwRemove) | dwAdd;
+	if (dwStyle != dwNewStyle) {
+		::SetWindowLong(hWnd, nStyleOffset, dwNewStyle);
+	}
+	if (nFlags != 0)
+	{
+		::SetWindowPos(hWnd, NULL, 0, 0, 0, 0,
+					   SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | nFlags);
+	}
+}
+
+void TTCWnd::ModifyStyle(DWORD dwRemove, DWORD dwAdd, UINT nFlags)
+{
+	ModifyStyleCom(m_hWnd, GWL_STYLE, dwRemove, dwAdd, nFlags);
+}
+
+void TTCWnd::ModifyStyleEx(DWORD dwRemove, DWORD dwAdd, UINT nFlags)
+{
+	ModifyStyleCom(m_hWnd, GWL_EXSTYLE, dwRemove, dwAdd, nFlags);
+}
+
+int TTCWnd::MessageBox(LPCTSTR lpText, LPCTSTR lpCaption, UINT uType)
+{
+	return ::MessageBox(m_hWnd, lpText, lpCaption, uType);
+}
+
+////////////////////////////////////////
+
+TTCDialog::TTCDialog()
+{
+}
+
+TTCDialog::~TTCDialog()
+{
+}
+
+void TTCDialog::OnInitDialog()
+{
+}
+
+BOOL TTCDialog::Create(HINSTANCE hInstance, HWND hParent, int idd)
+{
+#if 0
+	HRSRC hResource = ::FindResource(hInstance, MAKEINTRESOURCE(idd), RT_DIALOG);
+	HANDLE hDlgTemplate = ::LoadResource(hInstance, hResource);
+	DLGTEMPLATE *lpTemplate = (DLGTEMPLATE *)::LockResource(hDlgTemplate);
+#else
+	DLGTEMPLATE *lpTemplate = TTGetDlgTemplate(hInstance, MAKEINTRESOURCE(idd));
+#endif
+	HWND hWnd = ::CreateDialogIndirectParam(	
+		hInstance, lpTemplate, hParent,
+		(DLGPROC)OnDlgProc, (LPARAM)this);
+	if (hWnd == NULL)
+	{
+		return FALSE;
+	}
+
+	m_hWnd = hWnd;
+//	::EnableWindow(hParent,FALSE);
+	::ShowWindow(hWnd, SW_SHOW);
+//	::EnableWindow(m_hWnd,TRUE);
+
+	return TRUE;
+}
+
+BOOL TTCDialog::OnCommand(WPARAM wp, LPARAM lp)
+{
+	return TRUE;
+}
+
+void TTCDialog::OnOK()
+{
+	DestroyWindow();
+}
+
+void TTCDialog::OnCancel()
+{
+	DestroyWindow();
+}
+
+void TTCDialog::PostNcDestroy()
+{
+	delete this;
+}
+
+void TTCDialog::DestroyWindow()
+{
+	::EnableWindow(m_hParentWnd,TRUE);
+	::SetFocus(m_hParentWnd);
+	::DestroyWindow(m_hWnd);
+}
+
+LRESULT CALLBACK TTCDialog::OnDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp)
+{
+	TTCDialog *self = (TTCDialog *)GetWindowLongPtr(hDlgWnd, DWLP_USER);
+
+	switch (msg) {
+	case WM_INITDIALOG:
+	{
+		self = (TTCDialog *)lp;
+		SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)self);
+		self->OnInitDialog();
+		return TRUE;
+	}
+
+	case WM_COMMAND:
+	{
+		WORD wID = GET_WM_COMMAND_ID(wp, lp);
+		const WORD wCMD = GET_WM_COMMAND_CMD(wp, lp);
+		if (wID == IDOK) {
+			self->OnOK();
+			self->DestroyWindow();
+		}
+		if (wID == IDCANCEL) {
+			self->OnCancel();
+		}
+		return FALSE;
+	}
+	case WM_NCDESTROY:
+		self->PostNcDestroy();
+		return TRUE;
+
+	default:
+		return FALSE;
+	}
+	return TRUE;
+}
+
+////////////////////////////////////////
+
+// quick hack :-(
+static HINSTANCE ghInstance;
+static class TTCPropertySheet *gTTCPS;
+
+TTCPropertyPage::TTCPropertyPage(HINSTANCE inst, int id, TTCPropertySheet *sheet)
+{
+	memset(&m_psp, 0, sizeof(m_psp));
+	m_psp.dwSize = sizeof(m_psp);
+	m_psp.dwFlags = PSP_DEFAULT;
+	m_psp.hInstance = inst;
+	m_psp.pszTemplate = MAKEINTRESOURCE(id);
+#if 1
+	m_psp.dwFlags |= PSP_DLGINDIRECT;
+	m_psp.pResource = TTGetDlgTemplate(inst, m_psp.pszTemplate);
+#endif
+	m_psp.pfnDlgProc = (DLGPROC)Proc;
+	m_psp.lParam = (LPARAM)this;
+
+	m_pSheet = sheet;
+}
+
+TTCPropertyPage::~TTCPropertyPage()
+{
+	free((void *)m_psp.pResource);
+}
+
+void TTCPropertyPage::OnInitDialog()
+{
+}
+
+void TTCPropertyPage::OnOK()
+{
+}
+
+BOOL TTCPropertyPage::OnCommand(WPARAM wp, LPARAM lp)
+{
+	return TRUE;
+}
+
+HBRUSH TTCPropertyPage::OnCtlColor(HDC hDC, HWND hWnd)
+{
+	return (HBRUSH)::DefWindowProc(m_hWnd, WM_CTLCOLORSTATIC, (WPARAM)hDC, (LPARAM)hWnd);
+}
+
+UINT CALLBACK TTCPropertyPage::PropSheetPageProc(HWND hwnd, UINT uMsg, LPPROPSHEETPAGE ppsp)
+{
+	return 0;
+}
+
+BOOL CALLBACK TTCPropertyPage::Proc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp)
+{
+	TTCPropertyPage *self = (TTCPropertyPage *)GetWindowLongPtr(hDlgWnd, DWLP_USER);
+	switch (msg)
+	{
+	case WM_INITDIALOG:
+		self = (TTCPropertyPage *)(((PROPSHEETPAGE *)lp)->lParam);
+		SetWindowLongPtr(hDlgWnd, DWLP_USER, (LONG_PTR)self);
+		self->m_hWnd = hDlgWnd;
+		self->OnInitDialog();
+		break;
+	case WM_NOTIFY:
+	{
+		NMHDR * nmhdr = (NMHDR *)lp;
+		switch (nmhdr->code)
+		{
+		case PSN_APPLY:
+			self->OnOK();
+			break;
+		default:
+			break;
+		}
+		break;
+	}
+	case WM_COMMAND:
+		self->OnCommand(wp, lp);
+		break;
+	case WM_CTLCOLORSTATIC:
+		return (BOOL)self->OnCtlColor((HDC)wp, (HWND)lp);
+	}
+	return FALSE;
+}
+
+////////////////////////////////////////
+
+TTCPropertySheet::TTCPropertySheet(HINSTANCE hInstance, LPCTSTR pszCaption, HWND hParentWnd)
+{
+	m_hInst = hInstance;
+	memset(&m_psh, 0, sizeof(m_psh));
+	m_psh.dwSize = sizeof(m_psh);
+	m_psh.dwFlags = PSH_DEFAULT | PSH_NOAPPLYNOW | PSH_USECALLBACK;	// | PSH_MODELESS 
+	m_psh.hwndParent = hParentWnd;
+	m_psh.pfnCallback = PropSheetProc;
+}
+	
+TTCPropertySheet::~TTCPropertySheet()
+{
+}
+
+int TTCPropertySheet::DoModal()
+{
+	ghInstance = m_hInst;
+	gTTCPS = this;
+	return PropertySheet(&m_psh);
+
+	// モーダレスにするとタブの動きがおかしい
+#if 0
+	// モードレスダイアログボックスの場合はウィンドウのハンドル
+	m_hWnd = (HWND)::PropertySheet(&m_psh);
+//	ShowWindow(m_hWnd, SW_SHOW);
+	
+//	::ModifyStyle(m_hWnd, TCS_MULTILINE, TCS_SINGLELINE, 0);
+
+	ModalResult = 0;
+	HWND hDlgWnd = m_hWnd;
+	for(;;) {
+		if (ModalResult != 0) {
+			break;
+		}
+		MSG Msg;
+		BOOL quit = !::GetMessage(&Msg, NULL, NULL, NULL);
+		if (quit) {
+			// QM_QUIT
+			PostQuitMessage(0);
+			return IDCANCEL;
+		}
+		if ((hDlgWnd == Msg.hwnd) ||
+			::SendMessage(hDlgWnd, PSM_ISDIALOGMESSAGE, NULL, (LPARAM)&Msg))
+		{
+			// ダイアログ以外の処理
+			::TranslateMessage(&Msg);
+			::DispatchMessage(&Msg);
+		}
+		if (!SendMessage(hDlgWnd, PSM_GETCURRENTPAGEHWND, 0, 0)) {
+			// プロパティーシート終了
+			break;
+		}
+	}
+	return ModalResult;
+#endif
+}
+
+int CALLBACK TTCPropertySheet::PropSheetProc(HWND hWnd, UINT msg, LPARAM lp)
+{
+	switch (msg) {
+	case PSCB_PRECREATE:
+	{
+		// テンプレートの内容を書き換える 危険
+		// http://home.att.ne.jp/banana/akatsuki/doc/atlwtl/atlwtl15-01/index.html
+		size_t PrevTemplSize;
+		size_t NewTemplSize;
+		DLGTEMPLATE *NewTempl =
+			TTGetNewDlgTemplate(ghInstance, (DLGTEMPLATE *)lp,
+								&PrevTemplSize, &NewTemplSize);
+		NewTempl->style &= ~DS_CONTEXTHELP;		// check DLGTEMPLATEEX
+		memcpy((void *)lp, NewTempl, NewTemplSize);
+		free(NewTempl);
+		break;
+	}
+	case PSCB_INITIALIZED:
+	{
+		//TTCPropertySheet *self = (TTCPropertySheet *)lp;
+		TTCPropertySheet *self = gTTCPS;
+		self->m_hWnd = hWnd;
+		self->OnInitDialog();
+		break;
+	}
+	}
+	return 0;
+}
+
+void TTCPropertySheet::OnInitDialog()
+{
+}

Added: branches/cmake/teraterm/teraterm/tmfc.h
===================================================================
--- branches/cmake/teraterm/teraterm/tmfc.h	                        (rev 0)
+++ branches/cmake/teraterm/teraterm/tmfc.h	2018-08-10 15:12:13 UTC (rev 7176)
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2018 TeraTerm Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Tera term Micro Framework class
+ */
+#pragma once
+#include <windows.h>
+
+class TTCWnd
+{
+public:
+	HWND m_hWnd;
+	HINSTANCE m_hInst;
+
+	HWND GetSafeHwnd() const {return m_hWnd;}
+	HWND GetSafeHwnd() { return m_hWnd; }
+	LRESULT SendMessage(UINT msg, WPARAM wp, LPARAM lp);
+	LRESULT SendDlgItemMessage(int id, UINT msg, WPARAM wp, LPARAM lp);
+	void GetDlgItemText(int id, TCHAR *buf, size_t size);
+	void SetDlgItemText(int id, const TCHAR *str);
+	void SetCheck(int id, int nCheck);
+	UINT GetCheck(int id);
+	void SetCurSel(int id, int no);
+	int GetCurSel(int id);
+	void EnableDlgItem(int id, BOOL enable);
+	void SetDlgItemInt(int id, UINT val, BOOL bSigned = TRUE);
+	UINT GetDlgItemInt(int id, BOOL* lpTrans = NULL, BOOL bSigned = TRUE) const;
+	void ShowWindow(int nCmdShow);
+	void SetWindowText(TCHAR *str);
+	void ModifyStyle(DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0);
+	void ModifyStyleEx(DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0);
+	int MessageBox(LPCTSTR lpText, LPCTSTR lpCaption, UINT uType);
+};
+
+class TTCDialog : public TTCWnd
+{
+public:
+	TTCDialog();
+	virtual ~TTCDialog();
+	BOOL Create(HINSTANCE hInstance, HWND hParent, int idd);
+	virtual void OnInitDialog();
+	virtual	void OnOK();
+	virtual void OnCancel();
+	virtual void DestroyWindow();
+	virtual void PostNcDestroy();
+	virtual BOOL OnCommand(WPARAM wp, LPARAM lp);
+	HWND m_hParentWnd;
+
+private:
+	int DoModal();
+
+	static LRESULT CALLBACK OnDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp);
+};
+
+class TTCPropertySheet
+{
+public:
+	TTCPropertySheet(HINSTANCE hInstance, LPCTSTR pszCaption, HWND hParentWnd);
+	virtual ~TTCPropertySheet();
+	virtual void OnInitDialog();
+	int DoModal();
+	PROPSHEETHEADER m_psh;
+	HWND m_hWnd;
+	static int CALLBACK PropSheetProc(HWND hWnd, UINT msg, LPARAM lParam);
+	HINSTANCE m_hInst;
+};
+
+class TTCPropertyPage : public TTCWnd
+{
+public:
+	TTCPropertyPage(HINSTANCE inst, int id, TTCPropertySheet *sheet);
+	virtual ~TTCPropertyPage();
+	virtual void OnInitDialog();
+	virtual void OnOK();
+	virtual BOOL OnCommand(WPARAM wp, LPARAM lp);
+	virtual HBRUSH OnCtlColor(HDC hDC, HWND hWnd);
+
+	PROPSHEETPAGE m_psp;
+	static BOOL CALLBACK Proc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp);
+	static UINT CALLBACK PropSheetPageProc(HWND hwnd, UINT uMsg, LPPROPSHEETPAGE ppsp);
+	TTCPropertySheet *m_pSheet;
+};
+

Modified: branches/cmake/teraterm/teraterm/vtwin.cpp
===================================================================
--- branches/cmake/teraterm/teraterm/vtwin.cpp	2018-08-05 13:33:28 UTC (rev 7175)
+++ branches/cmake/teraterm/teraterm/vtwin.cpp	2018-08-10 15:12:13 UTC (rev 7176)
@@ -4525,8 +4525,8 @@
 {
 	DWORD ret;
 
-	CAddSettingPropSheetDlg CAddSetting("", CWnd::FromHandle(HVTWin));
-	CAddSetting.EnableStackedTabs(FALSE);
+	CAddSettingPropSheetDlg CAddSetting(hInst, "", HVTWin);
+//	CAddSetting.EnableStackedTabs(FALSE);
 	ret = CAddSetting.DoModal();
 	switch (ret) {
 		case -1:
@@ -6215,3 +6215,10 @@
 	(*AboutDialog)(HVTWin);
 	FreeTTDLG();
 }
+
+
+BOOL CallOnIdle(LONG lCount)
+{
+	CWinApp *app = AfxGetApp();
+	return app->OnIdle(lCount);
+}

Modified: branches/cmake/teraterm/ttpcmn/CMakeLists.txt
===================================================================
--- branches/cmake/teraterm/ttpcmn/CMakeLists.txt	2018-08-05 13:33:28 UTC (rev 7175)
+++ branches/cmake/teraterm/ttpcmn/CMakeLists.txt	2018-08-10 15:12:13 UTC (rev 7176)
@@ -34,6 +34,12 @@
   .
   )
 
+if(${MINGW})
+  link_directories(
+	${CMAKE_CURRENT_SOURCE_DIR}/../htmlhelp
+	)
+endif()
+
 add_library(
   ttpcmn SHARED
   ${SRC}

Modified: branches/cmake/teraterm/ttpdlg/CMakeLists.txt
===================================================================
--- branches/cmake/teraterm/ttpdlg/CMakeLists.txt	2018-08-05 13:33:28 UTC (rev 7175)
+++ branches/cmake/teraterm/ttpdlg/CMakeLists.txt	2018-08-10 15:12:13 UTC (rev 7176)
@@ -15,7 +15,11 @@
 
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/")
 
-set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} /i ${CMAKE_CURRENT_SOURCE_DIR}/../common")
+if(${MINGW})
+  set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} -I ${CMAKE_CURRENT_SOURCE_DIR}/../common")
+else()
+  set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} /i ${CMAKE_CURRENT_SOURCE_DIR}/../common")
+endif()
 
 set(SRC
   ../common/dlglib.c
@@ -38,9 +42,16 @@
   ${ONIGURUMA_INCLUDE_DIRS}
   )
 
-link_directories(
-  ${ONIGURUMA_LIBRARY_DIRS}
-  )
+if(${MINGW})
+  link_directories(
+	${CMAKE_CURRENT_SOURCE_DIR}/../htmlhelp
+	${ONIGURUMA_LIBRARY_DIRS}
+	)
+else()
+  link_directories(
+	${ONIGURUMA_LIBRARY_DIRS}
+	)
+endif()
 
 add_library(
   ttpdlg SHARED

Modified: branches/cmake/teraterm/ttpfile/CMakeLists.txt
===================================================================
--- branches/cmake/teraterm/ttpfile/CMakeLists.txt	2018-08-05 13:33:28 UTC (rev 7175)
+++ branches/cmake/teraterm/ttpfile/CMakeLists.txt	2018-08-10 15:12:13 UTC (rev 7176)
@@ -43,6 +43,12 @@
   ../common
   )
 
+if(${MINGW})
+  link_directories(
+	${CMAKE_CURRENT_SOURCE_DIR}/../htmlhelp
+	)
+endif()
+
 add_library(
   ttpfile SHARED
   ${SRC}

Modified: branches/cmake/teraterm/ttpmacro/CMakeLists.txt
===================================================================
--- branches/cmake/teraterm/ttpmacro/CMakeLists.txt	2018-08-05 13:33:28 UTC (rev 7175)
+++ branches/cmake/teraterm/ttpmacro/CMakeLists.txt	2018-08-10 15:12:13 UTC (rev 7176)
@@ -77,7 +77,9 @@
 
 set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:nafxcw.lib /NODEFAULTLIB:LIBCMT.lib")
 set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:nafxcwd.lib /NODEFAULTLIB:LIBCMTD.lib")
-set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:iphlpapi.dll /DELAYLOAD:user32.dll")
+if (${MSVC})
+  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:iphlpapi.dll /DELAYLOAD:user32.dll")
+endif()
 
 add_executable(
   ttpmacro WIN32

Modified: branches/cmake/teraterm/ttpset/CMakeLists.txt
===================================================================
--- branches/cmake/teraterm/ttpset/CMakeLists.txt	2018-08-05 13:33:28 UTC (rev 7175)
+++ branches/cmake/teraterm/ttpset/CMakeLists.txt	2018-08-10 15:12:13 UTC (rev 7176)
@@ -25,6 +25,12 @@
   ${CMAKE_CURRENT_SOURCE_DIR}/../common
   )
 
+if(${MINGW})
+  link_directories(
+	${CMAKE_CURRENT_SOURCE_DIR}/../htmlhelp
+	)
+endif()
+
 add_library(
   ttpset SHARED
   ${SRC}



Ttssh2-commit メーリングリストの案内