[Ttssh2-commit] [7382] ログローテートの単位(Byte,KB,MB)設定できていなかったので修正

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2019年 1月 3日 (木) 01:58:56 JST


Revision: 7382
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/7382
Author:   zmatsuo
Date:     2019-01-03 01:58:56 +0900 (Thu, 03 Jan 2019)
Log Message:
-----------
ログローテートの単位(Byte,KB,MB)設定できていなかったので修正
MessageBox系をUnicode化

Modified Paths:
--------------
    branches/cmake/teraterm/common/tmfc.cpp
    branches/cmake/teraterm/common/tmfc.h
    branches/cmake/teraterm/teraterm/addsetting.cpp

-------------- next part --------------
Modified: branches/cmake/teraterm/common/tmfc.cpp
===================================================================
--- branches/cmake/teraterm/common/tmfc.cpp	2019-01-02 16:58:43 UTC (rev 7381)
+++ branches/cmake/teraterm/common/tmfc.cpp	2019-01-02 16:58:56 UTC (rev 7382)
@@ -1,800 +1,807 @@
-/*
- * 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)) || \
-	(__cplusplus <= 199711L)
-#define nullptr NULL	// C++11,nullptr / > VS2010
-#endif
-
-TTCWnd::TTCWnd()
-{
-	m_hWnd = nullptr;
-	m_hInst = nullptr;
-	m_hAccel = nullptr;
-	m_hParentWnd = 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::SendDlgItemMessageT(int id, UINT msg, WPARAM wp, LPARAM lp)
-{
-	return ::SendDlgItemMessage(m_hWnd, id, msg, wp, lp);
-}
-
-#if defined(UNICODE)
-LRESULT TTCWnd::SendDlgItemMessageW(int id, UINT msg, WPARAM wp, LPARAM lp)
-{
-	return ::SendDlgItemMessageW(m_hWnd, id, msg, wp, lp);
-}
-#endif
-
-LRESULT TTCWnd::SendDlgItemMessageA(int id, UINT msg, WPARAM wp, LPARAM lp)
-{
-	return ::SendDlgItemMessageA(m_hWnd, id, msg, wp, lp);
-}
-
-void TTCWnd::GetDlgItemTextT(int id, TCHAR *buf, size_t size)
-{
-	::GetDlgItemText(m_hWnd, id, buf, (int)size);
-}
-
-#if defined(UNICODE)
-void TTCWnd::GetDlgItemTextW(int id, wchar_t *buf, size_t size)
-{
-	::GetDlgItemTextW(m_hWnd, id, buf, (int)size);
-}
-#endif
-
-void TTCWnd::GetDlgItemTextA(int id, char *buf, size_t size)
-{
-	::GetDlgItemTextA(m_hWnd, id, buf, (int)size);
-}
-
-void TTCWnd::SetDlgItemTextT(int id, const TCHAR *str)
-{
-	::SetDlgItemText(m_hWnd, id, str);
-}
-
-#if defined(UNICODE)
-void TTCWnd::SetDlgItemTextW(int id, const wchar_t *str)
-{
-	::SetDlgItemTextW(m_hWnd, id, str);
-}
-#endif
-
-void TTCWnd::SetDlgItemTextA(int id, const char *str)
-{
-	::SetDlgItemTextA(m_hWnd, id, str);
-}
-
-void TTCWnd::SetDlgItemNum(int id, LONG Num)
-{
-	SetDlgNum(m_hWnd, id, Num);
-}
-
-// 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::SetWindowTextT(const TCHAR *str)
-{
-	::SetWindowText(m_hWnd, str);
-}
-
-#if defined(UNICODE)
-void TTCWnd::SetWindowTextW(const wchar_t *str)
-{
-	::SetWindowTextW(m_hWnd, str);
-}
-#endif
-
-void TTCWnd::SetWindowTextA(const char *str)
-{
-	::SetWindowTextA(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::MessageBoxT(LPCTSTR lpText, LPCTSTR lpCaption, UINT uType)
-{
-	return ::MessageBox(m_hWnd, lpText, lpCaption, uType);
-}
-
-int TTCWnd::MessageBoxA(const char *lpText, const char *lpCaption, UINT uType)
-{
-	return ::MessageBoxA(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();
-			//SetWindowLongPtr(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();
-			//SetWindowLongPtr(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)
-{
-	m_hInst = hInstance;
-	m_hParentWnd = hParent;
-#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()
-{
-}
+/*
+ * 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"
+
+// \x83e\x83\x93\x83v\x83\x8C\x81[\x83g\x82̏\x91\x82\xAB\x8A\xB7\x82\xA6\x82\xF0\x8Ds\x82\xA4
+#define REWRITE_TEMPLATE
+
+#if (defined(_MSC_VER) && (_MSC_VER <= 1500)) || \
+	(__cplusplus <= 199711L)
+#define nullptr NULL	// C++11,nullptr / > VS2010
+#endif
+
+TTCWnd::TTCWnd()
+{
+	m_hWnd = nullptr;
+	m_hInst = nullptr;
+	m_hAccel = nullptr;
+	m_hParentWnd = 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::SendDlgItemMessageT(int id, UINT msg, WPARAM wp, LPARAM lp)
+{
+	return ::SendDlgItemMessage(m_hWnd, id, msg, wp, lp);
+}
+
+#if defined(UNICODE)
+LRESULT TTCWnd::SendDlgItemMessageW(int id, UINT msg, WPARAM wp, LPARAM lp)
+{
+	return ::SendDlgItemMessageW(m_hWnd, id, msg, wp, lp);
+}
+#endif
+
+LRESULT TTCWnd::SendDlgItemMessageA(int id, UINT msg, WPARAM wp, LPARAM lp)
+{
+	return ::SendDlgItemMessageA(m_hWnd, id, msg, wp, lp);
+}
+
+void TTCWnd::GetDlgItemTextT(int id, TCHAR *buf, size_t size)
+{
+	::GetDlgItemText(m_hWnd, id, buf, (int)size);
+}
+
+#if defined(UNICODE)
+void TTCWnd::GetDlgItemTextW(int id, wchar_t *buf, size_t size)
+{
+	::GetDlgItemTextW(m_hWnd, id, buf, (int)size);
+}
+#endif
+
+void TTCWnd::GetDlgItemTextA(int id, char *buf, size_t size)
+{
+	::GetDlgItemTextA(m_hWnd, id, buf, (int)size);
+}
+
+void TTCWnd::SetDlgItemTextT(int id, const TCHAR *str)
+{
+	::SetDlgItemText(m_hWnd, id, str);
+}
+
+#if defined(UNICODE)
+void TTCWnd::SetDlgItemTextW(int id, const wchar_t *str)
+{
+	::SetDlgItemTextW(m_hWnd, id, str);
+}
+#endif
+
+void TTCWnd::SetDlgItemTextA(int id, const char *str)
+{
+	::SetDlgItemTextA(m_hWnd, id, str);
+}
+
+void TTCWnd::SetDlgItemNum(int id, LONG Num)
+{
+	SetDlgNum(m_hWnd, id, Num);
+}
+
+// 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::SetWindowTextT(const TCHAR *str)
+{
+	::SetWindowText(m_hWnd, str);
+}
+
+#if defined(UNICODE)
+void TTCWnd::SetWindowTextW(const wchar_t *str)
+{
+	::SetWindowTextW(m_hWnd, str);
+}
+#endif
+
+void TTCWnd::SetWindowTextA(const char *str)
+{
+	::SetWindowTextA(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::MessageBoxT(LPCTSTR lpText, LPCTSTR lpCaption, UINT uType)
+{
+	return ::MessageBox(m_hWnd, lpText, lpCaption, uType);
+}
+
+int TTCWnd::MessageBoxA(const char *lpText, const char *lpCaption, UINT uType)
+{
+	return ::MessageBoxA(m_hWnd, lpText, lpCaption, uType);
+}
+
+#if defined(UNICODE)
+int TTCWnd::MessageBoxW(const wchar_t *lpText, const wchar_t *lpCaption, UINT uType)
+{
+	return ::MessageBoxW(m_hWnd, lpText, lpCaption, uType);
+}
+#endif
+
+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()
+{
+}
+
+/**
+ * \x83_\x83C\x83A\x83\x8D\x83O\x8F\x89\x8A\xFA\x89\xBB
+ * @retval	TRUE	\x8F\x88\x97\x9D\x82\xAA\x8Ds\x82\xED\x82ꂽ(\x8E\x9F\x82̃\x81\x83b\x83Z\x81[\x83W\x8F\x88\x97\x9D\x82͌Ăяo\x82\xB3\x82\xEA\x82Ȃ\xA2)
+ * @retval	FALSE	\x8E\x9F\x82̃\x81\x83b\x83Z\x81[\x83W\x8F\x88\x97\x9D\x82͌Ăяo\x82\xB3\x82\xEA\x82\xE9
+ *
+ * \x8E\x9F\x82̃\x81\x83b\x83Z\x81[\x83W\x8F\x88\x97\x9D
+ *		TTCDialog::DlgProc(msg=WM_INITDIALOG)
+ */
+BOOL TTCDialog::OnInitDialog()
+{
+	return FALSE;
+}
+
+/**
+ * OK\x83{\x83^\x83\x93
+ * @retval	TRUE	\x8F\x88\x97\x9D\x82\xAA\x8Ds\x82\xED\x82ꂽ(\x8E\x9F\x82̃\x81\x83b\x83Z\x81[\x83W\x8F\x88\x97\x9D\x82͌Ăяo\x82\xB3\x82\xEA\x82Ȃ\xA2)
+ * @retval	FALSE	\x8E\x9F\x82̃\x81\x83b\x83Z\x81[\x83W\x8F\x88\x97\x9D\x82͌Ăяo\x82\xB3\x82\xEA\x82\xE9
+ *
+ * \x8E\x9F\x82̃\x81\x83b\x83Z\x81[\x83W\x8F\x88\x97\x9D
+ *		TTCDialog::OnCommand()
+ */
+BOOL TTCDialog::OnOK()
+{
+	EndDialog(IDOK);
+	return TRUE;
+}
+
+/**
+ * CANCEL\x83{\x83^\x83\x93
+ * @retval	TRUE	\x8F\x88\x97\x9D\x82\xAA\x8Ds\x82\xED\x82ꂽ(\x8E\x9F\x82̃\x81\x83b\x83Z\x81[\x83W\x8F\x88\x97\x9D\x82͌Ăяo\x82\xB3\x82\xEA\x82Ȃ\xA2)
+ * @retval	FALSE	\x8E\x9F\x82̃\x81\x83b\x83Z\x81[\x83W\x8F\x88\x97\x9D\x82͌Ăяo\x82\xB3\x82\xEA\x82\xE9
+ *
+ * \x8E\x9F\x82̃\x81\x83b\x83Z\x81[\x83W\x8F\x88\x97\x9D
+ *		TTCDialog::OnCommand()
+ */
+BOOL TTCDialog::OnCancel()
+{
+	EndDialog(IDCANCEL);
+	return TRUE;
+}
+
+BOOL TTCDialog::OnCommand(WPARAM wp, LPARAM lp)
+{
+	return FALSE;
+}
+
+/**
+ * WM_CLOSE\x83\x81\x83b\x83Z\x81[\x83W\x8F\x88\x97\x9D
+ * @retval	TRUE	\x8F\x88\x97\x9D\x82\xAA\x8Ds\x82\xED\x82ꂽ(\x8E\x9F\x82̃\x81\x83b\x83Z\x81[\x83W\x8F\x88\x97\x9D\x82͌Ăяo\x82\xB3\x82\xEA\x82Ȃ\xA2)
+ * @retval	FALSE	\x8E\x9F\x82̃\x81\x83b\x83Z\x81[\x83W\x8F\x88\x97\x9D\x82͌Ăяo\x82\xB3\x82\xEA\x82\xE9
+ *
+ * \x8E\x9F\x82̃\x81\x83b\x83Z\x81[\x83W\x8F\x88\x97\x9D
+ *		TTCDialog::OnCancel()
+ */
+BOOL TTCDialog::OnClose()
+{
+	return FALSE;
+}
+
+/**
+ * WM_NCDESTROY\x83\x81\x83b\x83Z\x81[\x83W\x8F\x88\x97\x9D
+ * @retval	TRUE	\x8F\x88\x97\x9D\x82\xAA\x8Ds\x82\xED\x82ꂽ(\x8E\x9F\x82̃\x81\x83b\x83Z\x81[\x83W\x8F\x88\x97\x9D\x82͌Ăяo\x82\xB3\x82\xEA\x82Ȃ\xA2)
+ * @retval	FALSE	\x8E\x9F\x82̃\x81\x83b\x83Z\x81[\x83W\x8F\x88\x97\x9D\x82͌Ăяo\x82\xB3\x82\xEA\x82\xE9
+ *
+ * \x8E\x9F\x82̃\x81\x83b\x83Z\x81[\x83W\x8F\x88\x97\x9D
+ *		TTCDialog::DlgProc()
+ */
+BOOL TTCDialog::PostNcDestroy()
+{
+	return FALSE;
+}
+
+/*
+ * @retval	TRUE	\x83\x81\x83b\x83Z\x81[\x83W\x82\xF0\x8F\x88\x97\x9D\x82\xB5\x82\xBD\x8E\x9E
+ * @retval	FALSE	\x83\x81\x83b\x83Z\x81[\x83W\x82\xF0\x8F\x88\x97\x9D\x82\xB5\x82Ȃ\xA9\x82\xC1\x82\xBD\x8E\x9E
+ * @retval	\x82\xBB\x82̑\xBC	\x83\x81\x83b\x83Z\x81[\x83W\x82ɂ\xE6\x82\xC1\x82ĈقȂ邱\x82Ƃ\xAA\x82\xA0\x82\xE9
+ */
+LRESULT TTCDialog::DlgProc(UINT msg, WPARAM wp, LPARAM lp)
+{
+	(void)msg;
+	(void)wp;
+	(void)lp;
+	return (LRESULT)FALSE;
+}
+
+/*
+ * @retval	TRUE	\x83\x81\x83b\x83Z\x81[\x83W\x82\xF0\x8F\x88\x97\x9D\x82\xB5\x82\xBD\x8E\x9E
+ * @retval	FALSE	\x83\x81\x83b\x83Z\x81[\x83W\x82\xF0\x8F\x88\x97\x9D\x82\xB5\x82Ȃ\xA9\x82\xC1\x82\xBD\x8E\x9E
+ */
+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();
+			//SetWindowLongPtr(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\x83{\x83^\x83\x93\x82\xF0\x89\x9F\x82\xB5\x82\xBD\x8E\x9E\x81A
+		Processed = OnClose();
+		if (Processed == FALSE) {
+			//	\x83I\x81[\x83o\x81[\x83\x89\x83C\x83h\x82\xB3\x82\xEA\x82Ă\xA2\x82Ȃ\xAF\x82\xEA\x82\xCE
+			//	dialog\x82Ȃ\xE7OnCancel()\x82\xAA\x94\xAD\x90\xB6\x82\xB7\x82\xE9
+			Processed = OnCancel();
+		}
+		break;
+	default:
+		Processed = FALSE;
+		break;
+	}
+
+	if (Processed == TRUE) {
+		// \x8F\x88\x97\x9D\x82\xB5\x82\xBD
+		return TRUE;
+	}
+
+	// \x8DŌ\xE3\x82̃\x81\x83b\x83Z\x81[\x83W\x8F\x88\x97\x9D
+	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();
+			//SetWindowLongPtr(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\x83{\x83^\x83\x93\x82\xF0\x89\x9F\x82\xB5\x82\xBD\x8E\x9E\x81A
+		Processed = OnClose();
+		if (Processed == FALSE) {
+			//	\x83I\x81[\x83o\x81[\x83\x89\x83C\x83h\x82\xB3\x82\xEA\x82Ă\xA2\x82Ȃ\xAF\x82\xEA\x82\xCE
+			//	dialog\x82Ȃ\xE7OnCancel()\x82\xAA\x94\xAD\x90\xB6\x82\xB7\x82\xE9
+			Processed = OnCancel();
+		}
+		break;
+	default:
+		Processed = FALSE;
+		break;
+	}
+
+	if (Processed == TRUE) {
+		// \x8F\x88\x97\x9D\x82\xB5\x82\xBD
+		return TRUE;
+	}
+
+	// DlgProc\x82\xF0\x83I\x81[\x83o\x83\x89\x83C\x83h\x82\xB7\x82\xE9\x82̂ł͂Ȃ\xAD\x81A
+	// DefWindowProc\x82\xF0\x83I\x81[\x83o\x81[\x83\x89\x83C\x83h\x82\xB7\x82邱\x82\xC6
+	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)
+{
+	m_hInst = hInstance;
+	m_hParentWnd = hParent;
+#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 \x8AO\x82ł\xE2\x82\xE9\x82̂\xAA\x97ǂ\xB3\x82\xBB\x82\xA4
+//	::EnableWindow(m_hWnd,TRUE);
+
+	return TRUE;
+}
+
+/*
+ * @retval	TRUE	\x83\x81\x83b\x83Z\x81[\x83W\x82\xF0\x8F\x88\x97\x9D\x82\xB5\x82\xBD\x8E\x9E
+ * @retval	FALSE	\x83\x81\x83b\x83Z\x81[\x83W\x82\xF0\x8F\x88\x97\x9D\x82\xB5\x82Ȃ\xA9\x82\xC1\x82\xBD\x8E\x9E
+ */
+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	\x83\x81\x83b\x83Z\x81[\x83W\x82\xF0\x8F\x88\x97\x9D\x82\xB5\x82\xBD\x8E\x9E
+ * @retval	FALSE	\x83\x81\x83b\x83Z\x81[\x83W\x82\xF0\x8F\x88\x97\x9D\x82\xB5\x82Ȃ\xA9\x82\xC1\x82\xBD\x8E\x9E
+ */
+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;		// \x81u\x82̃v\x83\x8D\x83p\x83e\x83B\x81[\x81v\x82\xAA\x92lj\xC1\x82\xB3\x82\xEA\x82\xE9?
+	}
+	m_psh.hwndParent = hParentWnd;
+	m_psh.pfnCallback = PropSheetProc;
+}
+
+TTCPropertySheet::~TTCPropertySheet()
+{
+}
+
+INT_PTR TTCPropertySheet::DoModal()
+{
+	ghInstance = m_hInst;
+	gTTCPS = this;
+	return PropertySheet(&m_psh);
+
+	// \x83\x82\x81[\x83_\x83\x8C\x83X\x82ɂ\xB7\x82\xE9\x82ƃ^\x83u\x82̓\xAE\x82\xAB\x82\xAA\x82\xA8\x82\xA9\x82\xB5\x82\xA2
+#if 0
+	// \x83\x82\x81[\x83h\x83\x8C\x83X\x83_\x83C\x83A\x83\x8D\x83O\x83{\x83b\x83N\x83X\x82̏ꍇ\x82̓E\x83B\x83\x93\x83h\x83E\x82̃n\x83\x93\x83h\x83\x8B
+	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))
+		{
+			// \x83_\x83C\x83A\x83\x8D\x83O\x88ȊO\x82̏\x88\x97\x9D
+			::TranslateMessage(&Msg);
+			::DispatchMessage(&Msg);
+		}
+		if (!SendMessage(hDlgWnd, PSM_GETCURRENTPAGEHWND, 0, 0)) {
+			// \x83v\x83\x8D\x83p\x83e\x83B\x81[\x83V\x81[\x83g\x8FI\x97\xB9
+			break;
+		}
+	}
+	return ModalResult;
+#endif
+}
+
+int CALLBACK TTCPropertySheet::PropSheetProc(HWND hWnd, UINT msg, LPARAM lp)
+{
+	switch (msg) {
+	case PSCB_PRECREATE:
+	{
+#if defined(REWRITE_TEMPLATE)
+		// \x83e\x83\x93\x83v\x83\x8C\x81[\x83g\x82̓\xE0\x97e\x82\xF0\x8F\x91\x82\xAB\x8A\xB7\x82\xA6\x82\xE9 \x8A댯
+		// 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()
+{
+}

Modified: branches/cmake/teraterm/common/tmfc.h
===================================================================
--- branches/cmake/teraterm/common/tmfc.h	2019-01-02 16:58:43 UTC (rev 7381)
+++ branches/cmake/teraterm/common/tmfc.h	2019-01-02 16:58:56 UTC (rev 7382)
@@ -1,183 +1,186 @@
-/*
- * 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;
-	HWND m_hParentWnd;
-
-	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 SetWindowTextT(const TCHAR *str);
-#if defined(UNICODE)
-	void SetWindowTextW(const wchar_t *str);
-#endif
-	void SetWindowTextA(const char *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 MessageBoxT(LPCTSTR lpText, LPCTSTR lpCaption, UINT uType);
-	int MessageBoxA(const char * lpText, const char *lpCaption, UINT uType);
-	//virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
-	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 SendDlgItemMessageT(int id, UINT msg, WPARAM wp, LPARAM lp);
-#if defined(UNICODE)
-	LRESULT SendDlgItemMessageW(int id, UINT msg, WPARAM wp, LPARAM lp);
-#endif
-	LRESULT SendDlgItemMessageA(int id, UINT msg, WPARAM wp, LPARAM lp);
-	void GetDlgItemTextT(int id, TCHAR *buf, size_t size);
-#if defined(UNICODE)
-	void GetDlgItemTextW(int id, wchar_t *buf, size_t size);
-#endif
-	void GetDlgItemTextA(int id, char *buf, size_t size);
-	void SetDlgItemTextT(int id, const TCHAR *str);
-#if defined(UNICODE)
-	void SetDlgItemTextW(int id, const wchar_t *str);
-#endif
-	void SetDlgItemTextA(int id, const char *str);
-	void SetDlgItemNum(int id, LONG Num);
-	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) = 0;
-	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);
-
-	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;
-};
-
+/*
+ * 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;
+	HWND m_hParentWnd;
+
+	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 SetWindowTextT(const TCHAR *str);
+#if defined(UNICODE)
+	void SetWindowTextW(const wchar_t *str);
+#endif
+	void SetWindowTextA(const char *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 MessageBoxT(LPCTSTR lpText, LPCTSTR lpCaption, UINT uType);
+	int MessageBoxA(const char * lpText, const char *lpCaption, UINT uType);
+#if defined(UNICODE)
+	int MessageBoxW(const wchar_t * lpText, const wchar_t *lpCaption, UINT uType);
+#endif
+	//virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
+	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 SendDlgItemMessageT(int id, UINT msg, WPARAM wp, LPARAM lp);
+#if defined(UNICODE)
+	LRESULT SendDlgItemMessageW(int id, UINT msg, WPARAM wp, LPARAM lp);
+#endif
+	LRESULT SendDlgItemMessageA(int id, UINT msg, WPARAM wp, LPARAM lp);
+	void GetDlgItemTextT(int id, TCHAR *buf, size_t size);
+#if defined(UNICODE)
+	void GetDlgItemTextW(int id, wchar_t *buf, size_t size);
+#endif
+	void GetDlgItemTextA(int id, char *buf, size_t size);
+	void SetDlgItemTextT(int id, const TCHAR *str);
+#if defined(UNICODE)
+	void SetDlgItemTextW(int id, const wchar_t *str);
+#endif
+	void SetDlgItemTextA(int id, const char *str);
+	void SetDlgItemNum(int id, LONG Num);
+	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) = 0;
+	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);
+
+	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;
+};
+

Modified: branches/cmake/teraterm/teraterm/addsetting.cpp
===================================================================
--- branches/cmake/teraterm/teraterm/addsetting.cpp	2019-01-02 16:58:43 UTC (rev 7381)
+++ branches/cmake/teraterm/teraterm/addsetting.cpp	2019-01-02 16:58:56 UTC (rev 7382)
@@ -50,8 +50,6 @@
 #define GetDlgItemText GetDlgItemTextA
 #undef SetDlgItemText
 #define SetDlgItemText SetDlgItemTextA
-#undef MessageBox
-#define MessageBox MessageBoxA
 
 const mouse_cursor_t MouseCursor[] = {
 	{"ARROW", IDC_ARROW},
@@ -1121,7 +1119,7 @@
 	for (int i = 0 ; i < ts.LogRotateSizeType ; i++)
 		TmpLogRotateSize /= 1024;
 	SetDlgItemInt(IDC_ROTATE_SIZE, TmpLogRotateSize, FALSE);
-	SendDlgItemMessage(IDC_ROTATE_SIZE_TYPE, CB_SELECTSTRING, -1, (LPARAM)GetLogRotateSizeType(ts.LogRotateSizeType));
+	SendDlgItemMessageA(IDC_ROTATE_SIZE_TYPE, CB_SELECTSTRING, -1, (LPARAM)GetLogRotateSizeType(ts.LogRotateSizeType));
 	SetDlgItemInt(IDC_ROTATE_STEP, ts.LogRotateStep, FALSE);
 	if (ts.LogRotate == ROTATE_NONE) {
 		EnableDlgItem(IDC_ROTATE_SIZE_TEXT, FALSE);
@@ -1275,7 +1273,8 @@
 	char buf[80], buf2[80];
 	time_t time_local;
 	struct tm *tm_local;
-	char uimsg[MAX_UIMSG];
+	TCHAR uimsg[MAX_UIMSG];
+	TCHAR uimsg2[MAX_UIMSG];
 
 	// Viewlog Editor path (2005.1.29 yutaka)
 	GetDlgItemText(IDC_VIEWLOG_EDITOR, ts.ViewlogEditor, _countof(ts.ViewlogEditor));
@@ -1283,10 +1282,10 @@
 	// Log Default File Name (2006.8.28 maya)
 	GetDlgItemTextA(IDC_DEFAULTNAME_EDITOR, buf, sizeof(buf));
 	if (isInvalidStrftimeChar(buf)) {
-		get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile);
-		get_lang_msg("MSG_LOGFILE_INVALID_CHAR_ERROR", ts.UIMsg, sizeof(ts.UIMsg),
-		             "Invalid character is included in log file name.", ts.UILanguageFile);
-		MessageBoxA(ts.UIMsg, uimsg, MB_ICONEXCLAMATION);
+		get_lang_msgT("MSG_ERROR", uimsg, _countof(uimsg), _T("ERROR"), ts.UILanguageFile);
+		get_lang_msgT("MSG_LOGFILE_INVALID_CHAR_ERROR", uimsg2, _countof(uimsg2),
+		              _T("Invalid character is included in log file name."), ts.UILanguageFile);
+		MessageBox(uimsg2, uimsg, MB_ICONEXCLAMATION);
 		return;
 	}
 
@@ -1295,17 +1294,17 @@
 	tm_local = localtime(&time_local);
 	// \x8E\x9E\x8D\x8F\x95\xB6\x8E\x9A\x97\xF1\x82ɕϊ\xB7
 	if (strlen(buf) != 0 && strftime(buf2, sizeof(buf2), buf, tm_local) == 0) {
-		get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile);
-		get_lang_msg("MSG_LOGFILE_TOOLONG_ERROR", ts.UIMsg, sizeof(ts.UIMsg),
-		             "The log file name is too long.", ts.UILanguageFile);
-		MessageBox(ts.UIMsg, uimsg, MB_ICONEXCLAMATION);
+		get_lang_msgT("MSG_ERROR", uimsg, _countof(uimsg), _T("ERROR"), ts.UILanguageFile);
+		get_lang_msgT("MSG_LOGFILE_TOOLONG_ERROR", uimsg2, _countof(uimsg2),
+					  _T("The log file name is too long."), ts.UILanguageFile);
+		MessageBox(uimsg2, uimsg, MB_ICONEXCLAMATION);
 		return;
 	}
 	if (isInvalidFileNameChar(buf2)) {
-		get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile);
-		get_lang_msg("MSG_LOGFILE_INVALID_CHAR_ERROR", ts.UIMsg, sizeof(ts.UIMsg),
-		             "Invalid character is included in log file name.", ts.UILanguageFile);
-		MessageBox(ts.UIMsg, uimsg, MB_ICONEXCLAMATION);
+		get_lang_msgT("MSG_ERROR", uimsg, _countof(uimsg), _T("ERROR"), ts.UILanguageFile);
+		get_lang_msgT("MSG_LOGFILE_INVALID_CHAR_ERROR", uimsg2, _countof(uimsg2),
+					  _T("Invalid character is included in log file name."), ts.UILanguageFile);
+		MessageBox(uimsg2, uimsg, MB_ICONEXCLAMATION);
 		return;
 	}
 	strncpy_s(ts.LogDefaultName, sizeof(ts.LogDefaultName), buf, _TRUNCATE);


Ttssh2-commit メーリングリストの案内
Back to archive index