[Ttssh2-commit] [7256] - dllのdelayload調整

scmno****@osdn***** scmno****@osdn*****
2018年 11月 4日 (日) 00:33:07 JST


Revision: 7256
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/7256
Author:   zmatsuo
Date:     2018-11-04 00:33:07 +0900 (Sun, 04 Nov 2018)
Log Message:
-----------
- dllのdelayload調整
- メモリリーク関連検出追加
- モーダレスダイアログが正しく動作するよう修正
- マウスカーソルの設定がうまく動いていなかったので修正
- フォント設定追加
- listdlg()実装
- msgdlgのcloseボタン
- inpdlg
- statdlg全実装
- tmfcダイアログの使い方を修正
- VS2008expressでコンパイルできるよう調整
- msgdlgをWIN32に書き換え
- CWinAppからWinMainベースに
- statdlg作業
- リソースID修正
- NcDestoryWindowの動作を検討
- ListDlgが概ね動作
- impdlg()動く
- errdlg()動く
- ctrlwindowが生成できるようになった、リサイズがおかしい?
- editcontinueできるようにした
- OnIdle()がうまく回っていない?

Modified Paths:
--------------
    branches/cmake/.gitignore
    branches/cmake/CMakeLists.txt
    branches/cmake/TTProxy/CMakeLists.txt
    branches/cmake/TTProxy/StdAfx.h
    branches/cmake/TTXKanjiMenu/CMakeLists.txt
    branches/cmake/TTXSamples/TTXAlwaysOnTop/TTXAlwaysOnTop.c
    branches/cmake/TTXSamples/TTXRecurringCommand/CMakeLists.txt
    branches/cmake/TTXSamples/TTXttyrec/CMakeLists.txt
    branches/cmake/teraterm/CMakeLists.txt
    branches/cmake/teraterm/common/dlglib.c
    branches/cmake/teraterm/common/dlglib.h
    branches/cmake/teraterm/common/dlglib_tmpl.cpp
    branches/cmake/teraterm/keycode/CMakeLists.txt
    branches/cmake/teraterm/teraterm/CMakeLists.txt
    branches/cmake/teraterm/teraterm/WSAAsyncGetAddrInfo.c
    branches/cmake/teraterm/teraterm/WSAAsyncGetAddrInfo.h
    branches/cmake/teraterm/teraterm/addsetting.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/tekwin.cpp
    branches/cmake/teraterm/teraterm/teraterm.cpp
    branches/cmake/teraterm/teraterm/ttdde.c
    branches/cmake/teraterm/teraterm/ttermpro.rc
    branches/cmake/teraterm/teraterm/vtterm.c
    branches/cmake/teraterm/teraterm/vtwin.cpp
    branches/cmake/teraterm/teraterm/winjump.c
    branches/cmake/teraterm/ttpcmn/CMakeLists.txt
    branches/cmake/teraterm/ttpdlg/ttdlg.c
    branches/cmake/teraterm/ttpfile/CMakeLists.txt
    branches/cmake/teraterm/ttpfile/quickvan.c
    branches/cmake/teraterm/ttpmacro/CMakeLists.txt
    branches/cmake/teraterm/ttpmacro/ListDlg.cpp
    branches/cmake/teraterm/ttpmacro/ListDlg.h
    branches/cmake/teraterm/ttpmacro/errdlg.cpp
    branches/cmake/teraterm/ttpmacro/errdlg.h
    branches/cmake/teraterm/ttpmacro/inpdlg.cpp
    branches/cmake/teraterm/ttpmacro/inpdlg.h
    branches/cmake/teraterm/ttpmacro/msgdlg.cpp
    branches/cmake/teraterm/ttpmacro/msgdlg.h
    branches/cmake/teraterm/ttpmacro/statdlg.cpp
    branches/cmake/teraterm/ttpmacro/statdlg.h
    branches/cmake/teraterm/ttpmacro/ttl.c
    branches/cmake/teraterm/ttpmacro/ttm_res.h
    branches/cmake/teraterm/ttpmacro/ttmacro.cpp
    branches/cmake/teraterm/ttpmacro/ttmacro.h
    branches/cmake/teraterm/ttpmacro/ttmdlg.cpp
    branches/cmake/teraterm/ttpmacro/ttmlib.c
    branches/cmake/teraterm/ttpmacro/ttmlib.h
    branches/cmake/teraterm/ttpmacro/ttmmain.cpp
    branches/cmake/teraterm/ttpmacro/ttmmain.h
    branches/cmake/teraterm/ttpmacro/ttmparse.c
    branches/cmake/teraterm/ttpmacro/ttpmacro.rc
    branches/cmake/teraterm/ttpset/CMakeLists.txt
    branches/cmake/teraterm/ttptek/CMakeLists.txt
    branches/cmake/ttssh2/ttxssh/CMakeLists.txt
    branches/cmake/ttssh2/ttxssh/ttxssh.c
    branches/cmake/ttssh2/ttxssh/ttxssh.h

Added Paths:
-----------
    branches/cmake/teraterm/common/tmfc.cpp
    branches/cmake/teraterm/common/tmfc.h
    branches/cmake/teraterm/common/tmfc_frame.cpp
    branches/cmake/tests/gui_commands_test.ttl

Removed Paths:
-------------
    branches/cmake/teraterm/teraterm/tmfc.cpp
    branches/cmake/teraterm/teraterm/tmfc.h
    branches/cmake/teraterm/teraterm/tmfc_frame.cpp
    branches/cmake/teraterm/ttpmacro/stdafx.h

-------------- next part --------------
Modified: branches/cmake/.gitignore
===================================================================
--- branches/cmake/.gitignore	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/.gitignore	2018-11-03 15:33:07 UTC (rev 7256)
@@ -23,3 +23,5 @@
 GRTAGS
 GTAGS
 **/build*/*
+*.vcproj.*.user
+teraterm/ttpdlg/svnversion.h

Modified: branches/cmake/CMakeLists.txt
===================================================================
--- branches/cmake/CMakeLists.txt	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/CMakeLists.txt	2018-11-03 15:33:07 UTC (rev 7256)
@@ -22,10 +22,15 @@
   if(${CMAKE_GENERATOR} MATCHES "Visual Studio 15 2017")
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
+    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /ZI")
+    set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /ZI")
+    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
+    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
   endif()
 elseif(MINGW)
-  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -static -ffunction-sections -fdata-sections")
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -static -ffunction-sections -fdata-sections")
+  set(C_CXX_COMMON_FLAGS "")
+  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -static -ffunction-sections -fdata-sections ${C_ONLY_FLAGS} ${C_CXX_COMMON_FLAGS}")
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -static -ffunction-sections -fdata-sections ${C_CXX_COMMON_FLAGS}")
   if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
 	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc -static-libstdc++")
 	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
@@ -32,9 +37,6 @@
   endif()
   set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -s -Wl,--gc-sections")
   set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc -s -Wl,--gc-sections")
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__MINGW_USE_VC2005_COMPAT=1")
-  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__MINGW_USE_VC2005_COMPAT=1")
-#  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lmsvcr80")
 endif()
 
 add_subdirectory(teraterm)

Modified: branches/cmake/TTProxy/CMakeLists.txt
===================================================================
--- branches/cmake/TTProxy/CMakeLists.txt	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/TTProxy/CMakeLists.txt	2018-11-03 15:33:07 UTC (rev 7256)
@@ -97,8 +97,11 @@
 target_link_libraries(
   ttproxy
   ttpcmn
-  ws2_32.lib
-  version.lib
+  #
+  ws2_32
+  version
+  gdi32
+  comdlg32
   )
 
 

Modified: branches/cmake/TTProxy/StdAfx.h
===================================================================
--- branches/cmake/TTProxy/StdAfx.h	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/TTProxy/StdAfx.h	2018-11-03 15:33:07 UTC (rev 7256)
@@ -24,6 +24,8 @@
 
 // \x82\xB1\x82̈ʒu\x82Ƀw\x83b\x83_\x81[\x82\xF0\x91}\x93\xFC\x82\xB5\x82Ă\xAD\x82\xBE\x82\xB3\x82\xA2
 #include <winsock2.h>
+#include <ws2tcpip.h>
+#include <wspiapi.h>
 #include <windows.h>
 
 #include <openssl/crypto.h>

Modified: branches/cmake/TTXKanjiMenu/CMakeLists.txt
===================================================================
--- branches/cmake/TTXKanjiMenu/CMakeLists.txt	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/TTXKanjiMenu/CMakeLists.txt	2018-11-03 15:33:07 UTC (rev 7256)
@@ -36,7 +36,8 @@
 target_link_libraries(
   ttxkanjimenu
   ttpcmn
-  ws2_32.lib
+  #
+  ws2_32
   )
 
 

Modified: branches/cmake/TTXSamples/TTXAlwaysOnTop/TTXAlwaysOnTop.c
===================================================================
--- branches/cmake/TTXSamples/TTXAlwaysOnTop/TTXAlwaysOnTop.c	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/TTXSamples/TTXAlwaysOnTop/TTXAlwaysOnTop.c	2018-11-03 15:33:07 UTC (rev 7256)
@@ -7,7 +7,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <Windows.h>
+#include <windows.h>
 
 #include "compat_w95.h"
 

Modified: branches/cmake/TTXSamples/TTXRecurringCommand/CMakeLists.txt
===================================================================
--- branches/cmake/TTXSamples/TTXRecurringCommand/CMakeLists.txt	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/TTXSamples/TTXRecurringCommand/CMakeLists.txt	2018-11-03 15:33:07 UTC (rev 7256)
@@ -34,4 +34,6 @@
 target_link_libraries(
   TTXRecurringCommand
   ttpcmn
+  #
+  gdi32
   )

Modified: branches/cmake/TTXSamples/TTXttyrec/CMakeLists.txt
===================================================================
--- branches/cmake/TTXSamples/TTXttyrec/CMakeLists.txt	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/TTXSamples/TTXttyrec/CMakeLists.txt	2018-11-03 15:33:07 UTC (rev 7256)
@@ -25,6 +25,8 @@
 target_link_libraries(
   TTXttyplay
   ttpcmn
+  #
+  comdlg32
   )
 
 add_library(
@@ -36,6 +38,12 @@
   ReadMe-ja.txt
   )
 
+target_link_libraries(
+  TTXttyrec
+  ttpcmn
+  comdlg32
+  )
+
 set_target_properties(
   TTXttyrec TTXttyplay
   PROPERTIES

Modified: branches/cmake/teraterm/CMakeLists.txt
===================================================================
--- branches/cmake/teraterm/CMakeLists.txt	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/CMakeLists.txt	2018-11-03 15:33:07 UTC (rev 7256)
@@ -21,15 +21,10 @@
   ttpset
   PROPERTIES FOLDER teraterm)
 
-if((${CMAKE_MAKE_PROGRAM} MATCHES "VCExpress.exe") OR MINGW)
-  message("pass ttpmacro compile")
-else()
-  # need MFC (VS2005Express does not include MFC)
-  add_subdirectory(ttpmacro)
-  set_target_properties(
-	ttpmacro
-	PROPERTIES FOLDER teraterm)
-endif()
+add_subdirectory(ttpmacro)
+set_target_properties(
+  ttpmacro
+  PROPERTIES FOLDER teraterm)
 
 add_subdirectory(ttptek)
 set_target_properties(

Modified: branches/cmake/teraterm/common/dlglib.c
===================================================================
--- branches/cmake/teraterm/common/dlglib.c	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/common/dlglib.c	2018-11-03 15:33:07 UTC (rev 7256)
@@ -28,9 +28,11 @@
  */
 
 /* Routines for dialog boxes */
-#include <windows.h>
 #include "dlglib.h"
+
 #include "i18n.h"		// for MAX_UIMSG
+#include <windows.h>
+#include <assert.h>
 #include <stdio.h>
 #include <commctrl.h>
 
@@ -360,6 +362,8 @@
 void SetDlgTexts(HWND hDlgWnd, const DlgTextInfo *infos, int infoCount, const char *UILanguageFile)
 {
 	int i;
+	assert(hDlgWnd != NULL);
+	assert(infoCount > 0);
 	for (i = 0 ; i < infoCount; i++) {
 		const char *key = infos[i].key;
 #if 1
@@ -370,7 +374,9 @@
 			if (nIDDlgItem == 0) {
 				SetWindowText(hDlgWnd, uimsg);
 			} else {
-				SetDlgItemText(hDlgWnd, nIDDlgItem, uimsg);
+				BOOL r;
+				r = SetDlgItemText(hDlgWnd, nIDDlgItem, uimsg);
+				assert(r != 0); (void)r;
 			}
 		}
 #else

Modified: branches/cmake/teraterm/common/dlglib.h
===================================================================
--- branches/cmake/teraterm/common/dlglib.h	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/common/dlglib.h	2018-11-03 15:33:07 UTC (rev 7256)
@@ -57,6 +57,9 @@
 				  const char *UILanguageFile, PCHAR key);
 
 ////////////////////////////////////////
+void TTSetDlgFont(const char *face, int height, int charset);
+//void TTSetDlgFont(const wchar_t *face, int height, int charset);
+const wchar_t *TTGetClassName(const DLGTEMPLATE *DlgTempl);
 DLGTEMPLATE *TTGetDlgTemplate(HINSTANCE hInst, LPCSTR lpTemplateName);
 DLGTEMPLATE *TTGetNewDlgTemplate(
 	HINSTANCE hInst, const DLGTEMPLATE *src,

Modified: branches/cmake/teraterm/common/dlglib_tmpl.cpp
===================================================================
--- branches/cmake/teraterm/common/dlglib_tmpl.cpp	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/common/dlglib_tmpl.cpp	2018-11-03 15:33:07 UTC (rev 7256)
@@ -29,12 +29,16 @@
 /* Routines for dialog boxes */
 
 #include "dlglib.h"
-//#include "tttypes.h"		// for TTSet
-//#include "ttwinman.h"		// for ts
 
 #include <wchar.h>
 #include <assert.h>
+#include <crtdbg.h>
 
+#ifdef _DEBUG
+#define malloc(l) _malloc_dbg((l), _NORMAL_BLOCK, __FILE__, __LINE__)
+#define free(p)   _free_dbg((p), _NORMAL_BLOCK, __FILE__, __LINE__)
+#endif
+
 //#define	_countof(ary)	(sizeof(ary)/sizeof(ary[0]))
 
 // https://docs.microsoft.com/ja-jp/windows/desktop/dlgbox/dlgtemplateex
@@ -111,11 +115,13 @@
 {
 	size_t size;
 	if (*src == 0x0000) {
+		// 0x0000 のとき、なにもない
 		if (dest != NULL) {
 			*dest = *src;
 		}
 		size = 1;
 	} else if (*src == 0xffff) {
+		// 0xffff のとき、1WORDのデータ
 		if (dest != NULL) {
 			*dest++ = *src++;
 			*dest++ = *src++;
@@ -122,6 +128,7 @@
 		}
 		size = 2;
 	} else {
+		// 以外はwchar_tの文字列
 		return CopySz(src, dest);
 	}
 	return size;
@@ -370,7 +377,7 @@
 }
 
 static DLGTEMPLATE *GetDlgTemplate(
-	HINSTANCE hInst, const DLGTEMPLATE *src,
+	const DLGTEMPLATE *src,
 	const WCHAR *FontFaceName, LONG FontHeight, BYTE FontCharSet,
 	size_t *PrevTemplSize, size_t *NewTemplSize)
 {
@@ -420,7 +427,7 @@
 	const DLGTEMPLATE *src = (DLGTEMPLATE *)::LockResource(hDlgTemplate);
 
 	DLGTEMPLATE *dest = GetDlgTemplate(
-		hInst, src,
+		src,
 		FontFaceName, FontHeight, FontCharSet,
 		PrevTemplSize, NewTemplSize);
 
@@ -441,7 +448,7 @@
 		FontFaceName[0] = L'\0';
 	}
 	FontHeight = height;
-	FontCharSet = charset;
+	FontCharSet = (BYTE)charset;
 }
 
 void TTSetDlgFont(const char *face, int height, int charset)
@@ -452,38 +459,16 @@
 		FontFaceName[0] = L'\0';
 	}
 	FontHeight = height;
-	FontCharSet = charset;
+	FontCharSet = (BYTE)charset;
 }
 
