[ttssh2-commit] [9882] CAddSettingPropSheetDlg から TTCPropSheetDlg を分離

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2022年 4月 23日 (土) 00:37:38 JST


Revision: 9882
          https://osdn.net/projects/ttssh2/scm/svn/commits/9882
Author:   zmatsuo
Date:     2022-04-23 00:37:38 +0900 (Sat, 23 Apr 2022)
Log Message:
-----------
CAddSettingPropSheetDlg から TTCPropSheetDlg を分離

- プロパティーシートダイアログの動作を別クラスに分離

Modified Paths:
--------------
    trunk/teraterm/teraterm/addsetting.cpp
    trunk/teraterm/teraterm/addsetting.h

-------------- next part --------------
Modified: trunk/teraterm/teraterm/addsetting.cpp
===================================================================
--- trunk/teraterm/teraterm/addsetting.cpp	2022-04-22 15:37:28 UTC (rev 9881)
+++ trunk/teraterm/teraterm/addsetting.cpp	2022-04-22 15:37:38 UTC (rev 9882)
@@ -1722,10 +1722,10 @@
 
 #define REWRITE_TEMPLATE	1
 // quick hack :-(
-HINSTANCE CAddSettingPropSheetDlg::ghInstance;
-class CAddSettingPropSheetDlg *CAddSettingPropSheetDlg::gTTCPS;
+HINSTANCE TTCPropSheetDlg::ghInstance;
+class TTCPropSheetDlg* TTCPropSheetDlg::gTTCPS;
 
-LRESULT CALLBACK CAddSettingPropSheetDlg::WndProc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
+LRESULT CALLBACK TTCPropSheetDlg::WndProc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
 {
 	switch(msg){
 	case WM_INITDIALOG:
@@ -1743,13 +1743,13 @@
 	return result;
 }
 
-LRESULT CALLBACK CAddSettingPropSheetDlg::WndProcStatic(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
+LRESULT CALLBACK TTCPropSheetDlg::WndProcStatic(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
 {
-	CAddSettingPropSheetDlg *self = (CAddSettingPropSheetDlg *)GetWindowLongPtr(dlg, GWLP_USERDATA);
+	TTCPropSheetDlg*self = (TTCPropSheetDlg*)GetWindowLongPtr(dlg, GWLP_USERDATA);
 	return self->WndProc(dlg, msg, wParam, lParam);
 }
 
-int CALLBACK CAddSettingPropSheetDlg::PropSheetProc(HWND hWnd, UINT msg, LPARAM lp)
+int CALLBACK TTCPropSheetDlg::PropSheetProc(HWND hWnd, UINT msg, LPARAM lp)
 {
 	switch (msg) {
 	case PSCB_PRECREATE:
@@ -1775,10 +1775,9 @@
 			{ IDCANCEL, "BTN_CANCEL" },
 			{ IDHELP, "BTN_HELP" },
 		};
-		CAddSettingPropSheetDlg *self = gTTCPS;
+		TTCPropSheetDlg*self = gTTCPS;
 		self->m_hWnd = hWnd;
 		SetDlgTexts(hWnd, TextInfos, _countof(TextInfos), ts.UILanguageFile);
-		CenterWindow(hWnd, self->m_hParentWnd);
 		self->m_OrgProc = SetWindowLongPtrW(hWnd, GWLP_WNDPROC, (LONG_PTR)WndProcStatic);
 		self->m_OrgUserData = SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LONG_PTR)self);
 		break;
@@ -1787,9 +1786,14 @@
 	return 0;
 }
 
-// CAddSettingPropSheetDlg
-CAddSettingPropSheetDlg::CAddSettingPropSheetDlg(HINSTANCE hInstance, HWND hParentWnd)
+void TTCPropSheetDlg::AddPage(HPROPSHEETPAGE page)
 {
+	hPsp[m_PageCount] = page;
+	m_PageCount++;
+}
+
+TTCPropSheetDlg::TTCPropSheetDlg(HINSTANCE hInstance, HWND hParentWnd)
+{
 	m_hInst = hInstance;
 	m_hWnd = 0;
 	m_hParentWnd = hParentWnd;
@@ -1800,7 +1804,33 @@
 	m_psh.hwndParent = hParentWnd;
 	m_psh.hInstance = hInstance;
 	m_psh.pfnCallback = PropSheetProc;
+	m_PageCount = 0;
+}
+TTCPropSheetDlg::~TTCPropSheetDlg()
+{
+	free((void*)m_psh.pszCaption);
+}
 
+void TTCPropSheetDlg::SetCaption(const wchar_t* caption)
+{
+	m_psh.pszCaption = _wcsdup(caption);
+}
+
+INT_PTR TTCPropSheetDlg::DoModal()
+{
+	m_psh.nPages = m_PageCount;
+	m_psh.phpage = hPsp;
+	ghInstance = m_hInst;
+	gTTCPS = this;
+	return PropertySheetW(&m_psh);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+// CAddSettingPropSheetDlg
+CAddSettingPropSheetDlg::CAddSettingPropSheetDlg(HINSTANCE hInstance, HWND hParentWnd):
+	TTCPropSheetDlg(hInstance, hParentWnd)
+{
 	// CPP,tmfc\x82\xCCTTCPropertyPage\x94h\x90\xB6\x83N\x83\x89\x83X\x82\xA9\x82琶\x90\xAC
 	int i = 0;
 	m_Page[i++] = new CGeneralPropPageDlg(hInstance);
@@ -1814,35 +1844,27 @@
 		m_Page[i++] = new CDebugPropPage(hInstance);
 	}
 	m_PageCountCPP = i;
+
+	HPROPSHEETPAGE page;
 	for (i = 0; i < m_PageCountCPP; i++) {
-		hPsp[i] = m_Page[i]->CreatePropertySheetPage();
+		page = m_Page[i]->CreatePropertySheetPage();
+		AddPage(page);
 	}
 
 	// TTCPropertyPage \x82\xF0\x8Eg\x97p\x82\xB5\x82Ȃ\xA2 PropertyPage
-	hPsp[m_PageCountCPP+0] = CodingPageCreate(hInstance, &ts);
-	hPsp[m_PageCountCPP+1] = FontPageCreate(hInstance, &ts);
-	m_PageCount = m_PageCountCPP + 2;
+	page = CodingPageCreate(hInstance, &ts);
+	AddPage(page);
+	page = FontPageCreate(hInstance, &ts);
+	AddPage(page);
 
-	m_psh.nPages = m_PageCount;
-	m_psh.phpage = hPsp;
-
-	wchar_t UIMsg[MAX_UIMSG];
-	get_lang_msgW("DLG_TABSHEET_TITLE", UIMsg, _countof(UIMsg),
-				  L"Tera Term: Additional settings", ts.UILanguageFile);
-	m_psh.pszCaption = _wcsdup(UIMsg);
+	wchar_t *title = TTGetLangStrW("Tera Term", "DLG_TABSHEET_TITLE", L"Tera Term: Additional settings", ts.UILanguageFile);
+	SetCaption(title);
+	free(title);
 }
 
 CAddSettingPropSheetDlg::~CAddSettingPropSheetDlg()
 {
-	free((void*)m_psh.pszCaption);
 	for (int i = 0; i < m_PageCountCPP; i++) {
 		delete m_Page[i];
 	}
 }
-
-INT_PTR CAddSettingPropSheetDlg::DoModal()
-{
-	ghInstance = m_hInst;
-	gTTCPS = this;
-	return PropertySheetW(&m_psh);
-}

Modified: trunk/teraterm/teraterm/addsetting.h
===================================================================
--- trunk/teraterm/teraterm/addsetting.h	2022-04-22 15:37:28 UTC (rev 9881)
+++ trunk/teraterm/teraterm/addsetting.h	2022-04-22 15:37:38 UTC (rev 9882)
@@ -129,18 +129,20 @@
 };
 
 // Property Sheet
