Revision: 9883 https://osdn.net/projects/ttssh2/scm/svn/commits/9883 Author: zmatsuo Date: 2022-04-23 00:37:48 +0900 (Sat, 23 Apr 2022) Log Message: ----------- TTCPropSheetDlg クラスを別ファイルに分離 - common/tmfc_propdlg.cpp,h を追加 Modified Paths: -------------- trunk/teraterm/common/CMakeLists.txt trunk/teraterm/common/common_static.v16.vcxproj trunk/teraterm/common/common_static.v8.vcproj trunk/teraterm/teraterm/addsetting.cpp trunk/teraterm/teraterm/addsetting.h Added Paths: ----------- trunk/teraterm/common/tmfc_propdlg.cpp trunk/teraterm/common/tmfc_propdlg.h -------------- next part -------------- Modified: trunk/teraterm/common/CMakeLists.txt =================================================================== --- trunk/teraterm/common/CMakeLists.txt 2022-04-22 15:37:38 UTC (rev 9882) +++ trunk/teraterm/common/CMakeLists.txt 2022-04-22 15:37:48 UTC (rev 9883) @@ -32,6 +32,8 @@ tmfc.cpp tmfc.h tmfc_frame.cpp + tmfc_propdlg.cpp + tmfc_propdlg.h tmfc_property.cpp ttknownfolders.h ttknownfolders.c Modified: trunk/teraterm/common/common_static.v16.vcxproj =================================================================== --- trunk/teraterm/common/common_static.v16.vcxproj 2022-04-22 15:37:38 UTC (rev 9882) +++ trunk/teraterm/common/common_static.v16.vcxproj 2022-04-22 15:37:48 UTC (rev 9883) @@ -141,6 +141,7 @@ <ClCompile Include="tipwin.cpp" /> <ClCompile Include="tmfc.cpp" /> <ClCompile Include="tmfc_frame.cpp" /> + <ClCompile Include="tmfc_propdlg.cpp" /> <ClCompile Include="tmfc_property.cpp" /> <ClCompile Include="codeconv.cpp" /> <ClCompile Include="compat_win.cpp" /> @@ -167,6 +168,7 @@ <ClInclude Include="i18n.h" /> <ClInclude Include="codeconv.h" /> <ClInclude Include="getcontent.h" /> + <ClInclude Include="tmfc_propdlg.h" /> <ClInclude Include="ttknownfolders.h" /> <ClInclude Include="ttlib.h" /> <ClInclude Include="ttlib_charset.h" /> Modified: trunk/teraterm/common/common_static.v8.vcproj =================================================================== --- trunk/teraterm/common/common_static.v8.vcproj 2022-04-22 15:37:38 UTC (rev 9882) +++ trunk/teraterm/common/common_static.v8.vcproj 2022-04-22 15:37:48 UTC (rev 9883) @@ -277,6 +277,14 @@ > </File> <File + RelativePath=".\tmfc_propdlg.cpp" + > + </File> + <File + RelativePath=".\tmfc_propdlg.h" + > + </File> + <File RelativePath=".\tmfc_property.cpp" > </File> Added: trunk/teraterm/common/tmfc_propdlg.cpp =================================================================== --- trunk/teraterm/common/tmfc_propdlg.cpp (rev 0) +++ trunk/teraterm/common/tmfc_propdlg.cpp 2022-04-22 15:37:48 UTC (rev 9883) @@ -0,0 +1,140 @@ +/* + * (C) 2022- 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. + */ + +#include "ttlib.h" +#include "dlglib.h" + +#include "tmfc_propdlg.h" + +#define REWRITE_TEMPLATE 1 +// quick hack :-( +HINSTANCE TTCPropSheetDlg::ghInstance; +class TTCPropSheetDlg* TTCPropSheetDlg::gTTCPS; + +LRESULT CALLBACK TTCPropSheetDlg::WndProc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg){ + case WM_INITDIALOG: + case WM_SHOWWINDOW: { + CenterWindow(dlg, m_hParentWnd); + break; + } + } + SetWindowLongPtrW(dlg, GWLP_WNDPROC, m_OrgProc); + SetWindowLongPtrW(dlg, GWLP_USERDATA, m_OrgUserData); + LRESULT result = CallWindowProcW((WNDPROC)m_OrgProc, dlg, msg, wParam, lParam); + m_OrgProc = SetWindowLongPtrW(dlg, GWLP_WNDPROC, (LONG_PTR)WndProcStatic); + m_OrgUserData = SetWindowLongPtrW(dlg, GWLP_USERDATA, (LONG_PTR)this); + + return result; +} + +LRESULT CALLBACK TTCPropSheetDlg::WndProcStatic(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + TTCPropSheetDlg*self = (TTCPropSheetDlg*)GetWindowLongPtr(dlg, GWLP_USERDATA); + return self->WndProc(dlg, msg, wParam, lParam); +} + +int CALLBACK TTCPropSheetDlg::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 + // 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: + { + static const DlgTextInfo TextInfos[] = { + { IDOK, "BTN_OK" }, + { IDCANCEL, "BTN_CANCEL" }, + { IDHELP, "BTN_HELP" }, + }; + TTCPropSheetDlg*self = gTTCPS; + self->m_hWnd = hWnd; + SetDlgTextsW(hWnd, TextInfos, _countof(TextInfos), self->m_UiLanguageFile); + self->m_OrgProc = SetWindowLongPtrW(hWnd, GWLP_WNDPROC, (LONG_PTR)WndProcStatic); + self->m_OrgUserData = SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LONG_PTR)self); + break; + } + } + return 0; +} + +void TTCPropSheetDlg::AddPage(HPROPSHEETPAGE page) +{ + hPsp[m_PageCount] = page; + m_PageCount++; +} + +TTCPropSheetDlg::TTCPropSheetDlg(HINSTANCE hInstance, HWND hParentWnd, const wchar_t *uilangfile) +{ + m_hInst = hInstance; + m_hWnd = 0; + m_hParentWnd = hParentWnd; + m_UiLanguageFile = _wcsdup(uilangfile); + memset(&m_psh, 0, sizeof(m_psh)); + m_psh.dwSize = sizeof(m_psh); + m_psh.dwFlags = PSH_DEFAULT | PSH_NOAPPLYNOW | PSH_USECALLBACK; + //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.hInstance = hInstance; + m_psh.pfnCallback = PropSheetProc; + m_PageCount = 0; +} +TTCPropSheetDlg::~TTCPropSheetDlg() +{ + free((void*)m_psh.pszCaption); + free(m_UiLanguageFile); +} + +void TTCPropSheetDlg::SetCaption(const wchar_t* caption) +{ + free((void*)m_psh.pszCaption); + 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); +} Added: trunk/teraterm/common/tmfc_propdlg.h =================================================================== --- trunk/teraterm/common/tmfc_propdlg.h (rev 0) +++ trunk/teraterm/common/tmfc_propdlg.h 2022-04-22 15:37:48 UTC (rev 9883) @@ -0,0 +1,62 @@ +/* + * (C) 2022- 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. + */ + +#include <windows.h> + +#pragma once + +// Property Sheet +class TTCPropSheetDlg +{ +public: + TTCPropSheetDlg(HINSTANCE hInstance, HWND hParentWnd, const wchar_t *uilangfile); + 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 TTCPropSheetDlg *gTTCPS; + LRESULT CALLBACK WndProc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam); + + PROPSHEETHEADERW m_psh; + HWND m_hWnd; + HWND m_hParentWnd; + HINSTANCE m_hInst; + + int m_PageCount; + HPROPSHEETPAGE hPsp[9]; + + LONG_PTR m_OrgProc; + LONG_PTR m_OrgUserData; + + wchar_t *m_UiLanguageFile; +}; Modified: trunk/teraterm/teraterm/addsetting.cpp =================================================================== --- trunk/teraterm/teraterm/addsetting.cpp 2022-04-22 15:37:38 UTC (rev 9882) +++ trunk/teraterm/teraterm/addsetting.cpp 2022-04-22 15:37:48 UTC (rev 9883) @@ -1720,116 +1720,9 @@ ////////////////////////////////////////////////////////////////////////////// -#define REWRITE_TEMPLATE 1 -// quick hack :-( -HINSTANCE TTCPropSheetDlg::ghInstance; -class TTCPropSheetDlg* TTCPropSheetDlg::gTTCPS; - -LRESULT CALLBACK TTCPropSheetDlg::WndProc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch(msg){ - case WM_INITDIALOG: - case WM_SHOWWINDOW: { - CenterWindow(dlg, m_hParentWnd); - break; - } - } - SetWindowLongPtrW(dlg, GWLP_WNDPROC, m_OrgProc); - SetWindowLongPtrW(dlg, GWLP_USERDATA, m_OrgUserData); - LRESULT result = CallWindowProcW((WNDPROC)m_OrgProc, dlg, msg, wParam, lParam); - m_OrgProc = SetWindowLongPtrW(dlg, GWLP_WNDPROC, (LONG_PTR)WndProcStatic); - m_OrgUserData = SetWindowLongPtrW(dlg, GWLP_USERDATA, (LONG_PTR)this); - - return result; -} - -LRESULT CALLBACK TTCPropSheetDlg::WndProcStatic(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - TTCPropSheetDlg*self = (TTCPropSheetDlg*)GetWindowLongPtr(dlg, GWLP_USERDATA); - return self->WndProc(dlg, msg, wParam, lParam); -} - -int CALLBACK TTCPropSheetDlg::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 - // 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: - { - static const DlgTextInfo TextInfos[] = { - { IDOK, "BTN_OK" }, - { IDCANCEL, "BTN_CANCEL" }, - { IDHELP, "BTN_HELP" }, - }; - TTCPropSheetDlg*self = gTTCPS; - self->m_hWnd = hWnd; - SetDlgTexts(hWnd, TextInfos, _countof(TextInfos), ts.UILanguageFile); - self->m_OrgProc = SetWindowLongPtrW(hWnd, GWLP_WNDPROC, (LONG_PTR)WndProcStatic); - self->m_OrgUserData = SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LONG_PTR)self); - break; - } - } - return 0; -} - -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; - memset(&m_psh, 0, sizeof(m_psh)); - m_psh.dwSize = sizeof(m_psh); - m_psh.dwFlags = PSH_DEFAULT | PSH_NOAPPLYNOW | PSH_USECALLBACK; - //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.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) + TTCPropSheetDlg(hInstance, hParentWnd, ts.UILanguageFileW) { // CPP,tmfc\x82\xCCTTCPropertyPage\x94h\x90\xB6\x83N\x83\x89\x83X\x82\xA9\x82琶\x90\xAC int i = 0; Modified: trunk/teraterm/teraterm/addsetting.h =================================================================== --- trunk/teraterm/teraterm/addsetting.h 2022-04-22 15:37:38 UTC (rev 9882) +++ trunk/teraterm/teraterm/addsetting.h 2022-04-22 15:37:48 UTC (rev 9883) @@ -29,6 +29,7 @@ #pragma once #include "tmfc.h" +#include "tmfc_propdlg.h" #include "tt_res.h" #include "teraterm.h" #include "tipwin.h" @@ -128,35 +129,6 @@ void OnHelp(); }; -// Property Sheet -class TTCPropSheetDlg -{ -public: - 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 TTCPropSheetDlg *gTTCPS; - LRESULT CALLBACK WndProc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam); - - PROPSHEETHEADERW m_psh; - HWND m_hWnd; - HWND m_hParentWnd; - HINSTANCE m_hInst; - - int m_PageCount; - HPROPSHEETPAGE hPsp[9]; - - LONG_PTR m_OrgProc; - LONG_PTR m_OrgUserData; -}; - // AddSetting Property Sheet class CAddSettingPropSheetDlg: public TTCPropSheetDlg {