-#if 0
-static void initFont()
-{
-	LOGFONT logfont;
-	BOOL result;
-	result = GetI18nLogfont("Tera Term", "DLG_TAHOMA_FONT", &logfont, 72, ts.UILanguageFile);
-	if (!result) {
-		result = GetI18nLogfont("Tera Term", "DLG_SYSTEM_FONT", &logfont, 72, ts.UILanguageFile);
-	}
-
-	if (result) {
-		TTSetDlgFont(logfont.lfFaceName, logfont.lfHeight, logfont.lfCharSet);
-	} else {
-		TTSetDlgFont((wchar_t *)NULL, 0, 0);
-	}
-}
-#endif
-static void initFont()
-{
-	TTSetDlgFont(L"MS Pゴシック",12,128);
-}
-
 DLGTEMPLATE *TTGetNewDlgTemplate(
 	HINSTANCE hInst, const DLGTEMPLATE *src,
 	size_t *PrevTemplSize, size_t *NewTemplSize)
 {
-	initFont();
+	(void)hInst;
 	DLGTEMPLATE *DlgTemplate =
-		GetDlgTemplate(hInst, src,
+		GetDlgTemplate(src,
 					   FontFaceName, FontHeight, FontCharSet,
 					   PrevTemplSize, NewTemplSize);
 
@@ -492,7 +477,6 @@
 
 DLGTEMPLATE *TTGetDlgTemplate(HINSTANCE hInst, LPCSTR lpTemplateName)
 {
-	initFont();
 	DLGTEMPLATE *DlgTemplate =
 		GetDlgTemplate(hInst, lpTemplateName,
 					   FontFaceName, FontHeight, FontCharSet,
@@ -499,3 +483,28 @@
 					   NULL, NULL);
 	return DlgTemplate;
 }
+
+/*
+ *	ダイアログテンプレートのクラス名取得
+ *	@retval		クラス文字列
+ *	@retval		NULL クラスなし
+ */
+const wchar_t *TTGetClassName(const DLGTEMPLATE *DlgTempl)
+{
+	const WORD *src = (const WORD *)DlgTempl;
+	if (*src != 1) {
+		// DLGTEMPLATE
+		src += sizeof(DLGTEMPLATE) / sizeof(WORD);
+	} else {
+		// DLGTEMPLATEEX
+		src += sizeof(DLGTEMPLATEEX) / sizeof(WORD);
+	}
+	size_t t = CopySzOrOrd(src, NULL);	// menu
+	src += t;
+
+	if (*src == L'\0') {
+		// no class name
+		return NULL;
+	}
+	return (wchar_t *)src;
+}

Added: branches/cmake/teraterm/common/tmfc.cpp
===================================================================
--- branches/cmake/teraterm/common/tmfc.cpp	                        (rev 0)
+++ branches/cmake/teraterm/common/tmfc.cpp	2018-11-03 15:33:07 UTC (rev 7256)
@@ -0,0 +1,738 @@
+/*
+ * 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 <assert.h>
+#include <tchar.h>
+#include "dlglib.h"
+#include "ttlib.h"
+
+// テンプレートの書き換えを行う
+#define REWRITE_TEMPLATE
+
+#if defined(_MSC_VER) && (_MSC_VER <= 1500)
+#define nullptr NULL	// C++11,nullptr / > VS2010
+#endif
+
+TTCWnd::TTCWnd()
+{
+	m_hWnd = nullptr;
+	m_hInst = nullptr;
+	m_hAccel = nullptr;
+}
+
+LRESULT TTCWnd::SendMessage(UINT msg, WPARAM wp, LPARAM lp)
+{
+	return ::SendMessage(m_hWnd, msg, wp, lp);
+}
+
+HWND TTCWnd::GetDlgItem(int id)
+{
+	return ::GetDlgItem(m_hWnd, id);
+}
+
+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, (int)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(id), BM_SETCHECK, nCheck, 0);
+}
+
+UINT TTCWnd::GetCheck(int id)
+{
+	return ::IsDlgButtonChecked(m_hWnd, id);
+}
+
+void TTCWnd::SetCurSel(int id, int no)
+{
+	HWND hWnd = GetDlgItem(id);
+	assert(hWnd != 0);
+	TCHAR ClassName[32];
+	int r = GetClassName(hWnd, ClassName, _countof(ClassName));
+	assert(r != 0); (void)r;
+	UINT msg = 
+		(_tcscmp(ClassName, _T("ListBox")) == 0) ? LB_SETCURSEL :
+		(_tcscmp(ClassName, _T("ComboBox")) == 0) ? CB_SETCURSEL : 0;
+	assert(msg != 0);
+	::SendMessage(hWnd, msg, no, 0);
+}
+
+int TTCWnd::GetCurSel(int id)
+{
+	HWND hWnd = GetDlgItem(id);
+	assert(hWnd != 0);
+	TCHAR ClassName[32];
+	int r = GetClassName(hWnd, ClassName, _countof(ClassName));
+	assert(r != 0); (void)r;
+	UINT msg = 
+		(_tcscmp(ClassName, _T("ListBox")) == 0) ? LB_GETCURSEL :
+		(_tcscmp(ClassName, _T("ComboBox")) == 0) ? CB_GETCURSEL : 0;
+	assert(msg != 0);
+	LRESULT lResult = ::SendMessage(hWnd, msg, 0, 0);
+	return (int)lResult;
+}
+
+void TTCWnd::EnableDlgItem(int id, BOOL enable)
+{
+	::EnableWindow(GetDlgItem(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(const TCHAR *str)
+{
+	::SetWindowText(m_hWnd, str);
+}
+
+LONG_PTR TTCWnd::SetWindowLongPtr(int nIndex, LONG_PTR dwNewLong)
+{
+	return ::SetWindowLongPtr(m_hWnd, nIndex, dwNewLong);
+}
+
+LONG_PTR TTCWnd::GetWindowLongPtr(int nIndex)
+{
+	return ::GetWindowLongPtr(m_hWnd, nIndex);
+}
+
+void TTCWnd::ModifyStyleCom(int nStyleOffset,
+							DWORD dwRemove, DWORD dwAdd, UINT nFlags)
+{
+	const LONG_PTR dwStyle = GetWindowLongPtr(nStyleOffset);
+	const LONG_PTR add = dwAdd;
+	const LONG_PTR remove = dwRemove;
+	const LONG_PTR dwNewStyle = (dwStyle & ~remove) | add;
+	if (dwStyle != dwNewStyle) {
+		SetWindowLongPtr(nStyleOffset, dwNewStyle);
+	}
+	if (nFlags != 0)
+	{
+		SetWindowPos(nullptr, 0, 0, 0, 0,
+					 SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | nFlags);
+	}
+}
+
+void TTCWnd::ModifyStyle(DWORD dwRemove, DWORD dwAdd, UINT nFlags)
+{
+	ModifyStyleCom(GWL_STYLE, dwRemove, dwAdd, nFlags);
+}
+
+void TTCWnd::ModifyStyleEx(DWORD dwRemove, DWORD dwAdd, UINT nFlags)
+{
+	ModifyStyleCom(GWL_EXSTYLE, dwRemove, dwAdd, nFlags);
+}
+
+int TTCWnd::MessageBox(LPCTSTR lpText, LPCTSTR lpCaption, UINT uType)
+{
+	return ::MessageBox(m_hWnd, lpText, lpCaption, uType);
+}
+
+BOOL TTCWnd::GetWindowRect(RECT *R)
+{
+	return ::GetWindowRect(m_hWnd, R);
+}
+
+BOOL TTCWnd::SetWindowPos(HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags)
+{
+	return ::SetWindowPos(m_hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags);
+}
+
+BOOL TTCWnd::GetClientRect(RECT *R)
+{
+	return ::GetClientRect(m_hWnd, R);
+}
+
+BOOL TTCWnd::InvalidateRect(RECT *R, BOOL bErase)
+{
+	return ::InvalidateRect(m_hWnd, R, bErase);
+}
+
+BOOL TTCWnd::EndDialog(int nResult)
+{
+	return ::EndDialog(m_hWnd, nResult);
+}
+
+void TTCWnd::DestroyWindow()
+{
+	::DestroyWindow(m_hWnd);
+}
+
+HDC TTCWnd::BeginPaint(LPPAINTSTRUCT lpPaint)
+{
+	return ::BeginPaint(m_hWnd, lpPaint);
+}
+
+BOOL TTCWnd::EndPaint(LPPAINTSTRUCT lpPaint)
+{
+	return ::EndPaint(m_hWnd, lpPaint);
+}
+
+LRESULT TTCWnd::DefWindowProc(UINT msg, WPARAM wParam, LPARAM lParam)
+{
+	return ::DefWindowProc(m_hWnd, msg, wParam, lParam);
+}
+
+////////////////////////////////////////
+
+TTCDialog *TTCDialog::pseudoPtr;
+
+TTCDialog::TTCDialog()
+{
+}
+
+TTCDialog::~TTCDialog()
+{
+}
+
+/**
+ * ダイアログ初期化
+ * @retval	TRUE	処理が行われた(次のメッセージ処理は呼び出されない)
+ * @retval	FALSE	次のメッセージ処理は呼び出される
+ *
+ * 次のメッセージ処理
+ *		TTCDialog::DlgProc(msg=WM_INITDIALOG)
+ */
+BOOL TTCDialog::OnInitDialog()
+{
+	return FALSE;
+}
+
+/**
+ * OKボタン
+ * @retval	TRUE	処理が行われた(次のメッセージ処理は呼び出されない)
+ * @retval	FALSE	次のメッセージ処理は呼び出される
+ *
+ * 次のメッセージ処理
+ *		TTCDialog::OnCommand()
+ */
+BOOL TTCDialog::OnOK()
+{
+	EndDialog(IDOK);
+	return TRUE;
+}
+
+/**
+ * CANCELボタン
+ * @retval	TRUE	処理が行われた(次のメッセージ処理は呼び出されない)
+ * @retval	FALSE	次のメッセージ処理は呼び出される
+ *
+ * 次のメッセージ処理
+ *		TTCDialog::OnCommand()
+ */
+BOOL TTCDialog::OnCancel()
+{
+	EndDialog(IDCANCEL);
+	return TRUE;
+}
+
+BOOL TTCDialog::OnCommand(WPARAM wp, LPARAM lp)
+{
+	return FALSE;
+}
+
+/**
+ * WM_CLOSEメッセージ処理
+ * @retval	TRUE	処理が行われた(次のメッセージ処理は呼び出されない)
+ * @retval	FALSE	次のメッセージ処理は呼び出される
+ *
+ * 次のメッセージ処理
+ *		TTCDialog::OnCancel()
+ */
+BOOL TTCDialog::OnClose()
+{
+	return FALSE;
+}
+
+/**
+ * WM_NCDESTROYメッセージ処理
+ * @retval	TRUE	処理が行われた(次のメッセージ処理は呼び出されない)
+ * @retval	FALSE	次のメッセージ処理は呼び出される
+ *
+ * 次のメッセージ処理
+ *		TTCDialog::DlgProc()
+ */
+BOOL TTCDialog::PostNcDestroy()
+{
+	return FALSE;
+}
+
+/*
+ * @retval	TRUE	メッセージを処理した時
+ * @retval	FALSE	メッセージを処理しなかった時
+ * @retval	その他	メッセージによって異なることがある
+ */
+LRESULT TTCDialog::DlgProc(UINT msg, WPARAM wp, LPARAM lp)
+{
+	(void)msg;
+	(void)wp;
+	(void)lp;
+	return (LRESULT)FALSE;
+}
+
+/*
+ * @retval	TRUE	メッセージを処理した時
+ * @retval	FALSE	メッセージを処理しなかった時
+ */
+LRESULT TTCDialog::DlgProcBase(UINT msg, WPARAM wp, LPARAM lp)
+{
+	BOOL Processed = FALSE;
+	switch (msg) {
+	case WM_INITDIALOG:
+		Processed = OnInitDialog();
+		break;
+	case WM_COMMAND:
+	{
+		const WORD wID = GET_WM_COMMAND_ID(wp, lp);
+		switch (wID) {
+		case IDOK:
+			Processed = OnOK();
+			//self->DestroyWindow();
+			//SetWindowLong(hwndDlg, DWL_MSGRESULT, lResult)
+			// return TRUE
+			break;
+		case IDCANCEL:
+			Processed = OnCancel();
+			break;
+		}
+
+		if (Processed == FALSE) {
+			Processed = OnCommand(wp, lp);
+		}
+		break;
+	}
+	case WM_NCDESTROY:
+		Processed = PostNcDestroy();
+		break;
+	case WM_CLOSE:
+		// CLOSEボタンを押した時、
+		Processed = OnClose();
+		if (Processed == FALSE) {
+			//	オーバーライドされていなければ
+			//	dialogならOnCancel()が発生する
+			Processed = OnCancel();
+		}
+		break;
+	default:
+		Processed = FALSE;
+		break;
+	}
+
+	if (Processed == TRUE) {
+		// 処理した
+		return TRUE;
+	}
+
+	// 最後のメッセージ処理
+	return DlgProc(msg, wp, lp);
+}
+
+LRESULT TTCDialog::WndProcBase(UINT msg, WPARAM wp, LPARAM lp)
+{
+	BOOL Processed = FALSE;
+	switch (msg) {
+	case WM_INITDIALOG:
+		Processed = OnInitDialog();
+		break;
+	case WM_COMMAND:
+	{
+		const WORD wID = GET_WM_COMMAND_ID(wp, lp);
+		switch (wID) {
+		case IDOK:
+			Processed = OnOK();
+			//self->DestroyWindow();
+			//SetWindowLong(hwndDlg, DWL_MSGRESULT, lResult)
+			// return TRUE
+			break;
+		case IDCANCEL:
+			Processed = OnCancel();
+			break;
+		}
+
+		if (Processed == FALSE) {
+			Processed = OnCommand(wp, lp);
+		}
+		break;
+	}
+	case WM_NCDESTROY:
+		Processed = PostNcDestroy();
+		break;
+	case WM_CLOSE:
+		// CLOSEボタンを押した時、
+		Processed = OnClose();
+		if (Processed == FALSE) {
+			//	オーバーライドされていなければ
+			//	dialogならOnCancel()が発生する
+			Processed = OnCancel();
+		}
+		break;
+	default:
+		Processed = FALSE;
+		break;
+	}
+
+	if (Processed == TRUE) {
+		// 処理した
+		return TRUE;
+	}
+
+	// DlgProcをオーバライドするのではなく、
+	// DefWindowProcをオーバーライドすること
+	return DefWindowProc(msg, wp, lp);
+}
+
+/**
+ * for modal dialog
+ */
+INT_PTR TTCDialog::DoModal(HINSTANCE hInstance, HWND hParent, int idd)
+{
+	pseudoPtr = this;
+#if defined(REWRITE_TEMPLATE)
+	INT_PTR result = 
+		TTDialogBoxParam(hInstance,
+						 MAKEINTRESOURCE(idd),
+						 hParent,
+						 (DLGPROC)&DlgProcStub, (LPARAM)this);
+#else
+	INT_PTR result = 
+		DialogBoxParam(hInstance,
+					   MAKEINTRESOURCE(idd),
+					   hParent,
+					   (DLGPROC)&DlgProcStub, (LPARAM)this);
+#endif	
+	pseudoPtr = nullptr;
+	return result;
+}
+
+/**
+ * for modeless dialog
+ */
+BOOL TTCDialog::Create(HINSTANCE hInstance, HWND hParent, int idd)
+{
+#if defined(REWRITE_TEMPLATE)
+	DLGTEMPLATE *lpTemplate = TTGetDlgTemplate(hInstance, MAKEINTRESOURCE(idd));
+#else
+	HRSRC hResource = ::FindResource(hInstance, MAKEINTRESOURCE(idd), RT_DIALOG);
+	HANDLE hDlgTemplate = ::LoadResource(hInstance, hResource);
+	DLGTEMPLATE *lpTemplate = (DLGTEMPLATE *)::LockResource(hDlgTemplate);
+#endif
+	DLGPROC dlgproc = (DLGPROC)DlgProcStub;
+	const wchar_t *dialog_class = TTGetClassName(lpTemplate);
+	if (dialog_class != nullptr) {
+		// Modaless Dialog & Dialog application
+		//  WNDCLASS.lpfnWndProc = TTCDialog::WndProcBase
+		dlgproc = nullptr;
+	}
+	pseudoPtr = this;
+	HWND hWnd = ::CreateDialogIndirectParam(
+		hInstance, lpTemplate, hParent,
+		dlgproc, (LPARAM)this);
+	pseudoPtr = nullptr;
+	if (hWnd == nullptr)
+	{
+#if defined(_DEBUG)
+		DWORD e = GetLastError();
+#endif
+		assert(false);
+		return FALSE;
+	}
+
+	m_hParentWnd = hParent;
+	m_hWnd = hWnd;
+	m_hInst = hInstance;
+//	::EnableWindow(hParent,FALSE);
+//	::ShowWindow(hWnd, SW_SHOW);		// TODO 外でやるのが良さそう
+//	::EnableWindow(m_hWnd,TRUE);
+
+	return TRUE;
+}
+
+/*
+ * @retval	TRUE	メッセージを処理した時
+ * @retval	FALSE	メッセージを処理しなかった時
+ */
+LRESULT CALLBACK TTCDialog::DlgProcStub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
+{
+	TTCDialog *self = (TTCDialog *)::GetWindowLongPtr(hWnd, DWLP_USER);
+	if (self == nullptr) {
+		self = pseudoPtr;
+		self->m_hWnd = hWnd;
+		if (msg == WM_INITDIALOG) {
+			::SetWindowLongPtr(hWnd, DWLP_USER, (LONG_PTR)self);
+			pseudoPtr = nullptr;
+		}
+	}
+	assert(self != nullptr);
+
+	LRESULT result = self->DlgProcBase(msg, wp, lp);
+	return result;
+}
+
+/*
+ * @retval	TRUE	メッセージを処理した時
+ * @retval	FALSE	メッセージを処理しなかった時
+ */
+LRESULT CALLBACK TTCDialog::WndProcStub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
+{
+	TTCDialog *self = (TTCDialog *)::GetWindowLongPtr(hWnd, GWLP_USERDATA);
+	if (self == nullptr) {
+		assert(pseudoPtr != nullptr);
+		self = pseudoPtr;
+		self->m_hWnd = hWnd;
+		if (msg == WM_CREATE) {
+			::SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)self);
+			pseudoPtr = nullptr;
+		}
+	}
+	assert(self != nullptr);
+
+	return self->WndProcBase(msg, wp, lp);
+}
+
+void TTCDialog::DestroyWindow()
+{
+	if (m_hWnd != nullptr) {
+		::EnableWindow(m_hParentWnd,TRUE);
+		::SetFocus(m_hParentWnd);
+		::DestroyWindow(m_hWnd);
+		m_hWnd = nullptr;
+	}
+}
+
+////////////////////////////////////////
+
+// 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 defined(REWRITE_TEMPLATE)
+	m_psp.dwFlags |= PSP_DLGINDIRECT;
+	m_psp.pResource = TTGetDlgTemplate(inst, m_psp.pszTemplate);
+#endif
+//	m_psp.pfnDlgProc = (DLGPROC)Proc;
+	m_psp.pfnDlgProc = 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;
+}
+
+INT_PTR 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 (INT_PTR)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
+	if (pszCaption != nullptr) {
+		m_psh.pszCaption = pszCaption;
+		//m_psh.dwFlags |= PSH_PROPTITLE;		// 「のプロパティー」が追加される?
+	}
+	m_psh.hwndParent = hParentWnd;
+	m_psh.pfnCallback = PropSheetProc;
+}
+	
+TTCPropertySheet::~TTCPropertySheet()
+{
+}
+
+INT_PTR 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, nullptr, nullptr, nullptr);
+		if (quit) {
+			// QM_QUIT
+			PostQuitMessage(0);
+			return IDCANCEL;
+		}
+		if ((hDlgWnd == Msg.hwnd) ||
+			::SendMessage(hDlgWnd, PSM_ISDIALOGMESSAGE, nullptr, (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:
+	{
+#if defined(REWRITE_TEMPLATE)
+		// テンプレートの内容を書き換える 危険
+		// 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);
+#endif
+		break;
+	}
+	case PSCB_INITIALIZED:
+	{
+		//TTCPropertySheet *self = (TTCPropertySheet *)lp;
+		TTCPropertySheet *self = gTTCPS;
+		self->m_hWnd = hWnd;
+		self->OnInitDialog();
+		break;
+	}
+	}
+	return 0;
+}
+
+void TTCPropertySheet::OnInitDialog()
+{
+}

Copied: branches/cmake/teraterm/common/tmfc.h (from rev 7255, branches/cmake/teraterm/teraterm/tmfc.h)
===================================================================
--- branches/cmake/teraterm/common/tmfc.h	                        (rev 0)
+++ branches/cmake/teraterm/common/tmfc.h	2018-11-03 15:33:07 UTC (rev 7256)
@@ -0,0 +1,164 @@
+/*
+ * 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;
+	HACCEL m_hAccel;
+
+	TTCWnd();
+	void DestroyWindow();
+	HWND GetSafeHwnd() const {return m_hWnd;}
+	HWND GetSafeHwnd() { return m_hWnd; }
+	HDC BeginPaint(LPPAINTSTRUCT lpPaint);
+	BOOL EndPaint(LPPAINTSTRUCT lpPaint);
+	LRESULT SendMessage(UINT msg, WPARAM wp, LPARAM lp);
+	void ShowWindow(int nCmdShow);
+	void SetWindowText(const TCHAR *str);
+	LONG_PTR SetWindowLongPtr(int nIndex, LONG_PTR dwNewLong);
+	LONG_PTR GetWindowLongPtr(int nIndex);
+	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);
+	virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
+	BOOL GetWindowRect(RECT *R);
+	BOOL SetWindowPos(HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags);
+	BOOL GetClientRect(RECT *R);
+	BOOL InvalidateRect(RECT *R, BOOL bErase = TRUE);
+	BOOL EndDialog(int nResult);
+	// for controls
+	HWND GetDlgItem(int id);
+	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 SetDlgItemInt(int id, UINT val, BOOL bSigned = TRUE);
+	UINT GetDlgItemInt(int id, BOOL* lpTrans = NULL, BOOL bSigned = TRUE) const;
+	void EnableDlgItem(int id, BOOL enable);
+private:
+	void ModifyStyleCom(int nStyleOffset, DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0);
+};
+
+class TTCFrameWnd : public TTCWnd
+{
+public:
+	TTCFrameWnd();
+	virtual ~TTCFrameWnd();
+	static TTCFrameWnd *pseudoPtr;
+	static LRESULT CALLBACK ProcStub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
+	virtual BOOL Create(HINSTANCE hInstance,
+						LPCTSTR lpszClassName,
+						LPCTSTR lpszWindowName,
+						DWORD dwStyle = WS_OVERLAPPEDWINDOW,
+						const RECT& rect = rectDefault,
+						HWND pParentWnd = NULL,        // != NULL for popups
+						LPCTSTR lpszMenuName = NULL,
+						DWORD dwExStyle = 0);//,
+						//CCreateContext* pContext = NULL);
+	virtual LRESULT Proc(UINT msg, WPARAM wp, LPARAM lp);
+	static const RECT rectDefault;
+	///
+	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
+	///
+#if 1
+	void OnKillFocus(HWND hNewWnd);
+	void OnDestroy();
+	void OnSetFocus(HWND hOldWnd);
+	void OnSysCommand(UINT nID, LPARAM lParam);
+	void OnClose();
+#endif
+	void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
+	void OnSysKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
+};
+
+class TTCDialog : public TTCWnd
+{
+public:
+	TTCDialog();
+	virtual ~TTCDialog();
+	BOOL Create(HINSTANCE hInstance, HWND hParent, int idd);
+	INT_PTR DoModal(HINSTANCE hInstance, HWND hParent, int idd);
+	void DestroyWindow();
+	virtual BOOL OnInitDialog();
+	virtual	BOOL OnOK();
+	virtual BOOL OnCancel();
+	virtual BOOL OnCommand(WPARAM wp, LPARAM lp);
+	virtual BOOL OnClose();
+	virtual BOOL PostNcDestroy();
+	virtual LRESULT DlgProc(UINT msg, WPARAM wp, LPARAM lp);
+	HWND m_hParentWnd;
+
+	static LRESULT CALLBACK DlgProcStub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
+	static LRESULT CALLBACK WndProcStub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
+private:
+
+	LRESULT DlgProcBase(UINT msg, WPARAM wp, LPARAM lp);
+	LRESULT WndProcBase(UINT msg, WPARAM wp, LPARAM lp);
+	static TTCDialog *pseudoPtr;
+};
+
+class TTCPropertySheet
+{
+public:
+	TTCPropertySheet(HINSTANCE hInstance, LPCTSTR pszCaption, HWND hParentWnd);
+	virtual ~TTCPropertySheet();
+	virtual void OnInitDialog();
+	INT_PTR 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 INT_PTR CALLBACK Proc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp);
+	static UINT CALLBACK PropSheetPageProc(HWND hwnd, UINT uMsg, LPPROPSHEETPAGE ppsp);
+	TTCPropertySheet *m_pSheet;
+};
+

Added: branches/cmake/teraterm/common/tmfc_frame.cpp
===================================================================
--- branches/cmake/teraterm/common/tmfc_frame.cpp	                        (rev 0)
+++ branches/cmake/teraterm/common/tmfc_frame.cpp	2018-11-03 15:33:07 UTC (rev 7256)
@@ -0,0 +1,134 @@
+/*
+ * 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 "ttlib.h"
+
+#if defined(_MSC_VER) && (_MSC_VER <= 1500)
+#define nullptr NULL	// C++11,nullptr / > VS2010
+#endif
+
+const RECT TTCFrameWnd::rectDefault =
+{
+	CW_USEDEFAULT, CW_USEDEFAULT,
+//	2*CW_USEDEFAULT, 2*CW_USEDEFAULTg
+	0, 0
+};
+
+TTCFrameWnd::TTCFrameWnd()
+{
+}
+
+TTCFrameWnd::~TTCFrameWnd()
+{
+}
+
+BOOL TTCFrameWnd::Create(
+	HINSTANCE hInstance,
+	LPCTSTR lpszClassName,
+	LPCTSTR lpszWindowName,
+	DWORD dwStyle,
+	const RECT& rect,
+	HWND hParentWnd,
+	LPCTSTR lpszMenuName,
+	DWORD dwExStyle)
+{
+	pseudoPtr = this;
+	HWND hWnd = ::CreateWindowExA(
+		0,
+		lpszClassName,
+		lpszWindowName,
+		dwStyle,
+		rect.left, rect.top,
+		rect.right - rect.left, rect.bottom - rect.top,
+		hParentWnd,
+		nullptr,
+		hInstance,
+		nullptr);
+	pseudoPtr = nullptr;
+	if (hWnd == nullptr) {
+		OutputDebugPrintf("CreateWindow %d\n", GetLastError());
+		return FALSE;
+	} else {
+		m_hWnd = hWnd;
+		SetWindowLongPtr(GWLP_USERDATA, (LONG_PTR)this);
+		return TRUE;
+	}
+}
+
+TTCFrameWnd *TTCFrameWnd::pseudoPtr;
+
+LRESULT TTCFrameWnd::ProcStub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
+{
+	TTCFrameWnd *self;
+	if (pseudoPtr != nullptr) {
+		self = pseudoPtr;
+		self->m_hWnd = hWnd;
+	} else {
+		self = (TTCFrameWnd *)::GetWindowLongPtr(hWnd, GWLP_USERDATA);
+	}
+	return self->Proc(msg, wp, lp);
+}
+
+LRESULT TTCFrameWnd::Proc(UINT msg, WPARAM wp, LPARAM lp)
+{
+	return DefWindowProc(msg, wp, lp);
+}
+
+BOOL TTCFrameWnd::OnCommand(WPARAM wParam, LPARAM lParam)
+{
+	return FALSE;
+}
+
+void TTCFrameWnd::OnKillFocus(HWND hNewWnd)
+{}
+
+void TTCFrameWnd::OnDestroy()
+{}
+
+void TTCFrameWnd::OnSetFocus(HWND hOldWnd)
+{}
+
+void TTCFrameWnd::OnSysCommand(UINT nID, LPARAM lParam)
+{}
+
+void TTCFrameWnd::OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
+{
+	TTCFrameWnd::Proc(WM_SYSKEYDOWN, (WPARAM)nChar, MAKELONG(nRepCnt, nFlags));
+}
+
+void TTCFrameWnd::OnSysKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
+{
+	TTCFrameWnd::Proc(WM_SYSKEYUP, (WPARAM)nChar, MAKELONG(nRepCnt, nFlags));
+}
+
+void TTCFrameWnd::OnClose()
+{}

Modified: branches/cmake/teraterm/keycode/CMakeLists.txt
===================================================================
--- branches/cmake/teraterm/keycode/CMakeLists.txt	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/keycode/CMakeLists.txt	2018-11-03 15:33:07 UTC (rev 7256)
@@ -34,4 +34,5 @@
 
 target_link_libraries(
   keycode
+  gdi32
   )

Modified: branches/cmake/teraterm/teraterm/CMakeLists.txt
===================================================================
--- branches/cmake/teraterm/teraterm/CMakeLists.txt	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/teraterm/CMakeLists.txt	2018-11-03 15:33:07 UTC (rev 7256)
@@ -33,6 +33,9 @@
   ../common/dlglib_tmpl.cpp
   ../common/compat_win.cpp
   ../common/compat_win.h
+  ../common/tmfc.cpp
+  ../common/tmfc.h
+  ../common/tmfc_frame.cpp
   )
 
 source_group(
@@ -42,10 +45,6 @@
   )
 
 set(SRC
-  tmfc.h
-  tmfc.cpp
-  tmfc_frame.cpp
-  #
   addsetting.cpp
   addsetting.h
   buffer.c
@@ -160,13 +159,17 @@
   ttpset
   ttptek
 #  ttpdlg
-  optimized onig.lib
-  debug onigd.lib
-  Comctl32.lib
-  ws2_32.lib
-  imm32.lib
-  imagehlp.lib
-  delayimp.lib
+  optimized onig
+  debug onigd
+  #
+  gdi32
+  comctl32
+  ws2_32
+  imm32
+  imagehlp
+  delayimp
+  oleaut32
+  uuid
   )
 
 add_dependencies(

Modified: branches/cmake/teraterm/teraterm/WSAAsyncGetAddrInfo.c
===================================================================
--- branches/cmake/teraterm/teraterm/WSAAsyncGetAddrInfo.c	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/teraterm/WSAAsyncGetAddrInfo.c	2018-11-03 15:33:07 UTC (rev 7256)
@@ -31,11 +31,22 @@
  */
 #include <winsock2.h>
 #include <ws2tcpip.h>
+#include <wspiapi.h>
 #include <windows.h>
 #include <process.h>
-#include "WSAASyncGetAddrInfo.h"
+#include "WSAAsyncGetAddrInfo.h"
 #include "ttwsk.h"
 
+struct getaddrinfo_args {
+	HWND hWnd;
+	unsigned int wMsg;
+	char *hostname;
+	char *portname;
+	struct addrinfo hints;
+	struct addrinfo **res;
+	HANDLE *lpHandle;
+};
+
 static unsigned __stdcall getaddrinfo_thread(void * p);
 
 HANDLE WINAPI WSAAsyncGetAddrInfo(HWND hWnd, unsigned int wMsg,

Modified: branches/cmake/teraterm/teraterm/WSAAsyncGetAddrInfo.h
===================================================================
--- branches/cmake/teraterm/teraterm/WSAAsyncGetAddrInfo.h	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/teraterm/WSAAsyncGetAddrInfo.h	2018-11-03 15:33:07 UTC (rev 7256)
@@ -36,16 +36,6 @@
 #include <winsock2.h>
 #include <ws2tcpip.h>
 
-struct getaddrinfo_args {
-  HWND hWnd;
-  unsigned int wMsg;
-  char *hostname;
-  char *portname;
-  struct addrinfo hints;
-  struct addrinfo **res;
-  HANDLE *lpHandle;
-};
-
 HANDLE WINAPI WSAAsyncGetAddrInfo(HWND hWnd,
 			   unsigned int wMsg,
 			   const char *hostname,

Modified: branches/cmake/teraterm/teraterm/addsetting.cpp
===================================================================
--- branches/cmake/teraterm/teraterm/addsetting.cpp	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/teraterm/addsetting.cpp	2018-11-03 15:33:07 UTC (rev 7256)
@@ -32,7 +32,7 @@
 
 #include <stdio.h>
 #include <tchar.h>
-#include <Windows.h>
+#include <windows.h>
 #include <commctrl.h>
 #include <time.h>
 
@@ -694,12 +694,12 @@
 	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);
+		SendDlgItemMessage(IDC_MOUSE_CURSOR, CB_ADDSTRING, i, (LPARAM)name);
 		if (_tcscmp(name, ts.MouseCursorName) == 0) {
 			sel = i;
 		}
 	}
-	SendDlgItemMessage(IDC_MOUSE_CURSOR, LB_SETCURSEL, sel, 0);
+	SetCurSel(IDC_MOUSE_CURSOR, sel);
 
 	// (4)Font quality
 	switch (ts.FontQuality) {
@@ -724,7 +724,7 @@
 	}
 	SetupRGBbox(GetSafeHwnd(), 0);
 	SendDlgItemMessage(IDC_ANSI_COLOR, LB_SETCURSEL, 0, 0);
-	InvalidateRect(GetDlgItem(m_hWnd, IDC_SAMPLE_COLOR), NULL, TRUE);
+	::InvalidateRect(GetDlgItem(IDC_SAMPLE_COLOR), NULL, TRUE);
 
 	// (6)Bold Attr Color
 	SetCheck(IDC_ENABLE_ATTR_COLOR_BOLD, (ts.ColorFlag&CF_BOLDCOLOR) != 0);
@@ -745,7 +745,7 @@
 	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_ACTIVE));
+	::SetFocus(GetDlgItem(IDC_ALPHA_BLEND_ACTIVE));
 }
 
 BOOL CVisualPropPageDlg::OnCommand(WPARAM wParam, LPARAM lParam)
@@ -835,7 +835,7 @@
 			sel = SendDlgItemMessage(IDC_ANSI_COLOR, LB_GETCURSEL, 0, 0);
 			if (sel != -1) {
 				SetupRGBbox(GetSafeHwnd(), sel);
-				InvalidateRect(GetDlgItem(m_hWnd, IDC_SAMPLE_COLOR), NULL, TRUE);
+				::InvalidateRect(GetDlgItem(IDC_SAMPLE_COLOR), NULL, TRUE);
 			}
 			return TRUE;
 
@@ -865,7 +865,7 @@
 				// 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);
 
-				InvalidateRect(GetDlgItem(m_hWnd, IDC_SAMPLE_COLOR), NULL, TRUE);
+				::InvalidateRect(GetDlgItem(IDC_SAMPLE_COLOR), NULL, TRUE);
 			}
 
 			return TRUE;
@@ -876,7 +876,7 @@
 
 HBRUSH CVisualPropPageDlg::OnCtlColor(HDC hDC, HWND hWnd)
 {
-	if ( hWnd == GetDlgItem(m_hWnd, IDC_SAMPLE_COLOR) ) {
+	if ( hWnd == GetDlgItem(IDC_SAMPLE_COLOR) ) {
 		BYTE r, g, b;
 		char buf[8];
 
@@ -942,7 +942,7 @@
 	}
 
 	// (3)
-	sel = SendDlgItemMessage(IDC_MOUSE_CURSOR, LB_GETCURSEL, 0, 0);
+	sel = GetCurSel(IDC_MOUSE_CURSOR);
 	if (sel >= 0 && sel < MOUSE_CURSOR_MAX) {
 		strncpy_s(ts.MouseCursorName, sizeof(ts.MouseCursorName), MouseCursor[sel].name, _TRUNCATE);
 	}

Modified: branches/cmake/teraterm/teraterm/ftdlg.cpp
===================================================================
--- branches/cmake/teraterm/teraterm/ftdlg.cpp	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/teraterm/ftdlg.cpp	2018-11-03 15:33:07 UTC (rev 7256)
@@ -30,7 +30,7 @@
 /* TERATERM.EXE, file transfer dialog box */
 #include <stdio.h>
 #include <windows.h>
-#include <Commctrl.h>
+#include <commctrl.h>
 #include "teraterm.h"
 #include "tttypes.h"
 #include "ttftypes.h"
@@ -55,7 +55,7 @@
 	ts = pts;
 
 	wc.style = CS_PARENTDC;
-	wc.lpfnWndProc = TTCDialog::ProcStub;
+	wc.lpfnWndProc = TTCDialog::WndProcStub;
 	wc.cbClsExtra = 0;
 	wc.cbWndExtra = DLGWINDOWEXTRA;
 	wc.hInstance = hInstance;
@@ -158,7 +158,7 @@
 /////////////////////////////////////////////////////////////////////////////
 // CFileTransDlg message handler
 
-void CFileTransDlg::OnInitDialog()
+BOOL CFileTransDlg::OnInitDialog()
 {
 	static const DlgTextInfo TextInfos[] = {
 		{ IDC_TRANS_FILENAME, "DLG_FILETRANS_FILENAME" },
@@ -203,11 +203,13 @@
 						IMAGE_ICON, 0, 0, fuLoad);
 	::PostMessage(GetSafeHwnd(), WM_SETICON, ICON_BIG,
 				  (LPARAM)BigIcon);
+	return TRUE;
 }
 
-void CFileTransDlg::OnCancel( )
+BOOL CFileTransDlg::OnCancel( )
 {
 	::PostMessage(fv->HMainWin,WM_USER_FTCANCEL,fv->OpId,0);
+	return TRUE;
 }
 
 BOOL CFileTransDlg::OnCommand(WPARAM wParam, LPARAM lParam)
@@ -227,7 +229,7 @@
 	}
 }
 