-class CAddSettingPropSheetDlg
+class TTCPropSheetDlg
 {
 public:
-	CAddSettingPropSheetDlg(HINSTANCE hInstance, HWND hParentWnd);
-	virtual ~CAddSettingPropSheetDlg();
+	TTCPropSheetDlg(HINSTANCE hInstance, HWND hParentWnd);
+	virtual ~TTCPropSheetDlg();
 	INT_PTR DoModal();
+	void AddPage(HPROPSHEETPAGE page);
+	void SetCaption(const wchar_t *caption);
 
 private:
 	static int CALLBACK PropSheetProc(HWND hWnd, UINT msg, LPARAM lParam);
 	static LRESULT CALLBACK WndProcStatic(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam);
 	static HINSTANCE ghInstance;
-	static class CAddSettingPropSheetDlg *gTTCPS;
+	static class TTCPropSheetDlg *gTTCPS;
 	LRESULT CALLBACK WndProc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam);
 
 	PROPSHEETHEADERW m_psh;
@@ -151,8 +153,18 @@
 	int m_PageCount;
 	HPROPSHEETPAGE hPsp[9];
 
-	int m_PageCountCPP;
-	TTCPropertyPage *m_Page[7];
 	LONG_PTR m_OrgProc;
 	LONG_PTR m_OrgUserData;
 };
+
+// AddSetting Property Sheet
+class CAddSettingPropSheetDlg: public TTCPropSheetDlg
+{
+public:
+	CAddSettingPropSheetDlg(HINSTANCE hInstance, HWND hParentWnd);
+	~CAddSettingPropSheetDlg();
+
+private:
+	int m_PageCountCPP;
+	TTCPropertyPage *m_Page[7];
+};


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