-void CFileTransDlg::PostNcDestroy()
+BOOL 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
 	//   - 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
@@ -243,4 +245,5 @@
 	}
 
 	delete this;
+	return TRUE;
 }

Modified: branches/cmake/teraterm/teraterm/ftdlg.h
===================================================================
--- branches/cmake/teraterm/teraterm/ftdlg.h	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/teraterm/ftdlg.h	2018-11-03 15:33:07 UTC (rev 7256)
@@ -49,10 +49,10 @@
 	enum { IDD = IDD_FILETRANSDLG };
 
 protected:
-	virtual void OnCancel();
+	virtual BOOL OnCancel();
 	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
-	virtual void PostNcDestroy();
-	virtual void OnInitDialog();
+	virtual BOOL PostNcDestroy();
+	virtual BOOL OnInitDialog();
 
 private:
 	PFileVar fv;

Modified: branches/cmake/teraterm/teraterm/prnabort.cpp
===================================================================
--- branches/cmake/teraterm/teraterm/prnabort.cpp	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/teraterm/prnabort.cpp	2018-11-03 15:33:07 UTC (rev 7256)
@@ -55,7 +55,7 @@
 	return TRUE;
 }
 
-void CPrnAbortDlg::OnInitDialog()
+BOOL CPrnAbortDlg::OnInitDialog()
 {
 	TTCDialog::OnInitDialog();
 
@@ -64,17 +64,17 @@
 		{ IDCANCEL, "BTN_CANCEL" },
 	};
 	SetDlgTexts(m_hWnd, TextInfos, _countof(TextInfos), m_ts->UILanguageFile);
+	return TRUE;
 }
 
-void CPrnAbortDlg::OnCancel()
+BOOL CPrnAbortDlg::OnCancel()
 {
 	*m_pAbort = TRUE;
-	TTCDialog::OnCancel();
+	return TTCDialog::OnCancel();
 }
 
-#if 0
-void CPrnAbortDlg::PostNcDestroy()
+BOOL CPrnAbortDlg::PostNcDestroy()
 {
-	TTCDialog::DestroyWindow();
+	delete this;
+	return TRUE;
 }
-#endif

Modified: branches/cmake/teraterm/teraterm/prnabort.h
===================================================================
--- branches/cmake/teraterm/teraterm/prnabort.h	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/teraterm/prnabort.h	2018-11-03 15:33:07 UTC (rev 7256)
@@ -40,9 +40,9 @@
 	CPrnAbortDlg();
 	~CPrnAbortDlg();
 	BOOL Create(HINSTANCE hInstance, HWND hParent, PBOOL AbortFlag, PTTSet pts);
-	void OnCancel();
-	void OnInitDialog();
-//	void PostNcDestroy();
+	BOOL OnCancel();
+	BOOL OnInitDialog();
+	BOOL PostNcDestroy();
 
 private:
 	BOOL *m_pAbort;

Modified: branches/cmake/teraterm/teraterm/protodlg.cpp
===================================================================
--- branches/cmake/teraterm/teraterm/protodlg.cpp	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/teraterm/protodlg.cpp	2018-11-03 15:33:07 UTC (rev 7256)
@@ -59,7 +59,7 @@
 /////////////////////////////////////////////////////////////////////////////
 // CProtoDlg message handler
 
-void CProtoDlg::OnInitDialog()
+BOOL CProtoDlg::OnInitDialog()
 {
 	static const DlgTextInfo TextInfos[] = {
 		{ IDC_PROT_FILENAME, "DLG_PROT_FILENAME" },
@@ -70,12 +70,14 @@
 		{ IDCANCEL, "BTN_CANCEL" },
 	};
 	SetDlgTexts(m_hWnd, TextInfos, _countof(TextInfos), m_pts->UILanguageFile);
+	return TRUE;
 }
 
 
-void CProtoDlg::OnCancel()
+BOOL CProtoDlg::OnCancel()
 {
 	::PostMessage(fv->HMainWin,WM_USER_PROTOCANCEL,0,0);
+	return TRUE;
 }
 
 BOOL CProtoDlg::OnCommand(WPARAM wParam, LPARAM lParam)
@@ -89,7 +91,8 @@
 	}
 }
 
-void CProtoDlg::PostNcDestroy()
+BOOL CProtoDlg::PostNcDestroy()
 {
 	delete this;
+	return TRUE;
 }

Modified: branches/cmake/teraterm/teraterm/protodlg.h
===================================================================
--- branches/cmake/teraterm/teraterm/protodlg.h	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/teraterm/protodlg.h	2018-11-03 15:33:07 UTC (rev 7256)
@@ -40,10 +40,10 @@
 
 	enum { IDD = IDD_PROTDLG };
 protected:
-	virtual void OnCancel( );
+	virtual BOOL OnCancel();
 	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
-	virtual void OnInitDialog();
-	virtual void PostNcDestroy();
+	virtual BOOL OnInitDialog();
+	virtual BOOL PostNcDestroy();
 private:
 	PFileVar fv;
 	TTTSet *m_pts;

Modified: branches/cmake/teraterm/teraterm/tekwin.cpp
===================================================================
--- branches/cmake/teraterm/teraterm/tekwin.cpp	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/teraterm/tekwin.cpp	2018-11-03 15:33:07 UTC (rev 7256)
@@ -702,7 +702,7 @@
 	DWORD Style;
 	HMENU SysMenu;
 
-	Style = GetWindowLong (HTEKWin, GWL_STYLE);
+	Style = GetWindowLongPtr (GWL_STYLE);
 	TBar = ((Style & WS_SYSMENU)!=0);
 	if (TBar == (ts.HideTitle==0)) {
 		return 0;
@@ -715,7 +715,7 @@
 		Style = Style & ~WS_POPUP | WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX;
 	}
 	tk.AdjustSize = TRUE;
-	SetWindowLong (HTEKWin, GWL_STYLE, Style);
+	SetWindowLongPtr (GWL_STYLE, Style);
 	::SetWindowPos (HTEKWin, NULL, 0, 0, 0, 0,
 	                SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
 	::ShowWindow (HTEKWin, SW_SHOW);

Modified: branches/cmake/teraterm/teraterm/teraterm.cpp
===================================================================
--- branches/cmake/teraterm/teraterm/teraterm.cpp	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/teraterm/teraterm.cpp	2018-11-03 15:33:07 UTC (rev 7256)
@@ -29,6 +29,7 @@
 
 /* TERATERM.EXE, main */
 
+#include <crtdbg.h>
 #include "teraterm.h"
 #include "tttypes.h"
 #include "commlib.h"
@@ -46,6 +47,7 @@
 #include "keyboard.h"
 #include "compat_win.h"
 #include "compat_w95.h"
+#include "dlglib.h"
 
 static void init()
 {
@@ -206,9 +208,61 @@
 	return OnIdle(lCount);
 }
 
+HINSTANCE GetInstance()
+{
+	return hInst;
+}
+
+static HWND main_window;
+HWND GetHWND()
+{
+	return main_window;
+}
+
+static void SetDialogFont()
+{
+	LOGFONT logfont;
+	BOOL result;
+	result = GetI18nLogfont("Tera Term", "DLG_FONT", &logfont, 72, ts.UILanguageFile);
+	if (result == FALSE) {
+		NONCLIENTMETRICSA ncm = {sizeof ncm};
+		result = SystemParametersInfoA(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0);
+		if (result == TRUE) {
+			logfont = ncm.lfMessageFont;
+		}
+	}
+	if (result == FALSE) {
+		result = GetI18nLogfont("Tera Term", "DLG_TAHOMA_FONT", &logfont, 72, ts.UILanguageFile);
+		if (result == FALSE) {
+			result = GetI18nLogfont("Tera Term", "DLG_SYSTEM_FONT", &logfont, 72, ts.UILanguageFile);
+		}
+	}
+
+#if 0
+	TTSetDlgFont(L"MS Shell Dlg2", 8, 128);
+	TTSetDlgFont(L"MS Shell Dlg", 8, 128);
+	TTSetDlgFont(L"Yu Gothic UI",12,128);	// windows 10
+	TTSetDlgFont(L"Meiryo UI",12,128);		// Windows 7,8
+	TTSetDlgFont(L"\x83\x81\x83C\x83\x8A\x83I",10,128);
+	TTSetDlgFont(L"MS UI Gothic",10,128);
+	TTSetDlgFont(L"\x82l\x82r \x82o\x83S\x83V\x83b\x83N",12,128);
+	TTSetDlgFont(L"Segoe UI",10,128);
+#endif
+
+	if (result) {
+		TTSetDlgFont(logfont.lfFaceName, logfont.lfHeight, logfont.lfCharSet);
+	} else {
+		TTSetDlgFont(NULL, 0, 0);
+	}
+}
+
 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst,
                    LPSTR lpszCmdLine, int nCmdShow)
 {
+#ifdef _DEBUG
+	::_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
+#endif
+
 	LONG lCount = 0;
 	DWORD SleepTick = 1;
 	init();
@@ -215,7 +269,9 @@
 	hInst = hInstance;
 	CVTWindow *m_pMainWnd = new CVTWindow();
 	pVTWin = m_pMainWnd;
+	main_window = m_pMainWnd->m_hWnd;
 	ShowWindow(m_pMainWnd->m_hWnd, nCmdShow);
+	SetDialogFont();
 
 	MSG msg;
 	while (GetMessage(&msg, NULL, 0, 0)) {
@@ -252,5 +308,8 @@
 			}
 		}
 	}
-    return (msg.wParam);
+	delete m_pMainWnd;
+	m_pMainWnd = NULL;
+
+    return msg.wParam;
 }

Deleted: branches/cmake/teraterm/teraterm/tmfc.cpp
===================================================================
--- branches/cmake/teraterm/teraterm/tmfc.cpp	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/teraterm/tmfc.cpp	2018-11-03 15:33:07 UTC (rev 7256)
@@ -1,448 +0,0 @@
-/*
- * 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 <assert.h>
-#include "dlglib.h"
-
-TTCWnd::TTCWnd()
-{
-	m_hWnd = NULL;
-	m_hInst = NULL;
-	m_hAccel = NULL;
-}
-
-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(const 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
-	pseudoPtr = this;
-	HWND hWnd = ::CreateDialogIndirectParam(	
-		hInstance, lpTemplate, hParent,
-		(DLGPROC)OnDlgProc, (LPARAM)this);
-	pseudoPtr = NULL;
-	if (hWnd == NULL)
-	{
-#if defined(_DEBUG)
-		DWORD e = GetLastError();
-#endif
-		assert(false);
-		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;
-}
-
-TTCDialog *TTCDialog::pseudoPtr;
-
-LRESULT CALLBACK TTCDialog::ProcStub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
-{
-	TTCDialog *self;
-	if (pseudoPtr != NULL) {
-		self = pseudoPtr;
-		self->m_hWnd = hWnd;
-	} else {
-		self = (TTCDialog *)GetWindowLongPtr(hWnd, DWLP_USER);
-	}
-
-	LRESULT result = self->OnDlgProc(hWnd, msg, wp, lp);
-	if (result == FALSE) {
-		result = ::DefWindowProc(hWnd, msg, wp, lp);
-	}
-	return result;
-}
-
-////////////////////////////////////////
-
-// 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
-	if (pszCaption != NULL) {
-		m_psh.pszCaption = pszCaption;
-		//m_psh.dwFlags |= PSH_PROPTITLE;		// 「のプロパティー」が追加される?
-	}
-	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()
-{
-}

Deleted: branches/cmake/teraterm/teraterm/tmfc.h
===================================================================
--- branches/cmake/teraterm/teraterm/tmfc.h	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/teraterm/tmfc.h	2018-11-03 15:33:07 UTC (rev 7256)
@@ -1,149 +0,0 @@
-/*
- * 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;
-	HACCEL m_hAccel;
-
-	TTCWnd();
-	void DestroyWindow();
-	HWND GetSafeHwnd() const {return m_hWnd;}
-	HWND GetSafeHwnd() { return m_hWnd; }
-	HDC BeginPaint(LPPAINTSTRUCT lpPaint);
-	BOOL EndPaint(LPPAINTSTRUCT lpPaint);
-	virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
-	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(const 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 TTCFrameWnd : public TTCWnd
-{
-public:
-	TTCFrameWnd();
-	virtual ~TTCFrameWnd();
-	static TTCFrameWnd *pseudoPtr;
-	static LRESULT CALLBACK ProcStub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
-	virtual BOOL Create(HINSTANCE hInstance,
-						LPCTSTR lpszClassName,
-						LPCTSTR lpszWindowName,
-						DWORD dwStyle = WS_OVERLAPPEDWINDOW,
-						const RECT& rect = rectDefault,
-						HWND pParentWnd = NULL,        // != NULL for popups
-						LPCTSTR lpszMenuName = NULL,
-						DWORD dwExStyle = 0);//,
-						//CCreateContext* pContext = NULL);
-	virtual LRESULT Proc(UINT msg, WPARAM wp, LPARAM lp);
-	static const RECT rectDefault;
-	///
-	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
-	///
-#if 1
-	void OnKillFocus(HWND hNewWnd);
-	void OnDestroy();
-	void OnSetFocus(HWND hOldWnd);
-	void OnSysCommand(UINT nID, LPARAM lParam);
-	void OnClose();
-#endif
-	void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
-	void OnSysKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
-};
-
-class TTCDialog : public TTCWnd
-{
-public:
-	TTCDialog();
-	virtual ~TTCDialog();
-	static TTCDialog *pseudoPtr;
-	static LRESULT CALLBACK ProcStub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
-	BOOL Create(HINSTANCE hInstance, HWND hParent, int idd);
-	void DestroyWindow();
-	virtual void OnInitDialog();
-	virtual	void OnOK();
-	virtual void OnCancel();
-	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;
-};
-

Deleted: branches/cmake/teraterm/teraterm/tmfc_frame.cpp
===================================================================
--- branches/cmake/teraterm/teraterm/tmfc_frame.cpp	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/teraterm/tmfc_frame.cpp	2018-11-03 15:33:07 UTC (rev 7256)
@@ -1,123 +0,0 @@
-
-#include "tmfc.h"
-#include "ttlib.h"
-
-const RECT TTCFrameWnd::rectDefault =
-{
-	CW_USEDEFAULT, CW_USEDEFAULT,
-//	2*CW_USEDEFAULT, 2*CW_USEDEFAULT
-	0, 0
-};
-
-TTCFrameWnd::TTCFrameWnd()
-{
-}
-
-TTCFrameWnd::~TTCFrameWnd()
-{
-}
-
-BOOL TTCFrameWnd::Create(
-	HINSTANCE hInstance,
-	LPCTSTR lpszClassName,
-	LPCTSTR lpszWindowName,
-	DWORD dwStyle,
-	const RECT& rect,
-	HWND hParentWnd,
-	LPCTSTR lpszMenuName,
-	DWORD dwExStyle)
-{
-	pseudoPtr = this;
-	HWND hWnd = ::CreateWindowExA(
-		0,
-		lpszClassName,
-		lpszWindowName,
-		dwStyle,
-		rect.left, rect.top,
-		rect.right - rect.left, rect.bottom - rect.top,
-		hParentWnd,
-		NULL,
-		hInstance,
-		NULL);
-	pseudoPtr = NULL;
-	if (hWnd == NULL) {
-		OutputDebugPrintf("CreateWindow %d\n", GetLastError());
-		return FALSE;
-	} else {
-		m_hWnd = hWnd;
-		SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)this);
-		return TRUE;
-	}
-}
-
-TTCFrameWnd *TTCFrameWnd::pseudoPtr;
-
-LRESULT TTCFrameWnd::ProcStub(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
-{
-	TTCFrameWnd *self;
-	if (pseudoPtr != NULL) {
-		self = pseudoPtr;
-		self->m_hWnd = hWnd;
-	} else {
-		self = (TTCFrameWnd *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
-	}
-	return self->Proc(msg, wp, lp);
-}
-
-LRESULT TTCFrameWnd::Proc(UINT msg, WPARAM wp, LPARAM lp)
-{
-	return DefWindowProc(msg, wp, lp);
-}
-
-BOOL TTCFrameWnd::OnCommand(WPARAM wParam, LPARAM lParam)
-{
-	return FALSE;
-}
-
-void TTCFrameWnd::OnKillFocus(HWND hNewWnd)
-{}
-
-void TTCFrameWnd::OnDestroy()
-{}
-
-void TTCFrameWnd::OnSetFocus(HWND hOldWnd)
-{}
-
-void TTCFrameWnd::OnSysCommand(UINT nID, LPARAM lParam)
-{}
-
-void TTCFrameWnd::OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
-{
-	TTCFrameWnd::Proc(WM_SYSKEYDOWN, (WPARAM)nChar, MAKELONG(nRepCnt, nFlags));
-}
-
-void TTCFrameWnd::OnSysKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
-{
-	TTCFrameWnd::Proc(WM_SYSKEYUP, (WPARAM)nChar, MAKELONG(nRepCnt, nFlags));
-}
-
-void TTCFrameWnd::OnClose()
-{}
-
-
-////////////////////////////////////////
-
-void TTCWnd::DestroyWindow()
-{
-	::DestroyWindow(m_hWnd);
-}
-
-HDC TTCWnd::BeginPaint(LPPAINTSTRUCT lpPaint)
-{
-	return ::BeginPaint(m_hWnd, lpPaint);
-}
-
-BOOL TTCWnd::EndPaint(LPPAINTSTRUCT lpPaint)
-{
-	return ::EndPaint(m_hWnd, lpPaint);
-}
-
-LRESULT TTCWnd::DefWindowProc(UINT msg, WPARAM wParam, LPARAM lParam)
-{
-	return ::DefWindowProc(m_hWnd, msg, wParam, lParam);
-}

Modified: branches/cmake/teraterm/teraterm/ttdde.c
===================================================================
--- branches/cmake/teraterm/teraterm/ttdde.c	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/teraterm/ttdde.c	2018-11-03 15:33:07 UTC (rev 7256)
@@ -68,7 +68,7 @@
 static HSZ Item2 = 0;
 static HWND HWndDdeCli = NULL;
 
-static StartupFlag = FALSE;
+static BOOL StartupFlag = FALSE;
 
 // for sync mode
 static BOOL SyncMode = FALSE;
@@ -335,8 +335,77 @@
 	return w;
 }
 
-HDDEDATA AcceptExecute(HSZ TopicHSz, HDDEDATA Data)
+#if defined(_MSC_VER) && (_MSC_VER == 1400)
+#define inline
+#endif
+inline static void Debug(char c)
 {
+	OutputDebugPrintf("%s\n",
+		c == CmdSetHWnd ? "CmdSetHWnd" :
+		c == CmdSetFile ? "CmdSetFile" :
+		c == CmdSetBinary ? "CmdSetBinary" :
+		c == CmdSetLogOpt ? "CmdSetLogOpt" :
+		c == CmdSetXmodemOpt ? "CmdSetXmodemOpt" :
+		c == CmdSetSync ? "CmdSetSync" :
+		c == CmdBPlusRecv ? "CmdBPlusRecv" :
+		c == CmdBPlusSend ? "CmdBPlusSend" :
+		c == CmdChangeDir ? "CmdChangeDir" :
+		c == CmdClearScreen ? "CmdClearScreen" :
+		c == CmdCloseWin ? "CmdCloseWin" :
+		c == CmdConnect ? "CmdConnect" :
+		c == CmdDisconnect ? "CmdDisconnect" :
+		c == CmdEnableKeyb ? "CmdEnableKeyb" :
+		c == CmdGetTitle ? "CmdGetTitle" :
+		c == CmdInit ? "CmdInit" :
+		c == CmdKmtFinish ? "CmdKmtFinish" :
+		c == CmdKmtGet ? "CmdKmtGet" :
+		c == CmdKmtRecv ? "CmdKmtRecv" :
+		c == CmdKmtSend ? "CmdKmtSend" :
+		c == CmdLoadKeyMap ? "CmdLoadKeyMap" :
+		c == CmdLogClose ? "CmdLogClose" :
+		c == CmdLogOpen ? "CmdLogOpen" :
+		c == CmdLogPause ? "CmdLogPause" :
+		c == CmdLogStart ? "CmdLogStart" :
+		c == CmdLogWrite ? "CmdLogWrite" :
+		c == CmdQVRecv ? "CmdQVRecv" :
+		c == CmdQVSend ? "CmdQVSend" :
+		c == CmdRestoreSetup ? "CmdRestoreSetup" :
+		c == CmdSendBreak ? "CmdSendBreak" :
+		c == CmdSendFile ? "CmdSendFile" :
+		c == CmdSendKCode ? "CmdSendKCode" :
+		c == CmdSetEcho ? "CmdSetEcho" :
+		c == CmdSetTitle ? "CmdSetTitle" :
+		c == CmdShowTT ? "CmdShowTT" :
+		c == CmdXmodemSend ? "CmdXmodemSend" :
+		c == CmdXmodemRecv ? "CmdXmodemRecv" :
+		c == CmdZmodemSend ? "CmdZmodemSend" :
+		c == CmdZmodemRecv ? "CmdZmodemRecv" :
+		c == CmdCallMenu ? "CmdCallMenu" :
+		c == CmdScpSend ? "CmdScpSend" :
+		c == CmdScpRcv ? "CmdScpRcv" :
+		c == CmdSetSecondFile ? "CmdSetSecondFile" :
+		c == CmdSetBaud ? "CmdSetBaud" :
+		c == CmdSetRts ? "CmdSetRts" :
+		c == CmdSetDtr ? "CmdSetDtr" :
+		c == CmdGetHostname ? "CmdGetHostname" :
+		c == CmdSendBroadcast ? "CmdSendBroadcast" :
+		c == CmdSendMulticast ? "CmdSendMulticast" :
+		c == CmdSetMulticastName ? "CmdSetMulticastName" :
+		c == CmdSetDebug ? "CmdSetDebug" :
+		c == CmdYmodemSend ? "CmdYmodemSend" :
+		c == CmdYmodemRecv ? "CmdYmodemRecv" :
+		c == CmdDispStr ? "CmdDispStr" :
+		c == CmdLogInfo ? "CmdLogInfo" :
+		c == CmdLogRotate ? "CmdLogRotate" :
+		c == CmdLogAutoClose ? "CmdLogAutoClose" :
+		c == CmdGetModemStatus ? "CmdGetModemStatus" :
+		c == CmdSetFlowCtrl ? "CmdSetFlowCtrl" :
+		"unknown"
+		);
+}
+
+static HDDEDATA AcceptExecute(HSZ TopicHSz, HDDEDATA Data)
+{
 	char Command[MaxStrLen + 1];
 	int i;
 	WORD w, c;
@@ -348,6 +417,7 @@
 		(DdeGetData(Data,Command,sizeof(Command),0) == 0))
 		return DDE_FNOTPROCESSED;
 
+	Debug(Command[0]);
 	switch (Command[0]) {
 	case CmdSetHWnd:
 		GetClientHWnd(&Command[1]);
@@ -1000,9 +1070,10 @@
 	return (HDDEDATA)DDE_FACK;
 }
 
-HDDEDATA CALLBACK DdeCallbackProc(UINT CallType, UINT Fmt, HCONV Conv,
-                                  HSZ HSz1, HSZ HSz2, HDDEDATA Data,
-                                  DWORD Data1, DWORD Data2)
+static HDDEDATA CALLBACK DdeCallbackProc(
+	UINT CallType, UINT Fmt, HCONV Conv,
+	HSZ HSz1, HSZ HSz2, HDDEDATA Data,
+	DWORD Data1, DWORD Data2)
 {
 	HDDEDATA Result;
 

Modified: branches/cmake/teraterm/teraterm/ttermpro.rc
===================================================================
--- branches/cmake/teraterm/teraterm/ttermpro.rc	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/teraterm/ttermpro.rc	2018-11-03 15:33:07 UTC (rev 7256)
@@ -51,9 +51,9 @@
                     "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,188,236,10
     CONTROL         "Do not d&isplay this dialog, next drop",IDC_DONTSHOW_CHECK,
                     "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,7,203,236,11
-    DEFPUSHBUTTON   "OK",IDOK,133,236,50,14
+    LTEXT           "Drop with CTRL, this dialog is displayed",IDC_DAD_NOTE,7,221,236,8
+    DEFPUSHBUTTON   "OK",IDOK,138,236,50,14
     PUSHBUTTON      "Cancel",IDCANCEL,193,236,50,14
-    LTEXT           "Drop with CTRL, this dialog is displayed",IDC_DAD_NOTE,7,221,236,8
 END
 
 IDD_COMMENT_DIALOG DIALOGEX 0, 0, 239, 19

Modified: branches/cmake/teraterm/teraterm/vtterm.c
===================================================================
--- branches/cmake/teraterm/teraterm/vtterm.c	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/teraterm/vtterm.c	2018-11-03 15:33:07 UTC (rev 7256)
@@ -36,6 +36,7 @@
 #include <mbstring.h>
 #include <locale.h>
 #include <ctype.h>
+#include <crtdbg.h>
 
 #include "buffer.h"
 #include "ttwinman.h"
@@ -53,6 +54,14 @@
 
 #include "vtterm.h"
 
+#ifdef _DEBUG
+#define malloc(l)     _malloc_dbg((l), _NORMAL_BLOCK, __FILE__, __LINE__)
+#define realloc(p, l) _realloc_dbg((p), (l), _NORMAL_BLOCK, __FILE__, __LINE__)
+#define free(p)       _free_dbg((p), _NORMAL_BLOCK, __FILE__, __LINE__)
+#define strdup(s)	  _strdup_dbg((s), _NORMAL_BLOCK, __FILE__, __LINE__)
+#define _strdup(s)	  _strdup_dbg((s), _NORMAL_BLOCK, __FILE__, __LINE__)
+#endif
+
 void ParseFirst(BYTE b);
 
 #define MAPSIZE(x) (sizeof(x)/sizeof((x)[0]))

Modified: branches/cmake/teraterm/teraterm/vtwin.cpp
===================================================================
--- branches/cmake/teraterm/teraterm/vtwin.cpp	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/teraterm/vtwin.cpp	2018-11-03 15:33:07 UTC (rev 7256)
@@ -71,7 +71,7 @@
 
 #include <windowsx.h>
 #include <imm.h>
-#include <Dbt.h>
+#include <dbt.h>
 
 #include "tt_res.h"
 #include "vtwin.h"
@@ -266,34 +266,6 @@
 	return hInst;
 }
 
-static BOOL MySetLayeredWindowAttributes(HWND hwnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags)
-{
-	typedef BOOL (WINAPI *func)(HWND,COLORREF,BYTE,DWORD);
-	static HMODULE g_hmodUser32 = NULL;
-	static func g_pSetLayeredWindowAttributes = NULL;
-	char user32_dll[MAX_PATH];
-
-	GetSystemDirectory(user32_dll, sizeof(user32_dll));
-	strncat_s(user32_dll, sizeof(user32_dll), "\\user32.dll", _TRUNCATE);
-	if (g_hmodUser32 == NULL) {
-		g_hmodUser32 = LoadLibrary(user32_dll);
-		if (g_hmodUser32 == NULL) {
-			return FALSE;
-		}
-
-		g_pSetLayeredWindowAttributes =
-			(func)GetProcAddress(g_hmodUser32, "SetLayeredWindowAttributes");
-	}
-
-	if (g_pSetLayeredWindowAttributes == NULL) {
-		return FALSE;
-	}
-
-	return g_pSetLayeredWindowAttributes(hwnd, crKey,
-	                                     bAlpha, dwFlags);
-}
-
-
 // Tera Term\x8BN\x93\xAE\x8E\x9E\x82\xC6URL\x95\xB6\x8E\x9A\x97\xF1mouse over\x8E\x9E\x82ɌĂ΂\xEA\x82\xE9 (2005.4.2 yutaka)
 static void SetMouseCursor(const char *cursor)
 {
@@ -330,7 +302,7 @@
 	if (Alpha == alpha) {
 		return;	// \x95ω\xBB\x82Ȃ\xB5\x82Ȃ牽\x82\xE0\x82\xB5\x82Ȃ\xA2
 	}
-	LONG_PTR lp = GetWindowLongPtr(HVTWin, GWL_EXSTYLE);
+	LONG_PTR lp = GetWindowLongPtr(GWL_EXSTYLE);
 	if (lp == 0) {
 		return;
 	}
@@ -340,12 +312,12 @@
 	// \x83A\x83\x8B\x83t\x83@\x92l\x82\xAA255\x82̏ꍇ\x81A\x89\xE6\x96ʂ̂\xBF\x82\xE7\x82‚\xAB\x82\xF0\x97}\x82\xA6\x82邽\x82߉\xBD\x82\xE0\x82\xB5\x82Ȃ\xA2\x82\xB1\x82ƂƂ\xB7\x82\xE9\x81B(2006.4.1 yutaka)
 	// \x8CĂяo\x82\xB5\x8C\xB3\x82ŁA\x92l\x82\xAA\x95ύX\x82\xB3\x82ꂽ\x82Ƃ\xAB\x82̂ݐݒ\xE8\x82𔽉f\x82\xB7\x82\xE9\x81B(2007.10.19 maya)
 	if (alpha < 255) {
-		SetWindowLongPtr(HVTWin, GWL_EXSTYLE, lp | WS_EX_LAYERED);
+		::SetWindowLongPtr(HVTWin, GWL_EXSTYLE, lp | WS_EX_LAYERED);
 		pSetLayeredWindowAttributes(HVTWin, 0, alpha, LWA_ALPHA);
 	}
 	else {
 		// \x83A\x83\x8B\x83t\x83@\x92l\x82\xAA 255 \x82̏ꍇ\x81A\x93\xA7\x96\xBE\x89\xBB\x91\xAE\x90\xAB\x82\xF0\x8D폜\x82\xB5\x82čĕ`\x89悷\x82\xE9\x81B(2007.10.22 maya)
-		SetWindowLongPtr(HVTWin, GWL_EXSTYLE, lp & ~WS_EX_LAYERED);
+		::SetWindowLongPtr(HVTWin, GWL_EXSTYLE, lp & ~WS_EX_LAYERED);
 		::RedrawWindow(HVTWin, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME);
 	}
 	Alpha = alpha;
@@ -434,6 +406,7 @@
 #undef EXCEPTION
 }
 
+#if !defined(_M_X64)
 /* \x97\xE1\x8AO\x94\xAD\x90\xB6\x8E\x9E\x82Ɋ֐\x94\x82̌Ăяo\x82\xB5\x97\x9A\x97\xF0\x82\xF0\x95\\x8E\xA6\x82\xB7\x82\xE9\x81A\x97\xE1\x8AO\x83t\x83B\x83\x8B\x83^\x8A֐\x94 */
 static LONG CALLBACK ApplicationFaultHandler(EXCEPTION_POINTERS *ExInfo)
 {
@@ -585,6 +558,7 @@
 //	return (EXCEPTION_EXECUTE_HANDLER);  /* \x82\xBB\x82̂܂܃v\x83\x8D\x83Z\x83X\x82\xF0\x8FI\x97\xB9\x82\xB3\x82\xB9\x82\xE9 */
 	return (EXCEPTION_CONTINUE_SEARCH);  /* \x88\xF8\x82\xAB\x91\xB1\x82\xAB\x81m\x83A\x83v\x83\x8A\x83P\x81[\x83V\x83\x87\x83\x93\x83G\x83\x89\x81[\x81n\x83|\x83b\x83v\x83A\x83b\x83v\x83\x81\x83b\x83Z\x81[\x83W\x83{\x83b\x83N\x83X\x82\xF0\x8CĂяo\x82\xB7 */
 }
+#endif // !defined(_M_X64 )
 
 
 // Virtual Store\x82\xAA\x97L\x8C\xF8\x82ł\xA0\x82邩\x82ǂ\xA4\x82\xA9\x82𔻕ʂ\xB7\x82\xE9\x81B
@@ -688,10 +662,6 @@
 	int fuLoad = LR_DEFAULTCOLOR;
 	BOOL isFirstInstance;
 
-#ifdef _DEBUG
-	::_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
-#endif
-
 	// \x97\xE1\x8AO\x83n\x83\x93\x83h\x83\x89\x82̃t\x83b\x83N (2007.9.30 yutaka)
 #if !defined(_M_X64)
 	SetUnhandledExceptionFilter(ApplicationFaultHandler);
@@ -861,9 +831,9 @@
 #ifdef ALPHABLEND_TYPE2
 //<!--by AKASI
 	if(BGNoFrame && ts.HideTitle > 0) {
-		ExStyle  = GetWindowLong(HVTWin,GWL_EXSTYLE);
+		ExStyle  = ::GetWindowLong(HVTWin,GWL_EXSTYLE);
 		ExStyle &= ~WS_EX_CLIENTEDGE;
-		SetWindowLong(HVTWin,GWL_EXSTYLE,ExStyle);
+		::SetWindowLong(HVTWin,GWL_EXSTYLE,ExStyle);
 	}
 //-->
 #endif
@@ -3529,8 +3499,8 @@
 	DWORD Style,ExStyle;
 	HMENU SysMenu;
 
-	Style = GetWindowLong (HVTWin, GWL_STYLE);
-	ExStyle = GetWindowLong (HVTWin, GWL_EXSTYLE);
+	Style = ::GetWindowLongPtr (HVTWin, GWL_STYLE);
+	ExStyle = ::GetWindowLongPtr (HVTWin, GWL_EXSTYLE);
 	TBar = ((Style & WS_SYSMENU)!=0);
 	if (TBar == (ts.HideTitle==0)) {
 		return 0;
@@ -3566,9 +3536,9 @@
 #endif
 
 	AdjustSize = TRUE;
-	SetWindowLong(HVTWin, GWL_STYLE, Style);
+	::SetWindowLong(HVTWin, GWL_STYLE, Style);
 #ifdef ALPHABLEND_TYPE2
-	SetWindowLong(HVTWin, GWL_EXSTYLE, ExStyle);
+	::SetWindowLong(HVTWin, GWL_EXSTYLE, ExStyle);
 #endif
 	::SetWindowPos(HVTWin, NULL, 0, 0, 0, 0,
 	               SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);

Modified: branches/cmake/teraterm/teraterm/winjump.c
===================================================================
--- branches/cmake/teraterm/teraterm/winjump.c	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/teraterm/winjump.c	2018-11-03 15:33:07 UTC (rev 7256)
@@ -51,11 +51,18 @@
 #include <stdio.h>
 #include <string.h>
 #include <shlobj.h>
+#include <crtdbg.h>
 
 #include "winjump.h"
 #include "teraterm.h"
 #include "tttypes.h"
 
+#ifdef _DEBUG
+#define malloc(l)	_malloc_dbg((l), _NORMAL_BLOCK, __FILE__, __LINE__)
+#define free(p)		_free_dbg((p), _NORMAL_BLOCK)
+#define _strdup(s)	_strdup_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)
+#endif
+
 #define MAX_JUMPLIST_ITEMS 30 /* PuTTY will never show more items in
                                * the jumplist than this, regardless of
                                * user preferences. */
@@ -385,9 +392,11 @@
     0x000214ee, 0x0000, 0x0000, {0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}
 };
 #endif
+#if __MINGW64_VERSION_MAJOR < 7
 static const IID IID_ICustomDestinationList = {
     0x6332debf, 0x87b5, 0x4670, {0x90,0xc0,0x5e,0x57,0xb4,0x08,0xa4,0x9e}
 };
+#endif
 #if !defined(__MINGW32__)
 static const IID IID_IObjectArray = {
     0x92ca9dcd, 0x5622, 0x4bba, {0xa8,0x05,0x5e,0x9f,0x54,0x1b,0xd8,0xc9}

Modified: branches/cmake/teraterm/ttpcmn/CMakeLists.txt
===================================================================
--- branches/cmake/teraterm/ttpcmn/CMakeLists.txt	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/ttpcmn/CMakeLists.txt	2018-11-03 15:33:07 UTC (rev 7256)
@@ -54,7 +54,7 @@
 	${CMAKE_CURRENT_SOURCE_DIR}/../htmlhelp
 	)
 endif()
-
+  
 add_library(
   ttpcmn
   SHARED
@@ -75,6 +75,7 @@
 
 target_link_libraries(
   ttpcmn
-  setupapi.lib
-  htmlhelp.lib
+  ole32
+  setupapi
+  htmlhelp
   )

Modified: branches/cmake/teraterm/ttpdlg/ttdlg.c
===================================================================
--- branches/cmake/teraterm/ttpdlg/ttdlg.c	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/ttpdlg/ttdlg.c	2018-11-03 15:33:07 UTC (rev 7256)
@@ -36,7 +36,7 @@
 #include <io.h>
 #include <direct.h>
 #include <commdlg.h>
-#include <Dlgs.h>
+#include <dlgs.h>
 #include "teraterm.h"
 #include "tttypes.h"
 #include "ttlib.h"

Modified: branches/cmake/teraterm/ttpfile/CMakeLists.txt
===================================================================
--- branches/cmake/teraterm/ttpfile/CMakeLists.txt	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/ttpfile/CMakeLists.txt	2018-11-03 15:33:07 UTC (rev 7256)
@@ -76,6 +76,9 @@
 target_link_libraries(
   ttpfile
   ttpcmn
+  #
+  gdi32
+  comdlg32
   )
 
 add_dependencies(

Modified: branches/cmake/teraterm/ttpfile/quickvan.c
===================================================================
--- branches/cmake/teraterm/ttpfile/quickvan.c	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/ttpfile/quickvan.c	2018-11-03 15:33:07 UTC (rev 7256)
@@ -34,8 +34,8 @@
 #include <stdio.h>
 #include <string.h>
 #include <time.h>
-#include <sys\utime.h>
-#include <sys\stat.h>
+#include <sys/utime.h>
+#include <sys/stat.h>
 
 #include "tt_res.h"
 #include "dlglib.h"

Modified: branches/cmake/teraterm/ttpmacro/CMakeLists.txt
===================================================================
--- branches/cmake/teraterm/ttpmacro/CMakeLists.txt	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/ttpmacro/CMakeLists.txt	2018-11-03 15:33:07 UTC (rev 7256)
@@ -21,6 +21,16 @@
   ../common/i18n.h
   ../common/ttlib.c
   ../common/ttlib.h
+  ../common/tmfc.cpp
+  ../common/tmfc.h
+  ../common/tmfc_frame.cpp
+  ../common/dlglib.h
+  ../common/dlglib.c
+  ../common/dlglib_tmpl.cpp
+  ../common/dlglib_cpp.cpp
+  ../common/compat_w95.h
+  ../common/compat_win.h
+  ../common/compat_win.cpp
   )
 
 source_group(
@@ -30,6 +40,8 @@
   )
 
 set(SRC
+  #
+  ttm_res.h
   errdlg.cpp
   errdlg.h
   inpdlg.cpp
@@ -40,7 +52,6 @@
   msgdlg.h
   statdlg.cpp
   statdlg.h
-  stdafx.h
   ttl.c
   ttl.h
   ttm_res.h
@@ -83,12 +94,16 @@
 
 set(CMAKE_MFC_FLAG 1)
 
-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")
-if (${MSVC})
+if (MSVC)
   set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:iphlpapi.dll /DELAYLOAD:user32.dll")
 endif()
 
+if(MINGW)
+  link_directories(
+	${CMAKE_CURRENT_SOURCE_DIR}/../htmlhelp
+	)
+endif()
+
 add_executable(
   ttpmacro WIN32
   ${SRC}
@@ -97,16 +112,17 @@
 target_link_libraries(
   ttpmacro
   ttpcmn
-  optimized nafxcw.lib
-  debug nafxcwd.lib
-  optimized LIBCMT.lib
-  debug LIBCMTD.lib
-  optimized onig.lib
-  debug onigd.lib
-  optimized sfmt.lib
-  debug sfmtd.lib
-  iphlpapi.lib
-  delayimp.lib
+  optimized onig
+  debug onigd
+  optimized sfmt
+  debug sfmtd
+  #
+  iphlpapi
+  delayimp
+  ws2_32
+  comctl32
+  gdi32
+  comdlg32
   )
 
 add_dependencies(

Modified: branches/cmake/teraterm/ttpmacro/ListDlg.cpp
===================================================================
--- branches/cmake/teraterm/ttpmacro/ListDlg.cpp	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/ttpmacro/ListDlg.cpp	2018-11-03 15:33:07 UTC (rev 7256)
@@ -29,23 +29,23 @@
 // ListDlg.cpp : \x8E\xC0\x91\x95\x83t\x83@\x83C\x83\x8B
 //
 
-#include "stdafx.h"
+#include "tmfc.h"
 #include "teraterm.h"
 #include "ttlib.h"
 #include "ttm_res.h"
 #include "ttmlib.h"
 #include "tttypes.h"
+#include "dlglib.h"
+#include "ttmdlg.h"
 
-#include "stdafx.h"
 #include "ListDlg.h"
 
+extern HINSTANCE GetInstance();
+extern HWND GetHWND();
 
 // CListDlg \x83_\x83C\x83A\x83\x8D\x83O
 
-IMPLEMENT_DYNAMIC(CListDlg, CDialog)
-
 CListDlg::CListDlg(PCHAR Text, PCHAR Caption, CHAR **Lists, int Selected, int x, int y)
-	: CDialog(CListDlg::IDD)
 {
 	m_Text = Text;
 	m_Caption = Caption;
@@ -53,76 +53,41 @@
 	m_Selected = Selected;
 	PosX = x;
 	PosY = y;
-	DlgFont = NULL;
 }
 
-CListDlg::~CListDlg()
+INT_PTR CListDlg::DoModal()
 {
+	HINSTANCE hInst = GetInstance();
+	HWND hWndParent = GetHWND();
+	return TTCDialog::DoModal(hInst, hWndParent, IDD);
 }
 
-void CListDlg::DoDataExchange(CDataExchange* pDX)
-{
-	CDialog::DoDataExchange(pDX);
-	DDX_Control(pDX, IDC_LISTBOX, m_xcList);
-}
-
-
-BEGIN_MESSAGE_MAP(CListDlg, CDialog)
-	ON_BN_CLICKED(IDOK, &CListDlg::OnBnClickedOk)
-	ON_BN_CLICKED(IDCANCEL, &CListDlg::OnBnClickedCancel)
-END_MESSAGE_MAP()
-
-
-// CListDlg \x83\x81\x83b\x83Z\x81[\x83W \x83n\x83\x93\x83h\x83\x89
-
-void CListDlg::OnBnClickedOk()
-{
-	// TODO: \x82\xB1\x82\xB1\x82ɃR\x83\x93\x83g\x83\x8D\x81[\x83\x8B\x92ʒm\x83n\x83\x93\x83h\x83\x89 \x83R\x81[\x83h\x82\xF0\x92lj\xC1\x82\xB5\x82܂\xB7\x81B
-	m_SelectItem = m_xcList.GetCurSel();
-	OnOK();
-}
-
 BOOL CListDlg::OnInitDialog()
 {
+	static const DlgTextInfo TextInfos[] = {
+		{ IDOK, "BTN_YES" },
+		{ IDCANCEL, "BTN_CANCEL" },
+	};
 	char **p;
-	char uimsg[MAX_UIMSG], uimsg2[MAX_UIMSG];
-	LOGFONT logfont;
-	HFONT font, tmpfont;
 	int ListMaxWidth = 0;
 	int ListWidth;
 	int ListCount = 0;
-	CDC *pDC;
-	CFont *pOldFont;
+	HDC DC;
 	RECT R;
 	HDC TmpDC;
 	HWND HList, HOk;
 
-	CDialog::OnInitDialog();
+	SetDlgTexts(m_hWnd, TextInfos, _countof(TextInfos), UILanguageFile);
 
-	// TODO:  \x82\xB1\x82\xB1\x82ɏ\x89\x8A\xFA\x89\xBB\x82\xF0\x92lj\xC1\x82\xB5\x82Ă\xAD\x82\xBE\x82\xB3\x82\xA2
-	font = (HFONT)SendMessage(WM_GETFONT, 0, 0);
-	GetObject(font, sizeof(LOGFONT), &logfont);
-	if (get_lang_font("DLG_SYSTEM_FONT", m_hWnd, &logfont, &DlgFont, UILanguageFile)) {
-		SendDlgItemMessage(IDC_LISTBOX, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_STATIC, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDOK, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDCANCEL, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-	}
+	HList = ::GetDlgItem(m_hWnd, IDC_LISTBOX);
+	DC = ::GetDC(HList);	// \x83\x8A\x83X\x83g\x83{\x83b\x83N\x83X\x82\xF0\x89\xA1\x83X\x83N\x83\x8D\x81[\x83\x8B\x82ł\xAB\x82\xE9\x82悤\x82ɍő啝\x82\xF0\x8E擾
 
-	GetDlgItemText(IDOK, uimsg2, sizeof(uimsg2));
-	get_lang_msg("BTN_OK", uimsg, sizeof(uimsg), uimsg2, UILanguageFile);
-	SetDlgItemText(IDOK, uimsg);
-	GetDlgItemText(IDCANCEL, uimsg2, sizeof(uimsg2));
-	get_lang_msg("BTN_CANCEL", uimsg, sizeof(uimsg), uimsg2, UILanguageFile);
-	SetDlgItemText(IDCANCEL, uimsg);
-
-	pDC = m_xcList.GetDC(); // \x83\x8A\x83X\x83g\x83{\x83b\x83N\x83X\x82\xF0\x89\xA1\x83X\x83N\x83\x8D\x81[\x83\x8B\x82ł\xAB\x82\xE9\x82悤\x82ɍő啝\x82\xF0\x8E擾
-	pOldFont = pDC->SelectObject(m_xcList.GetFont());
-
 	p = m_Lists;
 	while (*p) {
-		m_xcList.InsertString(-1, _T(*p));
-		ListWidth = pDC->GetTextExtent(*p).cx;
+		SIZE size;
+		SendDlgItemMessage(IDC_LISTBOX, LB_ADDSTRING, 0, (LPARAM)(*p));
+		GetTextExtentPoint32(DC, *p, strlen(*p), &size);
+		ListWidth = size.cx;
 		if (ListWidth > ListMaxWidth) {
 			ListMaxWidth = ListWidth;
 		}
@@ -129,35 +94,25 @@
 		ListCount++;
 		p++;
 	}
-	UpdateData(FALSE);
 
-	m_xcList.SetHorizontalExtent(ListMaxWidth + 5);
-	pDC->SelectObject(pOldFont);
-	ReleaseDC(pDC);
+	SendDlgItemMessage(IDC_LISTBOX, LB_SETHORIZONTALEXTENT, (ListMaxWidth + 5), 0);
+	::ReleaseDC(m_hWnd, DC);
 
 	if (m_Selected < 0 || m_Selected >= ListCount) {
 		m_Selected = 0;
 	}
-	m_xcList.SetCurSel(m_Selected);
+	SetCurSel(IDC_LISTBOX, m_Selected);
 
 	// \x96{\x95\xB6\x82ƃ^\x83C\x83g\x83\x8B
-	SetDlgItemText(IDC_STATIC, m_Text);
+	SetDlgItemText(IDC_LISTTEXT, m_Text);
 	SetWindowText(m_Caption);
 
-
-	TmpDC = ::GetDC(GetDlgItem(IDC_STATIC)->GetSafeHwnd());
-	if (DlgFont) {
-		tmpfont = (HFONT)SelectObject(TmpDC, DlgFont);
-	}
+	TmpDC = ::GetDC(GetDlgItem(IDC_LISTTEXT));
 	CalcTextExtent(TmpDC,m_Text,&s);
-	if (DlgFont && tmpfont != NULL) {
-		SelectObject(TmpDC, tmpfont);
-	}
-	::ReleaseDC(GetDlgItem(IDC_STATIC)->GetSafeHwnd(),TmpDC);
+	::ReleaseDC(GetDlgItem(IDC_LISTTEXT), TmpDC);
 	TW = s.cx + s.cx/10;
 	TH = s.cy;
 
-	HList = ::GetDlgItem(GetSafeHwnd(), IDC_LISTBOX);
 	::GetWindowRect(HList,&R);
 	LW = R.right-R.left;
 	LH = R.bottom-R.top;
@@ -172,19 +127,33 @@
 	WH = R.bottom-R.top;
 
 	Relocation(TRUE, WW);
+	BringupWindow(m_hWnd);
 
-	BringupWindow(this->m_hWnd);
+	return TRUE;
+}
 
-	return TRUE;  // return TRUE unless you set the focus to a control
-	// \x97\xE1\x8AO : OCX \x83v\x83\x8D\x83p\x83e\x83B \x83y\x81[\x83W\x82͕K\x82\xB8 FALSE \x82\xF0\x95Ԃ\xB5\x82܂\xB7\x81B
+BOOL CListDlg::OnOK()
+{
+	m_SelectItem = GetCurSel(IDC_LISTBOX);
+	return TTCDialog::OnOK();
 }
 
-void CListDlg::OnBnClickedCancel()
+BOOL CListDlg::OnCancel()
 {
-	// TODO: \x82\xB1\x82\xB1\x82ɃR\x83\x93\x83g\x83\x8D\x81[\x83\x8B\x92ʒm\x83n\x83\x93\x83h\x83\x89 \x83R\x81[\x83h\x82\xF0\x92lj\xC1\x82\xB5\x82܂\xB7\x81B
-	OnCancel();
+	return TTCDialog::OnCancel();
 }
 
+//int MessageBoxHaltScript(HWND hWnd);
+
+BOOL CListDlg::OnClose()
+{
+	int ret = MessageBoxHaltScript(m_hWnd);
+	if (ret == IDYES) {
+		EndDialog(IDCLOSE);
+	}
+	return TRUE;
+}
+
 void CListDlg::Relocation(BOOL is_init, int new_WW)
 {
 	RECT R;
@@ -192,7 +161,7 @@
 	HWND HText, HOk, HCancel, HList;
 	int CW, CH;
 
-	GetClientRect(&R);
+	::GetClientRect(m_hWnd, &R);
 	CW = R.right-R.left;
 	CH = R.bottom-R.top;
 
@@ -216,7 +185,7 @@
 		WW = new_WW;
 	}
 
-	HText = ::GetDlgItem(GetSafeHwnd(), IDC_STATIC);
+	HText = ::GetDlgItem(GetSafeHwnd(), IDC_LISTTEXT);
 	HOk = ::GetDlgItem(GetSafeHwnd(), IDOK);
 	HCancel = ::GetDlgItem(GetSafeHwnd(), IDCANCEL);
 	HList = ::GetDlgItem(GetSafeHwnd(), IDC_LISTBOX);
@@ -227,13 +196,14 @@
 	::MoveWindow(HCancel,14+14+LW,BH*2,BW,BH,TRUE);
 
 	if (PosX<=GetMonitorLeftmost(PosX, PosY)-100) {
-		GetWindowRect(&R);
+		::GetWindowRect(m_hWnd, &R);
 		TmpDC = ::GetDC(GetSafeHwnd());
 		PosX = (GetDeviceCaps(TmpDC,HORZRES)-R.right+R.left) / 2;
 		PosY = (GetDeviceCaps(TmpDC,VERTRES)-R.bottom+R.top) / 2;
 		::ReleaseDC(GetSafeHwnd(),TmpDC);
 	}
-	SetWindowPos(&wndTop,PosX,PosY,WW,WH,0);
+	::SetWindowPos(m_hWnd, HWND_TOP,PosX,PosY,WW,WH,0);
 
-	InvalidateRect(NULL);
+	::InvalidateRect(m_hWnd, NULL, TRUE);
 }
+

Modified: branches/cmake/teraterm/ttpmacro/ListDlg.h
===================================================================
--- branches/cmake/teraterm/ttpmacro/ListDlg.h	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/ttpmacro/ListDlg.h	2018-11-03 15:33:07 UTC (rev 7256)
@@ -26,42 +26,28 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #pragma once
-#include "afxwin.h"
 
-
 // CListDlg \x83_\x83C\x83A\x83\x8D\x83O
-
-class CListDlg : public CDialog
+class CListDlg : public TTCDialog
 {
-	DECLARE_DYNAMIC(CListDlg)
-
 public:
 	CListDlg(PCHAR Text, PCHAR Caption, CHAR **Lists, int Selected, int x, int y);
-	virtual ~CListDlg();
+	INT_PTR DoModal();
+	int m_SelectItem;
 
-// \x83_\x83C\x83A\x83\x8D\x83O \x83f\x81[\x83^
+private:
 	enum { IDD = IDD_LISTDLG };
-
-protected:
 	PCHAR m_Text;
 	PCHAR m_Caption;
 	CHAR **m_Lists;
 	int m_Selected;
-	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV \x83T\x83|\x81[\x83g
 	int PosX, PosY, init_WW, WW, WH, TW, TH, BH, BW, LW, LH;
 	SIZE s;
-	HFONT DlgFont;
 
 	void Relocation(BOOL is_init, int WW);
 
-	DECLARE_MESSAGE_MAP()
-public:
-	CListBox m_xcList;
-	int m_SelectItem;
-public:
-	afx_msg void OnBnClickedOk();
-public:
 	virtual BOOL OnInitDialog();
-public:
-	afx_msg void OnBnClickedCancel();
+	virtual BOOL OnOK();
+	virtual BOOL OnCancel();
+	virtual BOOL OnClose();
 };

Modified: branches/cmake/teraterm/ttpmacro/errdlg.cpp
===================================================================
--- branches/cmake/teraterm/ttpmacro/errdlg.cpp	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/ttpmacro/errdlg.cpp	2018-11-03 15:33:07 UTC (rev 7256)
@@ -29,7 +29,9 @@
 
 /* TTMACRO.EXE, error dialog box */
 
-#include "stdafx.h"
+#include <windowsx.h>
+#include <stdio.h>
+#include "tmfc.h"
 #include "teraterm.h"
 #include "ttlib.h"
 #include "ttm_res.h"
@@ -41,19 +43,16 @@
 #include "errdlg.h"
 #include "ttmlib.h"
 #include "ttmparse.h"
+#include "htmlhelp.h"
+#include "dlglib.h"
 
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
+extern HINSTANCE GetInstance();
+extern HWND GetHWND();
 
 // CErrDlg dialog
+
 CErrDlg::CErrDlg(PCHAR Msg, PCHAR Line, int x, int y, int lineno, int start, int end, PCHAR FileName)
-	: CDialog(CErrDlg::IDD)
 {
-	//{{AFX_DATA_INIT(CErrDlg)
-	//}}AFX_DATA_INIT
 	MsgStr = Msg;
 	LineStr = Line;
 	PosX = x;
@@ -64,44 +63,27 @@
 	MacroFileName = FileName;
 }
 
-BEGIN_MESSAGE_MAP(CErrDlg, CDialog)
-	//{{AFX_MSG_MAP(CErrDlg)
-	//}}AFX_MSG_MAP
-	ON_BN_CLICKED(IDC_MACROERRHELP, &CErrDlg::OnBnClickedMacroerrhelp)
-END_MESSAGE_MAP()
+INT_PTR CErrDlg::DoModal()
+{
+	HINSTANCE hInst = GetInstance();
+	HWND parent = GetHWND();
+	return TTCDialog::DoModal(hInst, parent, CErrDlg::IDD);
+}
 
-// CErrDlg message handler
-
 BOOL CErrDlg::OnInitDialog()
 {
+	static const DlgTextInfo TextInfos[] = {
+		{ IDOK, "BTN_STOP" },
+		{ IDCANCEL, "BTN_CONTINUE" },
+		{ IDC_MACROERRHELP, "BTN_HELP" },
+	};
 	RECT R;
 	HDC TmpDC;
-	char uimsg[MAX_UIMSG], uimsg2[MAX_UIMSG];
-	LOGFONT logfont;
-	HFONT font;
 	char buf[MaxLineLen*2], buf2[10];
 	int i, len;
 
-	CDialog::OnInitDialog();
-	font = (HFONT)SendMessage(WM_GETFONT, 0, 0);
-	GetObject(font, sizeof(LOGFONT), &logfont);
-	if (get_lang_font("DLG_SYSTEM_FONT", m_hWnd, &logfont, &DlgFont, UILanguageFile)) {
-		SendDlgItemMessage(IDC_ERRMSG, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_ERRLINE, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDOK, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDCANCEL, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-	}
+	SetDlgTexts(m_hWnd, TextInfos, _countof(TextInfos), UILanguageFile);
 
-	GetDlgItemText(IDOK, uimsg2, sizeof(uimsg2));
-	get_lang_msg("BTN_STOP", uimsg, sizeof(uimsg), uimsg2, UILanguageFile);
-	SetDlgItemText(IDOK, uimsg);
-	GetDlgItemText(IDCANCEL, uimsg2, sizeof(uimsg2));
-	get_lang_msg("BTN_CONTINUE", uimsg, sizeof(uimsg), uimsg2, UILanguageFile);
-	SetDlgItemText(IDCANCEL, uimsg);
-	GetDlgItemText(IDC_MACROERRHELP, uimsg2, sizeof(uimsg2));
-	get_lang_msg("BTN_HELP", uimsg, sizeof(uimsg), uimsg2, UILanguageFile);
-	SetDlgItemText(IDC_MACROERRHELP, uimsg);
-
 	SetDlgItemText(IDC_ERRMSG,MsgStr);
 
 	// \x8Ds\x94ԍ\x86\x82\xF0\x90擪\x82ɂ‚\xAF\x82\xE9\x81B
@@ -132,8 +114,8 @@
 		PosY = (GetDeviceCaps(TmpDC,VERTRES)-R.bottom+R.top) / 2;
 		::ReleaseDC(GetSafeHwnd(),TmpDC);
 	}
-	SetWindowPos(&wndTop,PosX,PosY,0,0,SWP_NOSIZE);
-	SetForegroundWindow();
+	SetWindowPos(HWND_TOP, PosX, PosY, 0, 0, SWP_NOSIZE);
+	::SetForegroundWindow(m_hWnd);
 
 	return TRUE;
 }
@@ -142,3 +124,13 @@
 {
 	OpenHelp(HH_HELP_CONTEXT, HlpMacroAppendixesError, UILanguageFile);
 }
+
+BOOL CErrDlg::OnCommand(WPARAM wp, LPARAM lp)
+{
+	const WORD wID = GET_WM_COMMAND_ID(wp, lp);
+	if (wID == IDC_MACROERRHELP) {
+		OnBnClickedMacroerrhelp();
+		return TRUE;
+	}
+	return FALSE;
+}

Modified: branches/cmake/teraterm/ttpmacro/errdlg.h
===================================================================
--- branches/cmake/teraterm/ttpmacro/errdlg.h	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/ttpmacro/errdlg.h	2018-11-03 15:33:07 UTC (rev 7256)
@@ -30,32 +30,24 @@
 /* TTMACRO.EXE, error dialog box */
 
 // CErrDlg dialog
-class CErrDlg : public CDialog
+#include "tmfc.h"
+
+class CErrDlg : public TTCDialog
 {
 public:
 	CErrDlg(PCHAR Msg, PCHAR Line, int x, int y, int lineno, int start, int end, PCHAR FileName);
+	INT_PTR DoModal();
 
-	//{{AFX_DATA(CErrDlg)
+private:
 	enum { IDD = IDD_ERRDLG };
-	//}}AFX_DATA
 
-	//{{AFX_VIRTUAL(CErrDlg)
-	//}}AFX_VIRTUAL
-
-protected:
 	PCHAR MsgStr, LineStr;
 	int PosX, PosY;
-	HFONT DlgFont;
 	int LineNo;
 	int StartPos, EndPos;
 	PCHAR MacroFileName;
 
-	//{{AFX_MSG(CErrDlg)
 	virtual BOOL OnInitDialog();
-	//}}AFX_MSG
-	DECLARE_MESSAGE_MAP()
-public:
-	afx_msg void OnBnClickedMacroerrhelp();
+	BOOL OnCommand(WPARAM wp, LPARAM lp);
+	void OnBnClickedMacroerrhelp();
 };
-
-typedef CErrDlg *PErrDlg;

Modified: branches/cmake/teraterm/ttpmacro/inpdlg.cpp
===================================================================
--- branches/cmake/teraterm/ttpmacro/inpdlg.cpp	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/ttpmacro/inpdlg.cpp	2018-11-03 15:33:07 UTC (rev 7256)
@@ -29,28 +29,23 @@
 
 /* TTMACRO.EXE, input dialog box */
 
-#include "stdafx.h"
 #include "teraterm.h"
 #include "ttlib.h"
 #include "ttmdef.h"
 #include "ttm_res.h"
 #include "ttmlib.h"
+#include "dlglib.h"
 
 #include "inpdlg.h"
 
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
+extern HINSTANCE GetInstance();
+extern HWND GetHWND();
 
 // CInpDlg dialog
 CInpDlg::CInpDlg(PCHAR Input, PCHAR Text, PCHAR Title,
                  PCHAR Default, BOOL Paswd,
-                 int x, int y) : CDialog(CInpDlg::IDD)
+                 int x, int y)
 {
-	//{{AFX_DATA_INIT(CInpDlg)
-	//}}AFX_DATA_INIT
 	InputStr = Input;
 	TextStr = Text;
 	TitleStr = Title;
@@ -58,62 +53,39 @@
 	PaswdFlag = Paswd;
 	PosX = x;
 	PosY = y;
-	DlgFont = NULL;
 }
 
-BEGIN_MESSAGE_MAP(CInpDlg, CDialog)
-	//{{AFX_MSG_MAP(CInpDlg)
-	ON_MESSAGE(WM_EXITSIZEMOVE, OnExitSizeMove)
-	//}}AFX_MSG_MAP
-END_MESSAGE_MAP()
+INT_PTR CInpDlg::DoModal()
+{
+	HINSTANCE hInst = GetInstance();
+	HWND parent = GetHWND();
+	return TTCDialog::DoModal(hInst, parent, CInpDlg::IDD);
+}
 
-// CInpDlg message handler
-
 // msgdlg \x82̂悤\x82ɁA\x83\x81\x83b\x83Z\x81[\x83W\x82\xAA\x92\xB7\x82\xA2\x8Fꍇ\x82ɂ̓_\x83C\x83A\x83\x8D\x83O\x82\xF0\x8Ag\x82\xB0\x82\xE9\x82悤\x82ɂ\xB5\x82\xBD (2006.7.29 maya)
 BOOL CInpDlg::OnInitDialog()
 {
+	static const DlgTextInfo TextInfos[] = {
+		{ IDOK, "BTN_OK" },
+	};
 	RECT R;
-	HDC TmpDC;
 	HWND HEdit, HOk;
-	char uimsg[MAX_UIMSG], uimsg2[MAX_UIMSG];
-	LOGFONT logfont;
-	HFONT font, tmpfont;
 
-	CDialog::OnInitDialog();
-	font = (HFONT)SendMessage(WM_GETFONT, 0, 0);
-	GetObject(font, sizeof(LOGFONT), &logfont);
-	if (get_lang_font("DLG_SYSTEM_FONT", m_hWnd, &logfont, &DlgFont, UILanguageFile)) {
-		SendDlgItemMessage(IDC_INPTEXT, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_INPEDIT, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDOK, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-	}
-
-	GetDlgItemText(IDOK, uimsg2, sizeof(uimsg2));
-	get_lang_msg("BTN_OK", uimsg, sizeof(uimsg), uimsg2, UILanguageFile);
-	SetDlgItemText(IDOK, uimsg);
-
+	SetDlgTexts(m_hWnd, TextInfos, _countof(TextInfos), UILanguageFile);
 	SetWindowText(TitleStr);
 	SetDlgItemText(IDC_INPTEXT,TextStr);
 	SetDlgItemText(IDC_INPEDIT,DefaultStr);
 
-	TmpDC = ::GetDC(GetDlgItem(IDC_INPTEXT)->GetSafeHwnd());
-	if (DlgFont) {
-		tmpfont = (HFONT)SelectObject(TmpDC, DlgFont);
-	}
-	CalcTextExtent(TmpDC,TextStr,&s);
-	if (DlgFont && tmpfont != NULL) {
-		SelectObject(TmpDC, tmpfont);
-	}
-	::ReleaseDC(GetDlgItem(IDC_INPTEXT)->GetSafeHwnd(),TmpDC);
+	CalcTextExtent2(GetDlgItem(IDC_STATTEXT), NULL, TextStr, &s);
 	TW = s.cx + s.cx/10;
 	TH = s.cy;
 
-	HEdit = ::GetDlgItem(GetSafeHwnd(), IDC_INPEDIT);
+	HEdit = GetDlgItem(IDC_INPEDIT);
 	::GetWindowRect(HEdit,&R);
 	EW = R.right-R.left;
 	EH = R.bottom-R.top;
 
-	HOk = ::GetDlgItem(GetSafeHwnd(), IDOK);
+	HOk = GetDlgItem(IDOK);
 	::GetWindowRect(HOk,&R);
 	BW = R.right-R.left;
 	BH = R.bottom-R.top;
@@ -124,15 +96,16 @@
 
 	Relocation(TRUE, WW);
 
-	BringupWindow(this->m_hWnd);
+	BringupWindow(m_hWnd);
 
 	return TRUE;
 }
 
-void CInpDlg::OnOK()
+BOOL CInpDlg::OnOK()
 {
 	GetDlgItemText(IDC_INPEDIT,InputStr,MaxStrLen-1);
 	EndDialog(IDOK);
+	return TRUE;
 }
 
 LRESULT CInpDlg::OnExitSizeMove(WPARAM wParam, LPARAM lParam)
@@ -145,7 +118,7 @@
 	}
 	else if (R.bottom-R.top != WH || R.right-R.left < init_WW) {
 		// \x8D\x82\x82\xB3\x82\xAA\x95ύX\x82\xB3\x82ꂽ\x82\xA9\x81A\x8Dŏ\x89\x82\xE6\x82蕝\x82\xAA\x8B\xB7\x82\xAD\x82Ȃ\xC1\x82\xBD\x8Fꍇ\x82͌\xB3\x82ɖ߂\xB7
-		SetWindowPos(&wndTop,R.left,R.top,WW,WH,0);
+		SetWindowPos(HWND_TOP, R.left,R.top,WW,WH,0);
 	}
 	else {
 		// \x82\xBB\x82\xA4\x82łȂ\xAF\x82\xEA\x82΍Ĕz\x92u\x82\xB7\x82\xE9
@@ -152,7 +125,7 @@
 		Relocation(FALSE, R.right-R.left);
 	}
 
-	return CDialog::DefWindowProc(WM_EXITSIZEMOVE,wParam,lParam);
+	return TRUE;
 }
 
 void CInpDlg::Relocation(BOOL is_init, int new_WW)
@@ -185,9 +158,9 @@
 		WW = new_WW;
 	}
 
-	HText = ::GetDlgItem(GetSafeHwnd(), IDC_INPTEXT);
-	HOk = ::GetDlgItem(GetSafeHwnd(), IDOK);
-	HEdit = ::GetDlgItem(GetSafeHwnd(), IDC_INPEDIT);
+	HText = GetDlgItem(IDC_INPTEXT);
+	HOk = GetDlgItem(IDOK);
+	HEdit = GetDlgItem(IDC_INPEDIT);
 
 	::MoveWindow(HText,(TW-s.cx)/2,BH/2,TW,TH,TRUE);
 	::MoveWindow(HEdit,(WW-EW)/2-4,TH+BH,EW,EH,TRUE);
@@ -206,7 +179,16 @@
 		PosY = (GetDeviceCaps(TmpDC,VERTRES)-R.bottom+R.top) / 2;
 		::ReleaseDC(GetSafeHwnd(),TmpDC);
 	}
-	SetWindowPos(&wndTop,PosX,PosY,WW,WH,0);
+	SetWindowPos(HWND_TOP,PosX,PosY,WW,WH,0);
 
-	InvalidateRect(NULL);
+	InvalidateRect(NULL, TRUE);
 }
+
+LRESULT CInpDlg::DlgProc(UINT msg, WPARAM wp, LPARAM lp)
+{
+	switch(msg) {
+	case WM_EXITSIZEMOVE:
+		return OnExitSizeMove(wp, lp);
+	}
+	return FALSE;
+}

Modified: branches/cmake/teraterm/ttpmacro/inpdlg.h
===================================================================
--- branches/cmake/teraterm/ttpmacro/inpdlg.h	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/ttpmacro/inpdlg.h	2018-11-03 15:33:07 UTC (rev 7256)
@@ -29,33 +29,28 @@
 
 /* TTMACRO.EXE, input dialog box */
 
-class CInpDlg : public CDialog
+#include "../common/tmfc.h"
+
+class CInpDlg : public TTCDialog
 {
 public:
 	CInpDlg(PCHAR Input, PCHAR Text, PCHAR Title,
 	        PCHAR Default, BOOL Paswd,
 	        int x, int y);
+	INT_PTR DoModal();
 
-	//{{AFX_DATA(CInpDlg)
+private:
 	enum { IDD = IDD_INPDLG };
-	//}}AFX_DATA
 
-	//{{AFX_VIRTUAL(CInpDlg)
-	//}}AFX_VIRTUAL
-
-protected:
 	PCHAR InputStr, TextStr, TitleStr, DefaultStr;
 	BOOL PaswdFlag;
 	int PosX, PosY, init_WW, WW, WH, TW, TH, BH, BW, EW, EH;
 	SIZE s;
-	HFONT DlgFont;
 
-	//{{AFX_MSG(CInpDlg)
 	virtual BOOL OnInitDialog();
-	virtual void OnOK();
-	afx_msg LRESULT OnExitSizeMove(WPARAM wParam, LPARAM lParam);
-	//}}AFX_MSG
-	void Relocation(BOOL is_init, int WW);
-	DECLARE_MESSAGE_MAP()
+	virtual BOOL OnOK();
+	virtual LRESULT DlgProc(UINT msg, WPARAM wp, LPARAM lp);
+	LRESULT OnExitSizeMove(WPARAM wp, LPARAM lp);
+ 	void Relocation(BOOL is_init, int WW);
 };
-typedef CInpDlg *PInpDlg;
+

Modified: branches/cmake/teraterm/ttpmacro/msgdlg.cpp
===================================================================
--- branches/cmake/teraterm/ttpmacro/msgdlg.cpp	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/ttpmacro/msgdlg.cpp	2018-11-03 15:33:07 UTC (rev 7256)
@@ -29,82 +29,65 @@
 
 /* TTMACRO.EXE, message dialog box */
 
-#include "stdafx.h"
+#include <windows.h>
+#include <windowsx.h>
 #include "teraterm.h"
 #include "ttlib.h"
 #include "ttm_res.h"
 #include "ttmlib.h"
+#include "tmfc.h"
+#include "dlglib.h"
+#include "ttmdlg.h"
 
 #include "msgdlg.h"
 
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
+extern HINSTANCE GetInstance();
+extern HWND GetHWND();
 
 // CMsgDlg dialog
 
 CMsgDlg::CMsgDlg(PCHAR Text, PCHAR Title, BOOL YesNo,
-                 int x, int y) : CDialog(CMsgDlg::IDD)
+                 int x, int y)
 {
-	//{{AFX_DATA_INIT(CMsgDlg)
-	//}}AFX_DATA_INIT
 	TextStr = Text;
 	TitleStr = Title;
 	YesNoFlag = YesNo;
 	PosX = x;
 	PosY = y;
-	DlgFont = NULL;
 }
 
-BEGIN_MESSAGE_MAP(CMsgDlg, CDialog)
-	//{{AFX_MSG_MAP(CMsgDlg)
-	ON_MESSAGE(WM_EXITSIZEMOVE, OnExitSizeMove)
-	//}}AFX_MSG_MAP
-END_MESSAGE_MAP()
+INT_PTR CMsgDlg::DoModal()
+{
+	HINSTANCE hInst = GetInstance();
+	HWND hWndParent = GetHWND();
+	return TTCDialog::DoModal(hInst, hWndParent, CMsgDlg::IDD);
+}
 
-// CMsgDlg message handler
-
 BOOL CMsgDlg::OnInitDialog()
 {
+	static const DlgTextInfo TextInfosOk[] = {
+		{ IDOK, "BTN_OK" },
+	};
+	static const DlgTextInfo TextInfosYesNo[] = {
+		{ IDOK, "BTN_YES" },
+		{ IDCANCEL, "BTN_NO" },
+	};
 	RECT R;
-	HDC TmpDC;
-	HWND HOk, HNo;
-	char uimsg[MAX_UIMSG], uimsg2[MAX_UIMSG];
-	LOGFONT logfont;
-	HFONT font, tmpfont;
+	HWND HOk;
 
-	CDialog::OnInitDialog();
-	font = (HFONT)SendMessage(WM_GETFONT, 0, 0);
-	GetObject(font, sizeof(LOGFONT), &logfont);
-	if (get_lang_font("DLG_SYSTEM_FONT", m_hWnd, &logfont, &DlgFont, UILanguageFile)) {
-		SendDlgItemMessage(IDC_MSGTEXT, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDOK, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDCLOSE, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
+	if (YesNoFlag) {
+		SetDlgTexts(m_hWnd, TextInfosYesNo, _countof(TextInfosYesNo), UILanguageFile);
+	} else {
+		SetDlgTexts(m_hWnd, TextInfosOk, _countof(TextInfosOk), UILanguageFile);
 	}
 
-	GetDlgItemText(IDOK, uimsg2, sizeof(uimsg2));
-	get_lang_msg("BTN_OK", uimsg, sizeof(uimsg), uimsg2, UILanguageFile);
-	SetDlgItemText(IDOK, uimsg);
-
 	SetWindowText(TitleStr);
 	SetDlgItemText(IDC_MSGTEXT,TextStr);
-
-	TmpDC = ::GetDC(GetDlgItem(IDC_MSGTEXT)->GetSafeHwnd());
-	if (DlgFont) {
-		tmpfont = (HFONT)SelectObject(TmpDC, DlgFont);
-	}
-	CalcTextExtent(TmpDC,TextStr,&s);
-	if (DlgFont && tmpfont != NULL) {
-		SelectObject(TmpDC, tmpfont);
-	}
-	::ReleaseDC(GetDlgItem(IDC_MSGTEXT)->GetSafeHwnd(),TmpDC);
+	CalcTextExtent2(GetDlgItem(IDC_STATTEXT), NULL, TextStr, &s);
 	TW = s.cx + s.cx/10;
 	TH = s.cy;
 
 	HOk = ::GetDlgItem(GetSafeHwnd(), IDOK);
-	HNo = ::GetDlgItem(GetSafeHwnd(), IDCLOSE);
 	::GetWindowRect(HOk,&R);
 	BW = R.right-R.left;
 	BH = R.bottom-R.top;
@@ -130,7 +113,7 @@
 	}
 	else if (R.bottom-R.top != WH || R.right-R.left < init_WW) {
 		// \x8D\x82\x82\xB3\x82\xAA\x95ύX\x82\xB3\x82ꂽ\x82\xA9\x81A\x8Dŏ\x89\x82\xE6\x82蕝\x82\xAA\x8B\xB7\x82\xAD\x82Ȃ\xC1\x82\xBD\x8Fꍇ\x82͌\xB3\x82ɖ߂\xB7
-		SetWindowPos(&wndTop,R.left,R.top,WW,WH,0);
+		SetWindowPos(HWND_TOP,R.left,R.top,WW,WH,0);
 	}
 	else {
 		// \x82\xBB\x82\xA4\x82łȂ\xAF\x82\xEA\x82΍Ĕz\x92u\x82\xB7\x82\xE9
@@ -137,7 +120,7 @@
 		Relocation(FALSE, R.right-R.left);
 	}
 
-	return CDialog::DefWindowProc(WM_EXITSIZEMOVE,wParam,lParam);
+	return TRUE;
 }
 
 void CMsgDlg::Relocation(BOOL is_init, int new_WW)
@@ -146,7 +129,6 @@
 	HDC TmpDC;
 	HWND HText, HOk, HNo;
 	int CW, CH;
-	char uimsg[MAX_UIMSG], uimsg2[MAX_UIMSG];
 
 	GetClientRect(&R);
 	CW = R.right-R.left;
@@ -173,20 +155,10 @@
 
 	HText = ::GetDlgItem(GetSafeHwnd(), IDC_MSGTEXT);
 	HOk = ::GetDlgItem(GetSafeHwnd(), IDOK);
-	HNo = ::GetDlgItem(GetSafeHwnd(), IDCLOSE);
+	HNo = ::GetDlgItem(GetSafeHwnd(), IDCANCEL);
 
 	::MoveWindow(HText,(TW-s.cx)/2, BH/2,TW,TH,TRUE);
 	if (YesNoFlag) {
-		if (is_init) {
-			::SetWindowText(HOk,"&Yes");
-			::SetWindowText(HNo,"&No");
-			GetDlgItemText(IDOK, uimsg2, sizeof(uimsg2));
-			get_lang_msg("BTN_YES", uimsg, sizeof(uimsg), uimsg2, UILanguageFile);
-			::SetWindowText(HOk,uimsg);
-			GetDlgItemText(IDCLOSE, uimsg2, sizeof(uimsg2));
-			get_lang_msg("BTN_NO", uimsg, sizeof(uimsg), uimsg2, UILanguageFile);
-			::SetWindowText(HNo,uimsg);
-		}
 		::MoveWindow(HOk,(2*TW-5*BW)/4,TH+BH,BW,BH,TRUE);
 		::MoveWindow(HNo,(2*TW+BW)/4,TH+BH,BW,BH,TRUE);
 		::ShowWindow(HNo,SW_SHOW);
@@ -201,38 +173,41 @@
 		PosY = (GetDeviceCaps(TmpDC,VERTRES)-WH) / 2;
 		::ReleaseDC(GetSafeHwnd(),TmpDC);
 	}
-	SetWindowPos(&wndTop,PosX,PosY,WW,WH,0);
+	SetWindowPos(HWND_TOP,PosX,PosY,WW,WH,0);
 	InvalidateRect(NULL);
 }
 
-BOOL CMsgDlg::OnCommand(WPARAM wParam, LPARAM lParam)
+BOOL CMsgDlg::OnCancel()
 {
-	switch (LOWORD(wParam)) {
-	case IDCANCEL:
-		if( HIWORD(wParam) == BN_CLICKED ) {
-			// \x83\x81\x83b\x83Z\x81[\x83W\x83{\x83b\x83N\x83X\x82\xF0\x83L\x83\x83\x83\x93\x83Z\x83\x8B\x82\xB7\x82\xE9\x82ƁA\x83}\x83N\x83\x8D\x82̏I\x97\xB9\x82Ƃ\xB7\x82\xE9\x81B
-			// (2008.8.5 yutaka)	
-			int ret;
-			char uimsg[MAX_UIMSG], uimsg2[MAX_UIMSG];
-			get_lang_msg("MSG_MACRO_CONF", uimsg, sizeof(uimsg), "MACRO: confirmation", UILanguageFile);
-			get_lang_msg("MSG_MACRO_HALT_SCRIPT", uimsg2, sizeof(uimsg2), "Are you sure that you want to halt this macro script?", UILanguageFile);
-			ret = MessageBox(uimsg2, uimsg, MB_YESNO | MB_ICONWARNING | MB_DEFBUTTON2);
-			if (ret == IDYES) {
-				if (YesNoFlag == TRUE) {
-					EndDialog(IDCLOSE);
-				} else {
-					EndDialog(IDCANCEL);
-				}
-			}
-			return TRUE;
-		}
-		return FALSE;
-
-	case IDCLOSE:
-		EndDialog(IDCANCEL);
+	if (!YesNoFlag) {
+		// ok(yes)\x82\xBE\x82\xAF\x82̂Ƃ\xAB\x82́Acancel\x8F\x88\x97\x9D\x82͉\xBD\x82\xE0\x82\xB5\x82Ȃ\xA2
 		return TRUE;
+	} else {
+		// yes/no\x82̂Ƃ\xAB\x82́A\x83f\x83t\x83H\x83\x8B\x83g\x8F\x88\x97\x9D(\x8FI\x97\xB9)
+		return TTCDialog::OnCancel();
+	}
+}
 
-	default:
-		return (CDialog::OnCommand(wParam,lParam));
+// \x83\x81\x83b\x83Z\x81[\x83W\x83{\x83b\x83N\x83X\x82\xF0\x83L\x83\x83\x83\x93\x83Z\x83\x8B\x82\xB7\x82\xE9(close\x83{\x83^\x83\x93\x82\xF0\x89\x9F\x82\xB7)\x82ƁA\x83}\x83N\x83\x8D\x82̏I\x97\xB9\x82Ƃ\xB7\x82\xE9\x81B
+// (2008.8.5 yutaka)	
+BOOL CMsgDlg::OnClose()
+{
+	const int ret = MessageBoxHaltScript(m_hWnd);
+	if (ret == IDYES) {
+		if (YesNoFlag == TRUE) {
+			EndDialog(IDCLOSE);
+		} else {
+			EndDialog(IDCANCEL);
+		}
 	}
+	return TRUE;
 }
+
+LRESULT CMsgDlg::DlgProc(UINT msg, WPARAM wp, LPARAM lp)
+{
+	switch(msg) {
+	case WM_EXITSIZEMOVE:
+		return OnExitSizeMove(wp, lp);
+	}
+	return FALSE;
+}

Modified: branches/cmake/teraterm/ttpmacro/msgdlg.h
===================================================================
--- branches/cmake/teraterm/ttpmacro/msgdlg.h	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/ttpmacro/msgdlg.h	2018-11-03 15:33:07 UTC (rev 7256)
@@ -29,31 +29,27 @@
 
 /* TTMACRO.EXE, message dialog box */
 
-class CMsgDlg : public CDialog
+#include "ttm_res.h"
+
+class CMsgDlg : public TTCDialog
 {
 public:
-	CMsgDlg(PCHAR Text, PCHAR Title, BOOL YesNo,
-	        int x, int y);
+	CMsgDlg(PCHAR Text, PCHAR Title, BOOL YesNo, int x, int y);
+	INT_PTR DoModal();
 
-	//{{AFX_DATA(CMsgDlg)
+private:
 	enum { IDD = IDD_MSGDLG };
-	//}}AFX_DATA
 
-	//{{AFX_VIRTUAL(CMsgDlg)
-	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
-	//}}AFX_VIRTUAL
-
-protected:
 	PCHAR TextStr, TitleStr;
 	BOOL YesNoFlag;
 	int  PosX, PosY, init_WW, WW, WH, TW, TH, BH, BW;
 	SIZE s;
-	HFONT DlgFont;
 
-	//{{AFX_MSG(CMsgDlg)
 	virtual BOOL OnInitDialog();
-	afx_msg LRESULT OnExitSizeMove(WPARAM wParam, LPARAM lParam);
-	//}}AFX_MSG
+	virtual BOOL OnClose();
+	virtual BOOL OnCancel();
+	virtual LRESULT DlgProc(UINT msg, WPARAM wp, LPARAM lp);
+
+	LRESULT OnExitSizeMove(WPARAM wParam, LPARAM lParam);
 	void Relocation(BOOL is_init, int WW);
-	DECLARE_MESSAGE_MAP()
 };

Modified: branches/cmake/teraterm/ttpmacro/statdlg.cpp
===================================================================
--- branches/cmake/teraterm/ttpmacro/statdlg.cpp	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/ttpmacro/statdlg.cpp	2018-11-03 15:33:07 UTC (rev 7256)
@@ -29,30 +29,28 @@
 
 /* TTMACRO.EXE, status dialog box */
 
-#include "stdafx.h"
 #include "teraterm.h"
 #include "ttlib.h"
 #include "ttm_res.h"
 #include "ttmlib.h"
+#include "tmfc.h"
+#include "tttypes.h"
 
 #include "statdlg.h"
-#include "tttypes.h"
 
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
 // CStatDlg dialog
 
+#if 0
 BEGIN_MESSAGE_MAP(CStatDlg, CDialog)
 	//{{AFX_MSG_MAP(CStatDlg)
 	ON_MESSAGE(WM_EXITSIZEMOVE, OnExitSizeMove)
-	ON_MESSAGE(WM_USER_MSTATBRINGUP, OnSetForceForegroundWindow)
+//	ON_MESSAGE(WM_USER_MSTATBRINGUP, OnSetForceForegroundWindow)
 	//}}AFX_MSG_MAP
 END_MESSAGE_MAP()
+#endif
 
+extern HINSTANCE GetInstance();
+
 BOOL CStatDlg::Create(PCHAR Text, PCHAR Title, int x, int y)
 {
 	TextStr = Text;
@@ -59,15 +57,14 @@
 	TitleStr = Title;
 	PosX = x;
 	PosY = y;
-	DlgFont = NULL;
-	return CDialog::Create(CStatDlg::IDD, GetDesktopWindow());
+//	DlgFont = NULL;
+	HINSTANCE hInst = GetInstance();
+	return TTCDialog::Create(hInst, GetDesktopWindow(), CStatDlg::IDD);
 }
 
 void CStatDlg::Update(PCHAR Text, PCHAR Title, int x, int y)
 {
 	RECT R;
-	HDC TmpDC;
-	HFONT tmpfont;
 
 	if (Title!=NULL) {
 		SetWindowText(Title);
@@ -81,17 +78,12 @@
 	WH = R.bottom-R.top;
 
 	if (Text!=NULL) {
-		TmpDC = ::GetDC(GetDlgItem(IDC_STATTEXT)->GetSafeHwnd());
-		if (DlgFont) {
-			tmpfont = (HFONT)SelectObject(TmpDC, DlgFont);
-		}
-		CalcTextExtent(TmpDC,Text,&s);
-		if (DlgFont && tmpfont != NULL) {
-			SelectObject(TmpDC, tmpfont);
-		}
-		::ReleaseDC(GetDlgItem(IDC_STATTEXT)->GetSafeHwnd(),TmpDC);
-		TW = s.cx + s.cx/10;
-		TH = s.cy;
+		SIZE textSize;
+		HWND hWnd = GetDlgItem(IDC_STATTEXT);
+		CalcTextExtent2(hWnd, NULL, Text, &textSize);
+		TW = textSize.cx + textSize.cx/10;	// (cx * (1+0.1)) ?
+		TH = textSize.cy;
+		s = textSize;			// TODO s!?
 
 		SetDlgItemText(IDC_STATTEXT,Text);
 		TextStr = Text;
@@ -109,44 +101,53 @@
 
 BOOL CStatDlg::OnInitDialog()
 {
+#if 0
 	LOGFONT logfont;
 	HFONT font;
+#endif
 
-	CDialog::OnInitDialog();
 	Update(TextStr,TitleStr,PosX,PosY);
-	SetForegroundWindow();
-
+	SetForegroundWindow(m_hWnd);
+#if 0
 	font = (HFONT)SendMessage(WM_GETFONT, 0, 0);
 	GetObject(font, sizeof(LOGFONT), &logfont);
 	if (get_lang_font("DLG_SYSTEM_FONT", m_hWnd, &logfont, &DlgFont, UILanguageFile)) {
 		SendDlgItemMessage(IDC_STATTEXT, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
 	}
+#endif
+	return TRUE;
+}
 
+BOOL CStatDlg::OnOK()
+{
 	return TRUE;
 }
 
-void CStatDlg::OnCancel()
+BOOL CStatDlg::OnCancel()
 {
 	DestroyWindow();
+	return TRUE;
 }
 
 BOOL CStatDlg::OnCommand(WPARAM wParam, LPARAM lParam)
 {
 	switch (LOWORD(wParam)) {
-		case IDOK:  // Enter key\x89\x9F\x89\xBA\x82ŏ\xC1\x82\xA6\x82Ȃ\xA2\x82悤\x82ɂ\xB7\x82\xE9\x81B(2010.8.25 yutaka)
-			return TRUE;
-		case IDCANCEL:
-			if ((HWND)lParam!=NULL) { // ignore ESC key
-				DestroyWindow();
-			}
-			return TRUE;
-		default:
-		return (CDialog::OnCommand(wParam,lParam));
+	case IDOK:
+		// Enter key\x89\x9F\x89\xBA\x82ŏ\xC1\x82\xA6\x82Ȃ\xA2\x82悤\x82ɂ\xB7\x82\xE9\x81B(2010.8.25 yutaka)
+		return TRUE;
+	case IDCANCEL:
+		if ((HWND)lParam!=NULL) { // ignore ESC key
+			DestroyWindow();
+		}
+		return TRUE;
+	default:
+		return FALSE;
 	}
 }
 
-void CStatDlg::PostNcDestroy()
+BOOL CStatDlg::PostNcDestroy()
 {
+#if 0
 	// statusbox\x82\xC6closesbox\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
 	// (2016.10.5 yutaka)
@@ -154,8 +155,9 @@
 		DeleteObject(DlgFont);
 		DlgFont = NULL;
 	}
-
+#endif
 	delete this;
+	return TRUE;
 }
 
 LRESULT CStatDlg::OnExitSizeMove(WPARAM wParam, LPARAM lParam)
@@ -162,13 +164,13 @@
 {
 	RECT R;
 
-	GetWindowRect(&R);
+	::GetWindowRect(m_hWnd, &R);
 	if (R.bottom-R.top == WH && R.right-R.left == WW) {
 		// \x83T\x83C\x83Y\x82\xAA\x95ς\xED\x82\xC1\x82Ă\xA2\x82Ȃ\xAF\x82\xEA\x82Ή\xBD\x82\xE0\x82\xB5\x82Ȃ\xA2
 	}
 	else if (R.bottom-R.top != WH || R.right-R.left < init_WW) {
 		// \x8D\x82\x82\xB3\x82\xAA\x95ύX\x82\xB3\x82ꂽ\x82\xA9\x81A\x8Dŏ\x89\x82\xE6\x82蕝\x82\xAA\x8B\xB7\x82\xAD\x82Ȃ\xC1\x82\xBD\x8Fꍇ\x82͌\xB3\x82ɖ߂\xB7
-		SetWindowPos(&wndTop,R.left,R.top,WW,WH,0);
+		::SetWindowPos(m_hWnd, HWND_TOP, R.left,R.top,WW,WH,0);
 	}
 	else {
 		// \x82\xBB\x82\xA4\x82łȂ\xAF\x82\xEA\x82΍Ĕz\x92u\x82\xB7\x82\xE9
@@ -175,7 +177,7 @@
 		Relocation(FALSE, R.right-R.left);
 	}
 
-	return CDialog::DefWindowProc(WM_EXITSIZEMOVE,wParam,lParam);
+	return TRUE;
 }
 
 LRESULT CStatDlg::OnSetForceForegroundWindow(WPARAM wParam, LPARAM lParam)
@@ -188,12 +190,12 @@
 	targetid = GetWindowThreadProcessId(hwnd, &pid);
 	currentActiveThreadId = GetWindowThreadProcessId(::GetForegroundWindow(), &pid);
 
-	SetForegroundWindow();
+	::SetForegroundWindow(m_hWnd);
 	if (targetid == currentActiveThreadId) {
-		BringWindowToTop();
+		BringWindowToTop(m_hWnd);
 	} else {
 		AttachThreadInput(targetid, currentActiveThreadId, TRUE);
-		BringWindowToTop();
+		BringWindowToTop(m_hWnd);
 		AttachThreadInput(targetid, currentActiveThreadId, FALSE);
 	}
 
@@ -208,7 +210,7 @@
 	int CW, CH;
 
 	if (TextStr != NULL) {
-		HText = ::GetDlgItem(GetSafeHwnd(), IDC_STATTEXT);
+		HText = GetDlgItem(IDC_STATTEXT);
 
 		GetClientRect(&R);
 		CW = R.right-R.left;
@@ -239,16 +241,22 @@
 		PosY = (GetDeviceCaps(TmpDC,VERTRES)-WH) / 2;
 		::ReleaseDC(GetSafeHwnd(),TmpDC);
 	}
-	SetWindowPos(&wndTop,PosX,PosY,WW,WH,SWP_NOZORDER);
+	SetWindowPos(HWND_TOP,PosX,PosY,WW,WH,SWP_NOZORDER);
 
-	InvalidateRect(NULL);
+	InvalidateRect(NULL, TRUE);
 }
 
 void CStatDlg::Bringup()
 {
-	BringupWindow(this->m_hWnd);
+	BringupWindow(m_hWnd);
 }
 
+/**
+ * MFC\x82\xCCCWnd\x82̉B\x82ꃁ\x83\x93\x83o\x8A֐\x94
+ *	\x82\xB1\x82̊֐\x94\x82\xAAFALSE\x82\xF0\x95Ԃ\xB7\x82\xC6
+ *	CDialog::OnInitDialog()\x8C\xE3\x82\xC9
+ *	CWnd::CenterWindow() \x82\xAA\x8CĂяo\x82\xB3\x82\xEA\x82Ȃ\xA2
+ */
 BOOL CStatDlg::CheckAutoCenter()
 {
 	// CenterWindow() is called when x=0 && y=0
@@ -255,3 +263,15 @@
 	// Don't call CenterWindow()
 	return FALSE;
 }
+
+LRESULT CStatDlg::DlgProc(UINT msg, WPARAM wp, LPARAM lp)
+{
+	switch(msg) {
+	case WM_USER_MSTATBRINGUP:
+		return OnSetForceForegroundWindow(wp, lp);
+	case WM_EXITSIZEMOVE :
+		return OnExitSizeMove(wp, lp);
+	}
+	return FALSE;
+}
+

Modified: branches/cmake/teraterm/ttpmacro/statdlg.h
===================================================================
--- branches/cmake/teraterm/ttpmacro/statdlg.h	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/ttpmacro/statdlg.h	2018-11-03 15:33:07 UTC (rev 7256)
@@ -29,38 +29,30 @@
 
 /* TTMACRO.EXE, status dialog box */
 
-class CStatDlg : public CDialog
+class CStatDlg : public TTCDialog
 {
 public:
 	BOOL Create(PCHAR Text, PCHAR Title, int x, int y);
 	void Update(PCHAR Text, PCHAR Title, int x, int y);
 	void Bringup();
-	virtual BOOL CheckAutoCenter();
-
-	//{{AFX_DATA(CStatDlg)
 	enum { IDD = IDD_STATDLG };
-	//}}AFX_DATA
-
-	//{{AFX_VIRTUAL(CStatDlg)
-	protected:
-	virtual void OnCancel( );
-	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
-	virtual void PostNcDestroy();
-	//}}AFX_VIRTUAL
-
-protected:
+private:
 	PCHAR TextStr, TitleStr;
 	int  PosX, PosY, init_WW, WW, WH, TW, TH;
 	SIZE s;
-	HFONT DlgFont;
+//	HFONT DlgFont;
 
-	//{{AFX_MSG(CStatDlg)
 	virtual BOOL OnInitDialog();
-	afx_msg LRESULT OnExitSizeMove(WPARAM wParam, LPARAM lParam);
-	afx_msg LRESULT OnSetForceForegroundWindow(WPARAM wParam, LPARAM lParam);
-	//}}AFX_MSG
+	virtual BOOL OnOK();
+	virtual BOOL OnCancel();
+	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
+	virtual BOOL PostNcDestroy();
+	virtual LRESULT DlgProc(UINT msg, WPARAM wp, LPARAM lp);
+
+	LRESULT OnExitSizeMove(WPARAM wParam, LPARAM lParam);
+	LRESULT OnSetForceForegroundWindow(WPARAM wParam, LPARAM lParam);
+
 	void Relocation(BOOL is_init, int WW);
-	DECLARE_MESSAGE_MAP()
+
+	BOOL CheckAutoCenter();
 };
-
-typedef CStatDlg *PStatDlg;

Deleted: branches/cmake/teraterm/ttpmacro/stdafx.h
===================================================================
--- branches/cmake/teraterm/ttpmacro/stdafx.h	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/ttpmacro/stdafx.h	2018-11-03 15:33:07 UTC (rev 7256)
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2013-2017 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.
- */
-#pragma once
-#include <afxwin.h>

Modified: branches/cmake/teraterm/ttpmacro/ttl.c
===================================================================
--- branches/cmake/teraterm/ttpmacro/ttl.c	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/ttpmacro/ttl.c	2018-11-03 15:33:07 UTC (rev 7256)
@@ -3450,6 +3450,7 @@
 		// return 
 		//   0\x88ȏ\xE3: \x91I\x91\xF0\x8D\x80\x96\xDA
 		//   -1: \x83L\x83\x83\x83\x93\x83Z\x83\x8B
+		//	 -2: close
 		ret = OpenListDlg(Str1, Str2, s, sel);
 
 		for (i = 0 ; i < ary_size ; i++) {
@@ -3457,6 +3458,10 @@
 		}
 		free(s);
 
+		// \x83\x8A\x83X\x83g\x83{\x83b\x83N\x83X\x82̕‚\xB6\x82\xE9\x83{\x83^\x83\x93(&\x8Am\x94F\x83_\x83C\x83A\x83\x8D\x83O)\x82ŁA\x83}\x83N\x83\x8D\x82̏I\x97\xB9\x82Ƃ\xB7\x82\xE9\x81B
+		if (ret == -2) {
+			TTLStatus = IdTTLEnd;
+		}
 		return (ret);
 
 	}

Modified: branches/cmake/teraterm/ttpmacro/ttm_res.h
===================================================================
--- branches/cmake/teraterm/ttpmacro/ttm_res.h	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/ttpmacro/ttm_res.h	2018-11-03 15:33:07 UTC (rev 7256)
@@ -1,6 +1,6 @@
 //{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by ttpmacro.rc
+// Microsoft Visual C++ \x82Ő\xB6\x90\xAC\x82\xB3\x82ꂽ\x83C\x83\x93\x83N\x83\x8B\x81[\x83h \x83t\x83@\x83C\x83\x8B\x81B
+// ttpmacro.rc \x82Ŏg\x97p
 //
 #define IDD_CTRLWIN                     100
 #define IDI_TTMACRO                     100
@@ -21,17 +21,17 @@
 #define IDI_TTMACRO_3D                  601
 #define IDC_LISTBOX                     602
 #define IDC_MACROERRHELP                603
-#define IDC_EDIT1                       604
-#define IDC_EDIT_ERRLINE                604
-#define IDC_FILENAME                    605
+#define IDC_LISTTEXT                    604
+#define IDC_EDIT_ERRLINE                606
+#define IDC_FILENAME                    607
 
 // Next default values for new objects
 // 
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE        602
+#define _APS_NEXT_RESOURCE_VALUE        603
 #define _APS_NEXT_COMMAND_VALUE         32771
-#define _APS_NEXT_CONTROL_VALUE         606
+#define _APS_NEXT_CONTROL_VALUE         607
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif

Modified: branches/cmake/teraterm/ttpmacro/ttmacro.cpp
===================================================================
--- branches/cmake/teraterm/ttpmacro/ttmacro.cpp	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/ttpmacro/ttmacro.cpp	2018-11-03 15:33:07 UTC (rev 7256)
@@ -29,7 +29,8 @@
 
 /* TTMACRO.EXE, main */
 
-#include "stdafx.h"
+#include <stdio.h>
+#include <crtdbg.h>
 #include "teraterm.h"
 #include "ttm_res.h"
 #include "ttmmain.h"
@@ -40,25 +41,20 @@
 #include "ttlib.h"
 
 #include "compat_w95.h"
+#include "compat_win.h"
+#include "ttmdlg.h"
+#include "tmfc.h"
 
 #ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
+#define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
 #endif
 
 char UILanguageFile[MAX_PATH];
+static BOOL Busy;
+static HINSTANCE hInst;
+static CCtrlWindow *pCCtrlWindow;
 
-/////////////////////////////////////////////////////////////////////////////
-
-BEGIN_MESSAGE_MAP(CCtrlApp, CWinApp)
-	//{{AFX_MSG_MAP(CCtrlApp)
-	//}}AFX_MSG
-END_MESSAGE_MAP()
-
-/////////////////////////////////////////////////////////////////////////////
-
-CCtrlApp::CCtrlApp()
+static void init()
 {
 	typedef BOOL (WINAPI *pSetDllDir)(LPCSTR);
 	typedef BOOL (WINAPI *pSetDefDllDir)(DWORD);
@@ -78,55 +74,132 @@
 			(*setDllDir)("");
 		}
 	}
+
+	WinCompatInit();
+	if (pSetThreadDpiAwarenessContext) {
+		pSetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
+	}
 }
 
+// TTMACRO main engine
+static BOOL OnIdle(LONG lCount)
+{
+	BOOL Continue;
+
+	// Avoid multi entry
+	if (Busy) {
+		return FALSE;
+	}
+	Busy = TRUE;
+	if (pCCtrlWindow != NULL) {
+		Continue = pCCtrlWindow->OnIdle();
+	}
+	else {
+		Continue = FALSE;
+	}
+	Busy = FALSE;
+	return Continue;
+}
+
 /////////////////////////////////////////////////////////////////////////////
 
-CCtrlApp theApp;
+// CCtrlApp theApp;
 
+static HWND CtrlWnd;
+
+HINSTANCE GetInstance()
+{
+	return hInst;
+}
+
+HWND GetHWND()
+{
+	return CtrlWnd;
+}
+
 /////////////////////////////////////////////////////////////////////////////
 
 
 
-BOOL CCtrlApp::InitInstance()
+int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst,
+                   LPSTR lpszCmdLine, int nCmdShow)
 {
+	hInst = hInstance;
 	static HMODULE HTTSET = NULL;
+	LONG lCount = 0;
+	DWORD SleepTick = 1;
 
+#ifdef _DEBUG
+	::_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
+#endif
+
+	init();
+//	InitCommonControls();
 	GetUILanguageFile(UILanguageFile, sizeof(UILanguageFile));
 
 	Busy = TRUE;
-	m_pMainWnd = new CCtrlWindow();
-	PCtrlWindow(m_pMainWnd)->Create();
+	pCCtrlWindow = new CCtrlWindow();
+	pCCtrlWindow->Create();
+//	pCCtrlWindow->ShowWindow(SW_SHOW);
+//	tmpWnd->ShowWindow(SW_SHOW);
 	Busy = FALSE;  
-	return TRUE;
-}
 
-int CCtrlApp::ExitInstance()
-{
-	//delete m_pMainWnd;
-	if (m_pMainWnd) {
-		m_pMainWnd->DestroyWindow();
-	}
-	m_pMainWnd = NULL;
-	return ExitCode;
-}
+	HWND hWnd = pCCtrlWindow->GetSafeHwnd();
+	CtrlWnd = hWnd;
 
-// TTMACRO main engine
-BOOL CCtrlApp::OnIdle(LONG lCount)
-{
-	BOOL Continue;
+	//////////////////////////////////////////////////////////////////////
+	MSG msg;
+	while (GetMessage(&msg, NULL, 0, 0)) {
+#if 0
+		bool message_processed = false;
+		if (m_pMainWnd->m_hAccel != NULL) {
+			if (!MetaKey(ts.MetaKey)) {
+				// matakey\x82\xAA\x89\x9F\x82\xB3\x82\xEA\x82Ă\xA2\x82Ȃ\xA2
+				if (TranslateAccelerator(m_pMainWnd->m_hWnd , m_pMainWnd->m_hAccel, &msg)) {
+					// \x83A\x83N\x83Z\x83\x89\x83\x8C\x81[\x83^\x81[\x83L\x81[\x82\xF0\x8F\x88\x97\x9D\x82\xB5\x82\xBD
+					message_processed = true;
+				}
+			}
+		}
+#endif
 
-	// Avoid multi entry
-	if (Busy) {
-		return FALSE;
+		if (IsDialogMessage(hWnd, &msg) != 0) {
+			/* \x8F\x88\x97\x9D\x82\xB3\x82ꂽ*/
+		} else {
+			TranslateMessage(&msg);
+			DispatchMessage(&msg);
+		}
+#if 0
+		if (!message_processed) {
+			TranslateMessage(&msg);
+			DispatchMessage(&msg);
+		}
+#endif
+
+		while (!PeekMessage(&msg, NULL, NULL, NULL, PM_NOREMOVE)) {
+			// \x83\x81\x83b\x83Z\x81[\x83W\x82\xAA\x82Ȃ\xA2
+			if (!OnIdle(lCount)) {
+				// idle\x95s\x97v
+				if (SleepTick < 500) {	// \x8Dő\xE5 501ms\x96\xA2\x96\x9E
+					SleepTick += 2;
+				}
+				lCount = 0;
+				Sleep(SleepTick);
+			} else {
+				// \x97vidle
+				SleepTick = 0;
+				lCount++;
+			}
+		}
 	}
-	Busy = TRUE;
-	if (m_pMainWnd != NULL) {
-		Continue = PCtrlWindow(m_pMainWnd)->OnIdle();
+	
+	//////////////////////////////////////////////////////////////////////
+
+	// TODO \x82\xB7\x82łɕ‚\xB6\x82\xE7\x82\xEA\x82Ă\xA2\x82\xE9\x81A\x82\xB1\x82̏\x88\x97\x9D\x95s\x97v?
+	if (pCCtrlWindow) {
+		pCCtrlWindow->DestroyWindow();
 	}
-	else {
-		Continue = FALSE;
-	}
-	Busy = FALSE;
-	return Continue;
+	pCCtrlWindow = NULL;
+	return ExitCode;
 }
+

Modified: branches/cmake/teraterm/ttpmacro/ttmacro.h
===================================================================
--- branches/cmake/teraterm/ttpmacro/ttmacro.h	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/ttpmacro/ttmacro.h	2018-11-03 15:33:07 UTC (rev 7256)
@@ -32,6 +32,7 @@
 /////////////////////////////////////////////////////////////////////////////
 // CCtrlApp:
 
+#if 0
 class CCtrlApp : public CWinApp
 {
 public:
@@ -49,3 +50,4 @@
 	//}}AFX_MSG
 	DECLARE_MESSAGE_MAP()
 };
+#endif

Modified: branches/cmake/teraterm/ttpmacro/ttmdlg.cpp
===================================================================
--- branches/cmake/teraterm/ttpmacro/ttmdlg.cpp	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/ttpmacro/ttmdlg.cpp	2018-11-03 15:33:07 UTC (rev 7256)
@@ -29,13 +29,15 @@
 
 /* TTMACRO.EXE, dialog boxes */
 
-#include "stdafx.h"
+#include <windows.h>
+#include <direct.h>
+#include <commdlg.h>
+#include <crtdbg.h>
+
 #include "teraterm.h"
-#include <direct.h>
 #include "ttm_res.h"
 #include "tttypes.h"
 #include "ttlib.h"
-#include <commdlg.h>
 #include "ttmdef.h"
 #include "errdlg.h"
 #include "inpdlg.h"
@@ -43,8 +45,20 @@
 #include "statdlg.h"
 #include "ListDlg.h"
 #include "ttmlib.h"
+#include "ttmdlg.h"
 
-extern "C" {
+#ifdef _DEBUG
+#define malloc(l)     _malloc_dbg((l), _NORMAL_BLOCK, __FILE__, __LINE__)
+#define realloc(p, l) _realloc_dbg((p), (l), _NORMAL_BLOCK, __FILE__, __LINE__)
+#define calloc(c, s)  _calloc_dbg((c), (s), _NORMAL_BLOCK, __FILE__, __LINE__)
+#define free(p)       _free_dbg((p), _NORMAL_BLOCK, __FILE__, __LINE__)
+#define strdup(s)	  _strdup_dbg((s), _NORMAL_BLOCK, __FILE__, __LINE__)
+#define _strdup(s)	  _strdup_dbg((s), _NORMAL_BLOCK, __FILE__, __LINE__)
+#endif
+
+extern HINSTANCE GetInstance();
+extern HWND GetHWND();
+
 char HomeDir[MAXPATHLEN];
 char FileName[MAX_PATH];
 char TopicName[11];
@@ -53,14 +67,12 @@
 int ParamCnt;
 int ParamsSize;
 BOOL SleepFlag;
-}
 
 static int DlgPosX = -10000;
 static int DlgPosY = 0;
 
-static PStatDlg StatDlg = NULL;
+static CStatDlg *StatDlg = NULL;
 
-extern "C" {
 void ParseParam(PBOOL IOption, PBOOL VOption)
 {
 	int dirlen, fnpos;
@@ -69,7 +81,7 @@
 	PCHAR start, cur, next;
 
 	// Get home directory
-	if (GetModuleFileName(AfxGetInstanceHandle(),FileName,sizeof(FileName)) == 0) {
+	if (GetModuleFileName(GetInstance(), FileName,sizeof(FileName)) == 0) {
 		return;
 	}
 	ExtractDirName(FileName,HomeDir);
@@ -157,9 +169,7 @@
 		}
 	}
 }
-}
 
-extern "C" {
 BOOL GetFileName(HWND HWin)
 {
 	char FNFilter[31];
@@ -206,9 +216,7 @@
 		return TRUE;
 	}
 }
-}
 
-extern "C" {
 void SetDlgPos(int x, int y)
 {
 	DlgPosX = x;
@@ -217,9 +225,7 @@
 		StatDlg->Update(NULL,NULL,DlgPosX,DlgPosY);
 	}
 }
-}
 
-extern "C" {
 void OpenInpDlg(PCHAR Buff, PCHAR Text, PCHAR Caption,
                 PCHAR Default, BOOL Paswd)
 {
@@ -226,25 +232,19 @@
 	CInpDlg InpDlg(Buff,Text,Caption,Default,Paswd,DlgPosX,DlgPosY);
 	InpDlg.DoModal();
 }
-}
 
-extern "C" {
 int OpenErrDlg(PCHAR Msg, PCHAR Line, int lineno, int start, int end, PCHAR FileName)
 {
 	CErrDlg ErrDlg(Msg,Line,DlgPosX,DlgPosY, lineno, start, end, FileName);
 	return ErrDlg.DoModal();
 }
-}
 
-extern "C" {
 int OpenMsgDlg(PCHAR Text, PCHAR Caption, BOOL YesNo)
 {
 	CMsgDlg MsgDlg(Text,Caption,YesNo,DlgPosX,DlgPosY);
 	return MsgDlg.DoModal();
 }
-}
 
-extern "C" {
 void OpenStatDlg(PCHAR Text, PCHAR Caption)
 {
 	if (StatDlg==NULL) {
@@ -256,9 +256,7 @@
 		StatDlg->Update(Text,Caption,32767,0);
 	}
 }
-}
 
-extern "C" {
 void CloseStatDlg()
 {
 	if (StatDlg==NULL) {
@@ -267,9 +265,7 @@
 	StatDlg->DestroyWindow();
 	StatDlg = NULL;
 }
-}
 
-extern "C" {
 void BringupStatDlg()
 {
 	if (StatDlg==NULL) {
@@ -277,18 +273,22 @@
 	}
 	StatDlg->Bringup();
 }
-}
 
-extern "C" {
+/**
+ * @retval 0\x88ȏ\xE3	\x91I\x91\xF0\x8D\x80\x96\xDA
+ * @retval -1		cancel\x83{\x83^\x83\x93
+ * @retval -2		close\x83{\x83^\x83\x93
+ */
 int OpenListDlg(PCHAR Text, PCHAR Caption, CHAR **Lists, int Selected)
 {
-	int ret = -1;
+	HINSTANCE hInst = GetInstance();
+	HWND hWnd = GetHWND();
 
 	CListDlg ListDlg(Text, Caption, Lists, Selected, DlgPosX, DlgPosY);
-	if (ListDlg.DoModal() == IDOK) {
-		ret = ListDlg.m_SelectItem;
+	INT_PTR r = ListDlg.DoModal();
+	if (r == IDOK) {
+		return ListDlg.m_SelectItem;
 	}
-	return (ret);
+	return r == IDCANCEL ? -1 : -2;
 }
-}
 

Modified: branches/cmake/teraterm/ttpmacro/ttmlib.c
===================================================================
--- branches/cmake/teraterm/ttpmacro/ttmlib.c	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/ttpmacro/ttmlib.c	2018-11-03 15:33:07 UTC (rev 7256)
@@ -33,7 +33,7 @@
 #include "ttlib.h"
 #include <string.h>
 #include <direct.h>
-#include <Shlobj.h>
+#include <shlobj.h>
 
 static char CurrentDir[MAXPATHLEN];
 
@@ -216,3 +216,29 @@
 		AttachThreadInput(thisThreadId, fgThreadId, FALSE);
 	}
 }
+
+/**
+ * \x95\xB6\x8E\x9A\x82\xF0\x95`\x89悵\x82\xBD\x8E\x9E\x82ǂ\xF1\x82Ȕ͈͂ɂȂ邩\x8Cv\x8EZ\x82\xB7\x82\xE9
+ */
+void CalcTextExtent2(HWND hWnd, HFONT Font, const TCHAR *Text, LPSIZE textSize)
+{
+	HDC TmpDC = GetDC(hWnd);
+	HFONT prevFont = NULL;
+	if (Font) {
+		prevFont = (HFONT)SelectObject(TmpDC, Font);
+	}
+	CalcTextExtent(TmpDC, (PCHAR)Text, textSize);
+	if (Font && prevFont != NULL) {
+		SelectObject(TmpDC, prevFont);
+	}
+	ReleaseDC(hWnd, TmpDC);
+}
+
+int MessageBoxHaltScript(HWND hWnd, const char *UILanguageFile)
+{
+	char uimsg[MAX_UIMSG];
+	char uimsg2[MAX_UIMSG];
+	get_lang_msg("MSG_MACRO_CONF", uimsg, sizeof(uimsg), "MACRO: confirmation", UILanguageFile);
+	get_lang_msg("MSG_MACRO_HALT_SCRIPT", uimsg2, sizeof(uimsg2), "Are you sure that you want to halt this macro script?", UILanguageFile);
+	return MessageBox(hWnd, uimsg2, uimsg, MB_YESNO | MB_ICONWARNING | MB_DEFBUTTON2);
+}

Modified: branches/cmake/teraterm/ttpmacro/ttmlib.h
===================================================================
--- branches/cmake/teraterm/ttpmacro/ttmlib.h	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/ttpmacro/ttmlib.h	2018-11-03 15:33:07 UTC (rev 7256)
@@ -36,6 +36,7 @@
 extern char UILanguageFile[MAX_PATH];
 
 void CalcTextExtent(HDC DC, PCHAR Text, LPSIZE s);
+void CalcTextExtent2(HWND hWnd, HFONT Font, const TCHAR *Text, LPSIZE textSize);	// TODO name
 void TTMGetDir(PCHAR Dir, int destlen);
 void TTMSetDir(PCHAR Dir);
 int GetAbsPath(PCHAR FName, int destlen);
@@ -42,6 +43,7 @@
 int GetSpecialFolder(PCHAR dest, int dest_len, PCHAR type);
 int GetMonitorLeftmost(int PosX, int PosY);
 void BringupWindow(HWND hWnd);
+int MessageBoxHaltScript(HWND hWnd);
 
 #ifdef __cplusplus
 }

Modified: branches/cmake/teraterm/ttpmacro/ttmmain.cpp
===================================================================
--- branches/cmake/teraterm/ttpmacro/ttmmain.cpp	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/ttpmacro/ttmmain.cpp	2018-11-03 15:33:07 UTC (rev 7256)
@@ -29,7 +29,9 @@
 
 /* TTMACRO.EXE, main */
 
-#include "stdafx.h"
+#include <windows.h>
+#include <commctrl.h>
+#include <stdio.h>
 #include "teraterm.h"
 #include "ttm_res.h"
 #include "ttmdlg.h"
@@ -40,27 +42,60 @@
 #include "ttmmain.h"
 #include "ttmbuff.h"
 #include "ttmlib.h"
+#include "dlglib.h"
 
 #include "ttlib.h"
 
 #include "wait4all.h"
 
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
+#include "tmfc.h"
 
+extern HINSTANCE GetInstance();
+
+static void ClientToScreen(HWND hWnd, RECT *rect)
+{
+	POINT pos;
+	pos.x = rect->left;
+	pos.y = rect->top;
+	::ClientToScreen(hWnd, &pos);
+	rect->left = pos.x;
+	rect->top = pos.y;
+
+	pos.x = rect->right;
+	pos.y = rect->bottom;
+	::ClientToScreen(hWnd, &pos);
+	rect->right = pos.x;
+	rect->bottom = pos.y;
+}
+
+static void ScreenToClient(HWND hWnd, RECT *rect)
+{
+	POINT pos;
+	pos.x = rect->left;
+	pos.y = rect->top;
+	::ScreenToClient(hWnd, &pos);
+	rect->left = pos.x;
+	rect->top = pos.y;
+
+	pos.x = rect->right;
+	pos.y = rect->bottom;
+	::ScreenToClient(hWnd, &pos);
+	rect->right = pos.x;
+	rect->bottom = pos.y;
+}
+
 // CCtrlWindow dialog
 CCtrlWindow::CCtrlWindow()
-	: CDialog()
 {
-	m_hIcon = AfxGetApp()->LoadIcon(IDI_TTMACRO);
+	HINSTANCE hInst = GetInstance();
+	m_hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_TTMACRO));
 }
 
 BOOL CCtrlWindow::Create()
 {
-	if (! CDialog::Create(CCtrlWindow::IDD, NULL)) {
+	HINSTANCE hInst = GetInstance();
+	HWND parent = NULL;
+	if (! TTCDialog::Create(hInst, parent, CCtrlWindow::IDD)) {
 		PostQuitMessage(0);
 		return FALSE;
 	}
@@ -105,7 +140,7 @@
 		// \x8DX\x90V\x91Ώۂ̃}\x83N\x83\x8D\x83R\x83}\x83\x93\x83h\x82̏ꍇ\x82̂݁A\x83E\x83B\x83\x93\x83h\x83E\x82ɍX\x90V\x8Ew\x8E\xA6\x82\xF0\x8Fo\x82\xB7\x81B
 		// \x96\x88\x93x WM_PAINT \x82𑗂\xC1\x82Ă\xA2\x82\xE9\x82ƃ}\x83N\x83\x8D\x82̓\xAE\x8D삪\x92x\x82\xAD\x82Ȃ邽\x82߁B(2006.2.24 yutaka)
 		if (IsUpdateMacroCommand()) {
-			Invalidate(TRUE);
+			::InvalidateRect(m_hWnd, NULL, TRUE);
 		}
 		return TRUE;
 	}
@@ -112,7 +147,7 @@
 	else if (TTLStatus==IdTTLWait) {
 		ResultCode = Wait();
 		if (ResultCode>0) {
-			KillTimer(IdTimeOutTimer);
+			::KillTimer(m_hWnd, IdTimeOutTimer);
 			TTLStatus = IdTTLRun;
 			LockVar();
 			SetResult(ResultCode);
@@ -121,7 +156,7 @@
 			return TRUE;
 		}
 		else if (ComReady==0) {
-			SetTimer(IdTimeOutTimer,0, NULL);
+			::SetTimer(m_hWnd, IdTimeOutTimer,0, NULL);
 		}
 	}
 	else if (TTLStatus==IdTTLWaitLn) {
@@ -133,7 +168,7 @@
 			Temp[0] = 0x0a;
 			Temp[1] = 0;
 			if (CmpWait(ResultCode,Temp)==0) { // new-line is received
-				KillTimer(IdTimeOutTimer);
+				::KillTimer(m_hWnd, IdTimeOutTimer);
 				ClearWait();
 				TTLStatus = IdTTLRun;
 				LockVar();
@@ -148,13 +183,13 @@
 			return TRUE;
 		}
 		else if (ComReady==0) {
-			SetTimer(IdTimeOutTimer,0, NULL);
+			::SetTimer(m_hWnd, IdTimeOutTimer,0, NULL);
 		}
 	}
 	else if (TTLStatus==IdTTLWaitNL) {
 		ResultCode = Wait();
 		if (ResultCode>0) {
-			KillTimer(IdTimeOutTimer);
+			::KillTimer(m_hWnd, IdTimeOutTimer);
 			TTLStatus = IdTTLRun;
 			LockVar();
 			SetInputStr(GetRecvLnBuff());
@@ -162,12 +197,12 @@
 			return TRUE;
 		}
 		else if (ComReady==0) {
-			SetTimer(IdTimeOutTimer,0, NULL);
+			::SetTimer(m_hWnd, IdTimeOutTimer,0, NULL);
 		}
 	}
 	else if (TTLStatus==IdTTLWait2) {
 		if (Wait2()) {
-			KillTimer(IdTimeOutTimer);
+			::KillTimer(m_hWnd, IdTimeOutTimer);
 			TTLStatus = IdTTLRun;
 			LockVar();
 			SetInputStr(Wait2Str);
@@ -176,12 +211,12 @@
 			return TRUE;
 		}
 		else if (ComReady==0) {
-			SetTimer(IdTimeOutTimer,0, NULL);
+			::SetTimer(m_hWnd, IdTimeOutTimer,0, NULL);
 		}
 	}
 	else if (TTLStatus==IdTTLWaitN) {
 		if (WaitN()) {
-			KillTimer(IdTimeOutTimer);
+			::KillTimer(m_hWnd, IdTimeOutTimer);
 			TTLStatus = IdTTLRun;
 			LockVar();
 			SetResult(1);
@@ -191,13 +226,13 @@
 			return TRUE;
 		}
 		else if (ComReady==0) {
-			SetTimer(IdTimeOutTimer,0, NULL);
+			::SetTimer(m_hWnd, IdTimeOutTimer,0, NULL);
 		}
 	}
 	else if (TTLStatus==IdTTLWait4all) {
 		ResultCode = Wait4all();
 		if (ResultCode>0) {
-			KillTimer(IdTimeOutTimer);
+			::KillTimer(m_hWnd, IdTimeOutTimer);
 			TTLStatus = IdTTLRun;
 			LockVar();
 			SetResult(ResultCode);
@@ -206,7 +241,7 @@
 			return TRUE;
 		}
 		else if (ComReady==0) {
-			SetTimer(IdTimeOutTimer,0, NULL);
+			::SetTimer(m_hWnd, IdTimeOutTimer,0, NULL);
 		}
 	}
 
@@ -213,6 +248,7 @@
 	return FALSE;
 }
 
+#if 0
 BEGIN_MESSAGE_MAP(CCtrlWindow, CDialog)
 	//{{AFX_MSG_MAP(CCtrlWindow)
 	ON_WM_CLOSE()
@@ -231,11 +267,16 @@
 	ON_MESSAGE(WM_USER_DDEEND,OnDdeEnd)
 	//}}AFX_MSG_MAP
 END_MESSAGE_MAP()
+#endif
 
 // CCtrlWindow message handler
 
 BOOL CCtrlWindow::OnInitDialog()
 {
+	static const DlgTextInfo TextInfos[] = {
+		{ IDC_CTRLPAUSESTART, "BTN_PAUSE" },
+		{ IDC_CTRLEND, "BTN_END" },
+	};
 	HDC TmpDC;
 	int CRTWidth, CRTHeight;
 	RECT Rect;
@@ -242,35 +283,20 @@
 	char Temp[MAX_PATH + 8]; // MAX_PATH + "MACRO - "(8)
 	BOOL IOption, VOption;
 	int CmdShow;
-	char uimsg[MAX_UIMSG], uimsg2[MAX_UIMSG];
-	LOGFONT logfont;
-	HFONT font;
 	int fuLoad = LR_DEFAULTCOLOR;
 	RECT rc_dlg, rc_filename, rc_lineno;
 	LONG dlg_len, len;
+	HINSTANCE hInst = GetInstance();
 
-	CDialog::OnInitDialog();
+	SetDlgTexts(m_hWnd, TextInfos, _countof(TextInfos), UILanguageFile);
 
-	font = (HFONT)SendMessage(WM_GETFONT, 0, 0);
-	GetObject(font, sizeof(LOGFONT), &logfont);
-	if (get_lang_font("DLG_SYSTEM_FONT", m_hWnd, &logfont, &DlgFont, UILanguageFile)) {
-		SendDlgItemMessage(IDC_CTRLPAUSESTART, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-		SendDlgItemMessage(IDC_CTRLEND, WM_SETFONT, (WPARAM)DlgFont, MAKELPARAM(TRUE,0));
-	}
-
-	GetDlgItemText(IDC_CTRLPAUSESTART, uimsg2, sizeof(uimsg2));
-	get_lang_msg("BTN_PAUSE", uimsg, sizeof(uimsg), uimsg2, UILanguageFile);
-	SetDlgItemText(IDC_CTRLPAUSESTART, uimsg);
-	GetDlgItemText(IDC_CTRLEND, uimsg2, sizeof(uimsg2));
-	get_lang_msg("BTN_END", uimsg, sizeof(uimsg), uimsg2, UILanguageFile);
-	SetDlgItemText(IDC_CTRLEND, uimsg);
-
 	Pause = FALSE;
 
+	// \x83Z\x83\x93\x83^\x81[\x82Ɏ\x9D\x82\xC1\x82Ă\xA2\x82\xAD
 	TmpDC = ::GetDC(GetSafeHwnd());
-	CRTWidth = GetDeviceCaps(TmpDC,HORZRES);
-	CRTHeight = GetDeviceCaps(TmpDC,VERTRES);
-	GetWindowRect(&Rect);
+	CRTWidth = ::GetDeviceCaps(TmpDC,HORZRES);
+	CRTHeight = ::GetDeviceCaps(TmpDC,VERTRES);
+	::GetWindowRect(m_hWnd, &Rect);
 	::ReleaseDC(GetSafeHwnd(), TmpDC);
 	::SetWindowPos(GetSafeHwnd(),HWND_TOP,
 	               (CRTWidth-Rect.right+Rect.left) / 2,
@@ -281,16 +307,16 @@
 		fuLoad = LR_VGACOLOR;
 	}
 	::PostMessage(GetSafeHwnd(),WM_SETICON,ICON_SMALL,
-	              (LPARAM)LoadImage(AfxGetInstanceHandle(),
+	              (LPARAM)LoadImage(hInst,
 	                                MAKEINTRESOURCE(IDI_TTMACRO),
 	                                IMAGE_ICON,16,16,fuLoad));
 	::PostMessage(GetSafeHwnd(),WM_SETICON,ICON_BIG,
-	              (LPARAM)LoadImage(AfxGetInstanceHandle(),
+	              (LPARAM)LoadImage(hInst,
 	                                MAKEINTRESOURCE(IDI_TTMACRO),
 	                                IMAGE_ICON,0,0,fuLoad));
 
 	ParseParam(&IOption,&VOption);
-
+#if 1
 	if (TopicName[0] != 0) {
 		InitDDE(GetSafeHwnd());
 	}
@@ -308,7 +334,7 @@
 
 	// wait4all
 	register_macro_window(GetSafeHwnd());
-
+#endif
 	strncpy_s(Temp, sizeof(Temp), "MACRO - ", _TRUNCATE);
 	strncat_s(Temp, sizeof(Temp), ShortName, _TRUNCATE);
 	SetWindowText(Temp);
@@ -325,20 +351,20 @@
 	 * (2015.1.2 yutaka)
 	 */
 	// \x8C\xBB\x8D݃T\x83C\x83Y\x82\xA9\x82\xE7\x95K\x97v\x82Ȓl\x82\xF0\x8Cv\x8EZ
-	GetClientRect(&rc_dlg);
-	ClientToScreen(&rc_dlg);
+	::GetClientRect(m_hWnd, &rc_dlg);
+	ClientToScreen(m_hWnd, &rc_dlg);
 	dlg_len = rc_dlg.right - rc_dlg.left;
 
-	GetDlgItem(IDC_FILENAME)->GetWindowRect(&rc_filename);
+	::GetWindowRect(GetDlgItem(IDC_FILENAME), &rc_filename);
 	len = rc_filename.right - rc_filename.left;
 	m_filename_ratio = len*100 / dlg_len;
 
-	GetDlgItem(IDC_LINENO)->GetWindowRect(&rc_lineno);
+	::GetWindowRect(GetDlgItem(IDC_LINENO), &rc_lineno);
 	len = rc_lineno.right - rc_lineno.left;
 	m_lineno_ratio = len * 100 / dlg_len;
 
 	// \x83\x8A\x83T\x83C\x83Y\x83A\x83C\x83R\x83\x93\x82\xF0\x89E\x89\xBA\x82ɕ\\x8E\xA6\x82\xB3\x82\xB9\x82\xBD\x82\xA2\x82̂ŁA\x83X\x83e\x81[\x83^\x83X\x83o\x81[\x82\xF0\x95t\x82\xAF\x82\xE9\x81B
-	m_hStatus = CreateStatusWindow(
+	m_hStatus = ::CreateStatusWindow(
 		WS_CHILD | WS_VISIBLE |
 		CCS_BOTTOM | SBARS_SIZEGRIP, NULL, GetSafeHwnd(), 1);
 
@@ -356,10 +382,13 @@
 	return TRUE;
 }
 
-void CCtrlWindow::OnCancel( )
+BOOL CCtrlWindow::OnCancel( )
 {
+#if 1
 	::DestroyWindow(m_hStatus);
 	DestroyWindow();
+#endif
+	return TRUE;	// cancel(ESC\x89\x9F\x89\xBA)\x82𖳎\x8B
 }
 
 BOOL CCtrlWindow::OnCommand(WPARAM wParam, LPARAM lParam)
@@ -367,30 +396,31 @@
 	char uimsg[MAX_UIMSG];
 
 	switch (LOWORD(wParam)) {
-		case IDC_CTRLPAUSESTART:
-			if (Pause) {
-				get_lang_msg("BTN_PAUSE", uimsg, sizeof(uimsg),  "Pau&se", UILanguageFile);
-				SetDlgItemText(IDC_CTRLPAUSESTART, uimsg);
-			}
-			else {
-				get_lang_msg("BTN_START", uimsg, sizeof(uimsg),  "&Start", UILanguageFile);
-				SetDlgItemText(IDC_CTRLPAUSESTART, uimsg);
-			}
-			Pause = ! Pause;
-			return TRUE;
-		case IDC_CTRLEND:
-			TTLStatus = IdTTLEnd;
-			return TRUE;
-		default:
-			return (CDialog::OnCommand(wParam,lParam));
+	case IDC_CTRLPAUSESTART:
+		if (Pause) {
+			get_lang_msg("BTN_PAUSE", uimsg, sizeof(uimsg),  "Pau&se", UILanguageFile);
+			SetDlgItemText(IDC_CTRLPAUSESTART, uimsg);
+		}
+		else {
+			get_lang_msg("BTN_START", uimsg, sizeof(uimsg),  "&Start", UILanguageFile);
+			SetDlgItemText(IDC_CTRLPAUSESTART, uimsg);
+		}
+		Pause = ! Pause;
+		return TRUE;
+	case IDC_CTRLEND:
+		TTLStatus = IdTTLEnd;
+		PostQuitMessage(0);
+		return TRUE;
+	default:
+		return FALSE;
 	}
 }
 
-void CCtrlWindow::OnClose()
+BOOL CCtrlWindow::OnClose()
 {
 	EndTTL();
 	EndDDE();
-	CDialog::OnClose();
+	return TRUE;
 }
 
 void CCtrlWindow::OnDestroy()
@@ -399,17 +429,17 @@
 
 	EndTTL();
 	EndDDE();
-	CDialog::OnDestroy();
+//	CDialog::OnDestroy();
 }
 
 // for icon drawing in Win NT 3.5
-BOOL CCtrlWindow::OnEraseBkgnd(CDC* pDC)
+BOOL CCtrlWindow::OnEraseBkgnd(HDC DC)
 {
-	if (IsIconic()) {
+	if (::IsIconic(m_hWnd)) {
 		return TRUE;
 	}
 	else {
-		return CDialog::OnEraseBkgnd(pDC);
+		return FALSE;
 	}
 }
 
@@ -416,10 +446,12 @@
 // for icon drawing in Win NT 3.5
 void CCtrlWindow::OnPaint()
 {
-	int OldMapMode;
-	CPaintDC dc(this);
+	PAINTSTRUCT ps;
+	HDC dc;
 	char buf[128];
 
+	dc = BeginPaint(&ps);
+
 	// line number (2005.7.18 yutaka)
 	// added line buffer (2005.7.22 yutaka)
 	// added MACRO filename (2013.9.8 yutaka)
@@ -428,13 +460,15 @@
 	_snprintf_s(buf, sizeof(buf), _TRUNCATE, ":%d:%s", GetLineNo(), GetLineBuffer());
 	SetDlgItemText(IDC_LINENO, buf);
 
-	OldMapMode = dc.GetMapMode();
-	dc.SetMapMode(MM_TEXT);
+	if (::IsIconic(m_hWnd)) {
+		int OldMapMode = GetMapMode(dc);
+		SetMapMode(dc, MM_TEXT);
+		SendMessage(WM_ICONERASEBKGND,(UINT)dc, 0);	// TODO
+		DrawIcon(dc, 0, 0, m_hIcon);
+		SetMapMode(dc, OldMapMode);
+	}
 
-	if (!IsIconic()) return;
-	SendMessage(WM_ICONERASEBKGND,(UINT)(dc.m_hDC));
-	dc.DrawIcon(0, 0, m_hIcon);
-	dc.SetMapMode(OldMapMode);
+	EndPaint(&ps);
 }
 
 // \x83}\x83N\x83\x8D\x83E\x83B\x83\x93\x83h\x83E\x82\xF0\x83\x8A\x83T\x83C\x83Y\x89”\\x82Ƃ\xB7\x82邽\x82߂ɁAOnSize\x83n\x83\x93\x83h\x83\x89\x82\xF0override\x82\xB7\x82\xE9\x81B
@@ -445,16 +479,17 @@
 	LONG new_w, new_h, new_x, new_y;
 	LONG len;
 
-	GetClientRect(&rc_dlg);
-	ClientToScreen(&rc_dlg);
+	::GetClientRect(m_hWnd, &rc_dlg);
+	ClientToScreen(m_hWnd, &rc_dlg);
 	len = rc_dlg.right - rc_dlg.left;
 
 	// TTL\x83t\x83@\x83C\x83\x8B\x96\xBC\x82̍Ĕz\x92u
-	GetDlgItem(IDC_FILENAME)->GetWindowRect(&rc_filename);
-	ScreenToClient(&rc_filename);
+	HWND hWnd = GetDlgItem(IDC_FILENAME);
+	::GetWindowRect(hWnd, &rc_filename);
+	ScreenToClient(m_hWnd, &rc_filename);
 	new_w = (len * m_filename_ratio) / 100;
 	new_h = rc_filename.bottom - rc_filename.top;
-	GetDlgItem(IDC_FILENAME)->SetWindowPos(&CWnd::wndBottom,
+	::SetWindowPos(hWnd, HWND_BOTTOM,
 		0, 0, new_w, new_h,
 		SWP_NOMOVE | SWP_NOZORDER
 	);
@@ -461,18 +496,19 @@
 	new_x = rc_filename.left + new_w;
 
 	// \x8Ds\x94ԍ\x86\x82̍Ĕz\x92u
-	GetDlgItem(IDC_LINENO)->GetWindowRect(&rc_lineno);
-	ScreenToClient(&rc_lineno);
+	hWnd = GetDlgItem(IDC_LINENO);
+	::GetWindowRect(hWnd, &rc_lineno);
+	ScreenToClient(m_hWnd, &rc_lineno);
 	new_w = (len * m_lineno_ratio) / 100;
 	new_h = rc_lineno.bottom - rc_lineno.top;
 	new_y = rc_lineno.top;
-	GetDlgItem(IDC_LINENO)->SetWindowPos(&CWnd::wndBottom,
+	::SetWindowPos(hWnd, HWND_BOTTOM,
 		new_x, new_y, new_w, new_h,
 		SWP_NOZORDER
 		);
 
 	// status bar
-	::SendMessage(m_hStatus, WM_SIZE, cx, cy);
+	::SendMessage(m_hStatus, WM_SIZE, nType, (cy<<16)|cx );
 }
 
 // \x83}\x83N\x83\x8D\x83E\x83B\x83\x93\x83h\x83E\x82\xF0\x83\x8A\x83T\x83C\x83Y\x89”\\x82Ƃ\xB7\x82邽\x82߂ɁAOnGetMinMaxInfo\x83n\x83\x93\x83h\x83\x89\x82\xF0override\x82\xB7\x82\xE9\x81B
@@ -497,16 +533,18 @@
 	return m_hIcon;
 }
 
+#if 0
 void CCtrlWindow::OnSysColorChange()
 {
 	CDialog::OnSysColorChange();
 }
+#endif
 
 void CCtrlWindow::OnTimer(UINT_PTR nIDEvent)
 {
 	BOOL TimeOut;
 
-	KillTimer(nIDEvent);
+	::KillTimer(m_hWnd, nIDEvent);
 	if (nIDEvent!=IdTimeOutTimer) {
 		return;
 	}
@@ -576,15 +614,17 @@
 		return;
 	}
 
-	SetTimer(IdTimeOutTimer, TIMEOUT_TIMER_MS, NULL);
+	::SetTimer(m_hWnd, IdTimeOutTimer, TIMEOUT_TIMER_MS, NULL);
 }
 
-void CCtrlWindow::PostNcDestroy()
+BOOL CCtrlWindow::PostNcDestroy()
 {
 	delete this;
 	PostQuitMessage(0);
+	return TRUE;
 }
 
+#if 0
 BOOL CCtrlWindow::PreTranslateMessage(MSG* pMsg)
 {
 	if ((pMsg->message==WM_KEYDOWN) && (pMsg->wParam==VK_ESCAPE)) { // ignore ESC key
@@ -592,6 +632,7 @@
 	}
 	return CDialog::PreTranslateMessage(pMsg);
 }
+#endif
 
 LRESULT CCtrlWindow::OnDdeCmndEnd(WPARAM wParam, LPARAM lParam)
 {
@@ -617,7 +658,7 @@
 	    (TTLStatus == IdTTLWait2) ||
 	    (TTLStatus == IdTTLWaitN)) {
 		if (ComReady==0) {
-			SetTimer(IdTimeOutTimer,0, NULL);
+			::SetTimer(m_hWnd, IdTimeOutTimer,0, NULL);
 		}
 	}
 	else if (TTLStatus==IdTTLSleep) {
@@ -674,7 +715,7 @@
 	         (TTLStatus == IdTTLWaitNL) ||
 	         (TTLStatus == IdTTLWait2) ||
 	         (TTLStatus == IdTTLWaitN)) {
-		SetTimer(IdTimeOutTimer,0, NULL);
+		::SetTimer(m_hWnd, IdTimeOutTimer,0, NULL);
 	}
 	else if (TTLStatus==IdTTLSleep) {
 		LockVar();
@@ -701,13 +742,64 @@
 	fgThreadId = GetWindowThreadProcessId(::GetForegroundWindow(), &pid);
 
 	if (thisThreadId == fgThreadId) {
-		SetForegroundWindow();
-		BringWindowToTop();
+		::SetForegroundWindow(m_hWnd);
+		::BringWindowToTop(m_hWnd);
 	} else {
 		AttachThreadInput(thisThreadId, fgThreadId, TRUE);
-		SetForegroundWindow();
-		BringWindowToTop();
+		::SetForegroundWindow(m_hWnd);
+		::BringWindowToTop(m_hWnd);
 		AttachThreadInput(thisThreadId, fgThreadId, FALSE);
 	}
 	return 0;
 }
+
+LRESULT CCtrlWindow::DlgProc(UINT msg, WPARAM wp, LPARAM lp)
+{
+	switch(msg)
+	{
+#if 0	// tmfc\x82ŏ\x88\x97\x9D\x82\xB3\x82\xEA\x82\xE9
+	case WM_CLOSE:
+		OnClose();
+		break;
+#endif
+	case WM_DESTROY:
+		OnDestroy();
+		PostQuitMessage(0);
+		break;
+	case WM_ERASEBKGND:
+		OnEraseBkgnd((HDC)wp);
+		break;
+	case WM_PAINT:
+		OnPaint();
+		break;
+	case WM_SIZE:
+		OnSize(wp, LOWORD(lp), HIWORD(lp));
+		break;
+	case WM_GETMINMAXINFO:
+		OnGetMinMaxInfo((MINMAXINFO *)lp);
+		break;
+#if 0
+	case WM_QUERYDRAGICON:
+	case WM_SYSCOLORCHANGE:
+#endif
+	case WM_TIMER:
+		OnTimer(wp);
+		break;
+	case WM_USER_DDECMNDEND:
+		OnDdeCmndEnd(wp, lp);
+		break;
+	case WM_USER_DDECOMREADY:
+		OnDdeComReady(wp, lp);
+		break;
+	case WM_USER_DDEREADY:
+		OnDdeReady(wp, lp);
+		break;
+	case WM_USER_MACROBRINGUP:
+		OnMacroBringup(wp, lp);
+		break;
+	case WM_USER_DDEEND:
+		OnDdeEnd(wp, lp);
+		break;
+	}
+	return FALSE;
+}

Modified: branches/cmake/teraterm/ttpmacro/ttmmain.h
===================================================================
--- branches/cmake/teraterm/ttpmacro/ttmmain.h	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/ttpmacro/ttmmain.h	2018-11-03 15:33:07 UTC (rev 7256)
@@ -29,12 +29,13 @@
 
 /* TTMACRO.EXE, main window */
 
+#include "tmfc.h"
 #include "ttmmsg.h"
 #include "tttypes.h"
 /////////////////////////////////////////////////////////////////////////////
 // CCtrlWindow dialog
 
-class CCtrlWindow : public CDialog
+class CCtrlWindow : public TTCDialog
 {
 public:
 	BOOL Pause;
@@ -49,11 +50,13 @@
 
 	//{{AFX_VIRTUAL(CCtrlWindow)
 	protected:
-	virtual void OnCancel( );
+	virtual BOOL OnCancel( );
 	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
-	virtual void PostNcDestroy();
-	virtual BOOL PreTranslateMessage(MSG* pMsg);
+	virtual BOOL PostNcDestroy();
+	virtual BOOL OnInitDialog();
+	//	virtual BOOL PreTranslateMessage(MSG* pMsg);		// TODO
 	//}}AFX_VIRTUAL
+	virtual LRESULT DlgProc(UINT msg, WPARAM wp, LPARAM lp);
 
 protected:
 	HICON m_hIcon;
@@ -64,10 +67,10 @@
 	HWND m_hStatus;
 
 	//{{AFX_MSG(CCtrlWindow)
-	virtual BOOL OnInitDialog();
-	afx_msg void OnClose();
+#define afx_msg
+	afx_msg BOOL OnClose();
 	afx_msg void OnDestroy();
-	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
+	afx_msg BOOL OnEraseBkgnd(HDC DC);
 	afx_msg void OnPaint();
 	afx_msg void OnSize(UINT nType, int cx, int cy);
 	afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
@@ -80,7 +83,6 @@
 	afx_msg LRESULT OnDdeEnd(WPARAM wParam, LPARAM lParam);
 	afx_msg LRESULT OnMacroBringup(WPARAM wParam, LPARAM lParam);
 	//}}AFX_MSG
-	DECLARE_MESSAGE_MAP()
+//	DECLARE_MESSAGE_MAP()
 };
 
-typedef CCtrlWindow *PCtrlWindow;

Modified: branches/cmake/teraterm/ttpmacro/ttmparse.c
===================================================================
--- branches/cmake/teraterm/ttpmacro/ttmparse.c	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/ttpmacro/ttmparse.c	2018-11-03 15:33:07 UTC (rev 7256)
@@ -33,10 +33,19 @@
 #include <string.h>
 #include <stdio.h>
 #include <ctype.h>
+#include <crtdbg.h>
 #include "ttmdlg.h"
 #include "ttmparse.h"
 #include "ttmbuff.h"
 
+#ifdef _DEBUG
+
+#define malloc(l)     _malloc_dbg((l), _NORMAL_BLOCK, __FILE__, __LINE__)
+#define realloc(p, l) _realloc_dbg((p), (l), _NORMAL_BLOCK, __FILE__, __LINE__)
+#define calloc(c, s)  _calloc_dbg((c), (s), _NORMAL_BLOCK, __FILE__, __LINE__)
+#define free(p)       _free_dbg((p), _NORMAL_BLOCK, __FILE__, __LINE__)
+#endif
+
 /* C\x8C\xBE\x8C\xEA\x83X\x83^\x83C\x83\x8B\x82̃R\x83\x81\x83\x93\x83g\x82\xF0\x83T\x83|\x81[\x83g\x82\xB7\x82邩\x82ǂ\xA4\x82\xA9 (2009.7.2 yutaka) */
 #define SUPPORT_C_STYLE_COMMENT
 static int commenting = 0;   /* C\x8C\xBE\x8C\xEA\x83R\x83\x81\x83\x93\x83g */

Modified: branches/cmake/teraterm/ttpmacro/ttpmacro.rc
===================================================================
--- branches/cmake/teraterm/ttpmacro/ttpmacro.rc	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/ttpmacro/ttpmacro.rc	2018-11-03 15:33:07 UTC (rev 7256)
@@ -1,6 +1,8 @@
 // Microsoft Visual C++ generated resource script.
 //
+#include <windows.h>
 #include "ttm_res.h"
+#define IDC_STATIC 0
 
 #define APSTUDIO_READONLY_SYMBOLS
 /////////////////////////////////////////////////////////////////////////////
@@ -7,7 +9,7 @@
 //
 // Generated from the TEXTINCLUDE 2 resource.
 //
-#include "afxres.h"
+//#include "afxres.h"
 
 /////////////////////////////////////////////////////////////////////////////
 #undef APSTUDIO_READONLY_SYMBOLS
@@ -85,13 +87,13 @@
     DEFPUSHBUTTON   "OK",IDOK,54,36,34,14
 END
 
-IDD_MSGDLG DIALOGEX 0, 0, 80, 43
-STYLE DS_SETFONT | DS_3DLOOK | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
+IDD_MSGDLG DIALOGEX 0, 0, 81, 43
+STYLE DS_SETFONT | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
 FONT 14, "System", 0, 0, 0x0
 BEGIN
     DEFPUSHBUTTON   "OK",IDOK,0,31,35,12
     LTEXT           "",IDC_MSGTEXT,0,8,65,9,SS_NOPREFIX
-    PUSHBUTTON      "No",IDCLOSE,45,31,35,12,NOT WS_VISIBLE
+    PUSHBUTTON      "No",IDCANCEL,45,31,35,12,NOT WS_VISIBLE
 END
 
 IDD_STATDLG DIALOGEX 0, 0, 52, 25
@@ -108,8 +110,8 @@
 BEGIN
     DEFPUSHBUTTON   "OK",IDOK,129,7,50,14
     PUSHBUTTON      "Cancel",IDCANCEL,129,24,50,14
-    LISTBOX         IDC_LISTBOX,7,7,104,49,LBS_SORT | LBS_USETABSTOPS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP
-    LTEXT           "Static",IDC_STATIC,7,63,172,15
+    LISTBOX         IDC_LISTBOX,7,7,104,49,LBS_USETABSTOPS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP
+    LTEXT           "Static",IDC_LISTTEXT,7,63,172,15
 END
 
 
@@ -119,7 +121,7 @@
 //
 
 #ifdef APSTUDIO_INVOKED
-GUIDELINES DESIGNINFO 
+GUIDELINES DESIGNINFO
 BEGIN
     IDD_CTRLWIN, DIALOG
     BEGIN
@@ -131,6 +133,15 @@
         RIGHTMARGIN, 260
     END
 
+    IDD_INPDLG, DIALOG
+    BEGIN
+    END
+
+    IDD_MSGDLG, DIALOG
+    BEGIN
+        RIGHTMARGIN, 80
+    END
+
     IDD_LISTDLG, DIALOG
     BEGIN
         LEFTMARGIN, 7
@@ -150,7 +161,25 @@
 // Icon with lowest ID value placed first to ensure application icon
 // remains consistent on all systems.
 IDI_TTMACRO             ICON                    "ttmacro.ico"
+
 IDI_TTMACRO_3D          ICON                    "ttmacro_3d.ico"
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// AFX_DIALOG_LAYOUT
+//
+
+IDD_INPDLG AFX_DIALOG_LAYOUT
+BEGIN
+    0
+END
+
+IDD_MSGDLG AFX_DIALOG_LAYOUT
+BEGIN
+    0
+END
+
 #endif    // \x89p\x8C\xEA (\x95č\x91) resources
 /////////////////////////////////////////////////////////////////////////////
 

Modified: branches/cmake/teraterm/ttpset/CMakeLists.txt
===================================================================
--- branches/cmake/teraterm/ttpset/CMakeLists.txt	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/ttpset/CMakeLists.txt	2018-11-03 15:33:07 UTC (rev 7256)
@@ -58,6 +58,8 @@
 target_link_libraries(
   ttpset
   ttpcmn
+  #
+  gdi32
   )
 
 add_dependencies(

Modified: branches/cmake/teraterm/ttptek/CMakeLists.txt
===================================================================
--- branches/cmake/teraterm/ttptek/CMakeLists.txt	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/teraterm/ttptek/CMakeLists.txt	2018-11-03 15:33:07 UTC (rev 7256)
@@ -73,10 +73,12 @@
 target_link_libraries(
   ttptek
   ttpcmn
-  debug sfmtd.lib
-  optimized sfmt.lib
-  iphlpapi.lib
-  htmlhelp.lib
+  debug sfmtd
+  optimized sfmt
+  #
+  iphlpapi
+  htmlhelp
+  gdi32
   )
 
 add_dependencies(

Added: branches/cmake/tests/gui_commands_test.ttl
===================================================================
--- branches/cmake/tests/gui_commands_test.ttl	                        (rev 0)
+++ branches/cmake/tests/gui_commands_test.ttl	2018-11-03 15:33:07 UTC (rev 7256)
@@ -0,0 +1,259 @@
+;;;
+;;; test gui commands
+;;;
+;
+call test_messagebox
+call test_errordialogbox
+call test_yesnobox
+call test_inputbox
+call test_passwordbox
+call test_statusbox
+call test_macrodialogbox
+call test_listbox
+messagebox "finish all tests" "test"
+end
+
+;;;;;;;;;;;;;;;;
+;;; messagebox
+:test_messagebox
+s = "messagebox test\nthis is basic test\n3 lines"
+strspecial s
+messagebox s "test messagebox"
+messagebox "finish messagebox test" "test messagebox"
+return
+
+;;;;;;;;;;;;;;;;
+;;; error dialog
+;;; - Dependence
+;;;		messagebox
+:test_errordialogbox
+messagebox "Please push `continue` button in next window" "test errordialogbox"
+this_line_is_error_push_continue
+messagebox "finish error dialog test" "test error dialog"
+return
+
+;;;;;;;;;;;;;;;;
+;;; yesnobox
+;;; - Dependence
+;;;		messagebox
+:test_yesnobox
+yes = 0
+no = 0
+while ((yes == 0) or (no == 0))
+	yesnobox "push yes or no" "test yesnobox"
+	if result == 1 yes = yes + 1
+	if result == 0 no = no + 1
+	sprintf "yes=%d no=%d" yes no
+	messagebox inputstr "test yesnobox"
+endwhile
+sprintf "finish yesnobox test\nyes=%d no=%d" yes no
+s = inputstr
+strspecial s
+messagebox s "test yesnobox"
+return
+
+;;;;;;;;;;;;;;;;
+;;; inputbox
+;;; - Dependence
+;;;		messagebox
+:test_inputbox
+s = "default string"
+match = 0
+while match == 0
+	inputbox "input `ok` to finish" "test inputbox" s
+	s = inputstr
+	sprintf "input string is `%s`" s
+	messagebox inputstr "test inputbox"
+	strmatch s "^ok$"
+	match = result
+endwhile
+messagebox "finish inputbox test" "test inputbox"
+return
+
+;;;;;;;;;;;;;;;;
+;;; passwordbox
+;;; - Dependence
+;;;		messagebox
+:test_passwordbox
+match = 0
+while match == 0
+	passwordbox "input `password` to finish" "test passwordbox"
+	s = inputstr
+	sprintf "input string is `%s`" s
+	messagebox inputstr "test inputbox"
+	strmatch s "^password$"
+	match = result
+endwhile
+messagebox "finish passwordbox test" "test passwordbox"
+return
+
+;;;;;;;;;;;;;;;;
+;;; statusbox
+;;; setdlgpos
+;;; closesbox
+;;; - Dependence
+;;;		messagebox
+:test_statusbox
+call test_statusbox_centerwindow
+;call test_statusbox_setdlgpos
+return
+
+; 表示されていない→表示する 時 センタリングされる
+; 表示されている時 width=変化しない height=変化する(フィット) pos=変化しない
+:test_statusbox_centerwindow
+pause_time = 3
+statusbox "statusbox message" "test statusbox"
+pause pause_time
+sprintf2 s "1 line1\n2 line2 \n3 line3\n4 long long long long long line"
+strspecial s
+statusbox s "test statusbox"
+pause pause_time
+closesbox
+statusbox s "test statusbox"
+pause pause_time
+statusbox "statusbox message" "test statusbox"
+pause pause_time
+closesbox
+statusbox "statusbox message" "test statusbox"
+pause pause_time
+closesbox
+messagebox "finish statusbox centerwindow test" "test statusbox"
+return
+
+:test_statusbox_setdlgpos
+pause_time = 1
+last_val = 3
+statusbox "statusbox message" "test statusbox"
+pause pause_time
+for i 1 last_val
+	x = i*10
+	y = i*10
+	setdlgpos x y
+	sprintf2 s "setdlgpos\ni=%d/%d\n(%d,%d)" i last_val x y
+	strspecial s
+	statusbox s "test statusbox/setdlgpos"
+	pause pause_time
+next
+closesbox
+s = "Please overwrap other window\nwait 5 sec\nbringupbox test"
+strspecial s
+setdlgpos 0 0
+statusbox s "test statusbox"
+pause 5
+bringupbox
+statusbox "bringupbox" "test statusbox"
+pause 5
+closesbox
+setdlgpos -10000 0	  ; go center
+messagebox "finish statusbox setdlgpos test" "test statusbox"
+return
+
+;;;;;;;;;;;;;;;;
+;;; macrodialog box
+;;; show
+;;; - Dependence
+;;;		messagebox
+:test_macrodialogbox
+call test_macrodialogbox_show
+call test_macrodialogbox_move_resize
+messagebox "finish macro dialogbox test" "test macro dialogbox"
+return
+
+:test_macrodialogbox_show
+N = 5
+intdim show_flag_list N
+show_flag_list[0] = 1
+show_flag_list[1] = -1
+show_flag_list[2] = 1
+show_flag_list[3] = 0
+show_flag_list[4] = 1
+for i 0 N-1
+	show_flag = show_flag_list[i]
+	show show_flag
+	if show_flag < 0 then
+	   s = "macro dialog box was hidden\ncheck task bar"
+	elseif show_flag == 0 then
+	   s = "macro dialog box was minimize\ncheck task bar"
+	elseif show_flag > 0 then
+	   s = "macro dialog box was shown\nmove this messagebox and check macro dialog box"
+	endif
+	sprintf "show %d\n%s" show_flag s
+	s = inputstr
+	strspecial s
+	messagebox s "test macrodialog/show"
+next
+return
+
+:test_macrodialogbox_move_resize
+w = 15
+sprintf "move and resize test\nwait %d sec" w
+s = inputstr
+strspecial s
+messagebox s "test macro dialog"
+pause w
+messagebox "finish move and resize test" "test macro dialog/move and resize"
+return
+
+;;;;;;;;;;;;;;;;
+;;; listbox
+;;; - Dependence
+;;;		messagebox
+:test_listbox
+N = 7
+intdim done N
+strdim strs N
+strdim srcs N
+for i 0 N-1
+	done[i] = 0
+next
+srcs[0] = "No man should understand where his dreams come from, Data. (Soong to Data, Birthright pt. 1)"
+srcs[1] = "The Advocate will refrain from making her opponent disappear. (Data to Ardra, Devil's Due)"
+srcs[2] = "He's comparing the Enterprise to a cruise ship? (Picard, The Neutral Zone)"
+srcs[3] = "What's the first rule of acquisition?"
+srcs[4] = "Once you have their money, you never give it back."
+srcs[5] = "Don't thank me, I already regret it. (Odo)"
+srcs[6] = "How long can two people talk about nothing? (Deanna, Starship Mine) "
+done_all = 0
+done_cancel = 0
+prev = 0
+while ((done_all == 0) or (done_cancel == 0))
+	for i 0 N-1
+		if done[i] == 0 then
+			s = ""
+		else
+			s = "[selected]"
+		endif
+		sprintf2 s "%s %s" s srcs[i]
+		strs[i] = s
+	next
+	if done_all == 0 then
+		msg = "select one from list and `ok`"
+		if done_cancel == 0 then
+			strconcat msg " or `cancel`"
+		endif
+	else
+		msg = "push `cancel`"
+	endif
+	listbox msg "test listbox" strs prev
+	if result < 0 then
+		done_cancel = 1
+		continue
+	endif
+	prev = result
+	if done[result] == 0 then
+		done[result] = 1
+	else
+		done[result] = 0
+	endif
+	done_all = 1
+	for i 0 N-1
+		if done[i] == 0 then
+			done_all = 0
+			break
+		endif
+	next
+endwhile
+messagebox "finish listbox test" "test listbox"
+return
+
+

Modified: branches/cmake/ttssh2/ttxssh/CMakeLists.txt
===================================================================
--- branches/cmake/ttssh2/ttxssh/CMakeLists.txt	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/ttssh2/ttxssh/CMakeLists.txt	2018-11-03 15:33:07 UTC (rev 7256)
@@ -99,6 +99,10 @@
   ${ZLIB_LIBRARY_DIRS}
   )
 
+if (MSVC)
+  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DELAYLOAD:dnsapi.dll")
+endif()
+
 if(MINGW)
   link_directories(
 	${CMAKE_SOURCE_DIR}/teraterm/htmlhelp
@@ -125,11 +129,15 @@
   ttxssh
   libputty
   ttpcmn
-  debug zlibstaticd.lib
-  optimized zlibstatic.lib
+  debug zlibstaticd
+  optimized zlibstatic
   ${OPENSSL_LIB}
-  ws2_32.lib
-  dnsapi.lib
+  #
+  ws2_32
+  dnsapi
+  gdi32
+  comdlg32
+  delayimp
   )
 
 ### create puttyversion.h

Modified: branches/cmake/ttssh2/ttxssh/ttxssh.c
===================================================================
--- branches/cmake/ttssh2/ttxssh/ttxssh.c	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/ttssh2/ttxssh/ttxssh.c	2018-11-03 15:33:07 UTC (rev 7256)
@@ -57,7 +57,7 @@
 #include <winsock2.h>
 static char *ProtocolFamilyList[] = { "UNSPEC", "IPv6", "IPv4", NULL };
 
-#include <Lmcons.h>
+#include <lmcons.h>
 
 // include OpenSSL header file
 #include <openssl/evp.h>

Modified: branches/cmake/ttssh2/ttxssh/ttxssh.h
===================================================================
--- branches/cmake/ttssh2/ttxssh/ttxssh.h	2018-11-03 15:32:41 UTC (rev 7255)
+++ branches/cmake/ttssh2/ttxssh/ttxssh.h	2018-11-03 15:33:07 UTC (rev 7256)
@@ -49,6 +49,7 @@
 
 #include <winsock2.h>
 #include <ws2tcpip.h>
+#include <wspiapi.h>
 /* actual body of in6addr_any and in6addr_loopback is disappeared?? */
 #undef IN6_IS_ADDR_LOOPBACK
 #define IN6_IS_ADDR_LOOPBACK(a)         \


More information about the Ttssh2-commit mailing list