From b68b16d2a72ba42b6471797527123ae3e0a3c7f0 Mon Sep 17 00:00:00 2001 From: Kengo Ide Date: Sun, 8 Nov 2020 23:26:11 +0900 Subject: [PATCH 1/5] =?UTF-8?q?GetComboBoxInfo=20=E3=82=92=E4=BD=BF?= =?UTF-8?q?=E3=81=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sakura_core/dlg/CDialog.cpp | 51 ++++++++----------------------------- sakura_core/dlg/CDialog.h | 3 +-- 2 files changed, 11 insertions(+), 43 deletions(-) diff --git a/sakura_core/dlg/CDialog.cpp b/sakura_core/dlg/CDialog.cpp index 9cae984b6f..507606277a 100644 --- a/sakura_core/dlg/CDialog.cpp +++ b/sakura_core/dlg/CDialog.cpp @@ -805,51 +805,20 @@ LRESULT CALLBACK SubListBoxProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPar return CallWindowProc(data->pListBoxWndProc, hwnd, uMsg, wParam, lParam); } -LRESULT CALLBACK SubComboBoxProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - SComboBoxItemDeleter* data = (SComboBoxItemDeleter*)::GetProp( hwnd, TSTR_SUBCOMBOBOXDATA ); - switch( uMsg ){ - case WM_CTLCOLOREDIT: - { - if( NULL == data->pEditWndProc ){ - HWND hwndCtl = (HWND)lParam; - data->pEditWndProc = (WNDPROC)::GetWindowLongPtr(hwndCtl, GWLP_WNDPROC); - ::SetProp(hwndCtl, TSTR_SUBCOMBOBOXDATA, data); - ::SetWindowLongPtr(hwndCtl, GWLP_WNDPROC, (LONG_PTR)SubEditProc); - } - break; - } - case WM_CTLCOLORLISTBOX: - { - if( NULL == data->pListBoxWndProc ){ - HWND hwndCtl = (HWND)lParam; - data->pListBoxWndProc = (WNDPROC)::GetWindowLongPtr(hwndCtl, GWLP_WNDPROC); - ::SetProp(hwndCtl, TSTR_SUBCOMBOBOXDATA, data); - ::SetWindowLongPtr(hwndCtl, GWLP_WNDPROC, (LONG_PTR)SubListBoxProc); - } - break; - } - case WM_DESTROY: - { - ::SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)data->pComboBoxWndProc); - ::RemoveProp(hwnd, TSTR_SUBCOMBOBOXDATA); - data->pComboBoxWndProc = NULL; - break; - } - - default: - break; - } - return CallWindowProc(data->pComboBoxWndProc, hwnd, uMsg, wParam, lParam); -} - void CDialog::SetComboBoxDeleter( HWND hwndCtl, SComboBoxItemDeleter* data ) { if( NULL == data->pRecent ){ return; } data->hwndCombo = hwndCtl; - data->pComboBoxWndProc = (WNDPROC)::GetWindowLongPtr(hwndCtl, GWLP_WNDPROC); - ::SetProp(hwndCtl, TSTR_SUBCOMBOBOXDATA, data); - ::SetWindowLongPtr(hwndCtl, GWLP_WNDPROC, (LONG_PTR)SubComboBoxProc); + + COMBOBOXINFO info = { sizeof(COMBOBOXINFO) }; + if (!::GetComboBoxInfo(hwndCtl, &info)) + return; + data->pEditWndProc = reinterpret_cast(::GetWindowLongPtr(info.hwndItem, GWLP_WNDPROC)); + ::SetProp(info.hwndItem, TSTR_SUBCOMBOBOXDATA, data); + ::SetWindowLongPtr(info.hwndItem, GWLP_WNDPROC, reinterpret_cast(SubEditProc)); + data->pListBoxWndProc = reinterpret_cast(::GetWindowLongPtr(info.hwndList, GWLP_WNDPROC)); + ::SetProp(info.hwndList, TSTR_SUBCOMBOBOXDATA, data); + ::SetWindowLongPtr(info.hwndList, GWLP_WNDPROC, reinterpret_cast(SubListBoxProc)); } diff --git a/sakura_core/dlg/CDialog.h b/sakura_core/dlg/CDialog.h index cbbaa79528..a667dfca46 100644 --- a/sakura_core/dlg/CDialog.h +++ b/sakura_core/dlg/CDialog.h @@ -55,10 +55,9 @@ struct SComboBoxItemDeleter { CRecent* pRecent; HWND hwndCombo; - WNDPROC pComboBoxWndProc; WNDPROC pEditWndProc; WNDPROC pListBoxWndProc; - SComboBoxItemDeleter(): pRecent(NULL), hwndCombo(NULL), pComboBoxWndProc(NULL), pEditWndProc(NULL), pListBoxWndProc(NULL){} + SComboBoxItemDeleter(): pRecent(NULL), hwndCombo(NULL), pEditWndProc(NULL), pListBoxWndProc(NULL){} }; /*----------------------------------------------------------------------- From be81a57d44b5e409c572718bd2d28553eccd9f82 Mon Sep 17 00:00:00 2001 From: Kengo Ide Date: Tue, 10 Nov 2020 22:30:00 +0900 Subject: [PATCH 2/5] =?UTF-8?q?SetWindowSubclass=20=E3=82=92=E4=BD=BF?= =?UTF-8?q?=E3=81=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sakura_core/dlg/CDialog.cpp | 40 ++++++++++--------------------------- sakura_core/dlg/CDialog.h | 4 +--- 2 files changed, 11 insertions(+), 33 deletions(-) diff --git a/sakura_core/dlg/CDialog.cpp b/sakura_core/dlg/CDialog.cpp index 507606277a..81b356b35d 100644 --- a/sakura_core/dlg/CDialog.cpp +++ b/sakura_core/dlg/CDialog.cpp @@ -747,9 +747,10 @@ static void DeleteRecentItem( } } -LRESULT CALLBACK SubEditProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +LRESULT CALLBACK SubEditProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, + UINT_PTR uIdSubclass, DWORD_PTR dwRefData) { - SComboBoxItemDeleter* data = (SComboBoxItemDeleter*)::GetProp( hwnd, TSTR_SUBCOMBOBOXDATA ); + SComboBoxItemDeleter* data = reinterpret_cast(dwRefData); switch( uMsg ){ case WM_KEYDOWN: { @@ -763,22 +764,14 @@ LRESULT CALLBACK SubEditProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) } break; } - case WM_DESTROY: - { - ::SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)data->pEditWndProc); - ::RemoveProp(hwnd, TSTR_SUBCOMBOBOXDATA); - data->pEditWndProc = NULL; - break; - } - default: - break; } - return CallWindowProc(data->pEditWndProc, hwnd, uMsg, wParam, lParam); + return ::DefSubclassProc(hwnd, uMsg, wParam, lParam); } -LRESULT CALLBACK SubListBoxProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +LRESULT CALLBACK SubListBoxProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, + UINT_PTR uIdSubclass, DWORD_PTR dwRefData) { - SComboBoxItemDeleter* data = (SComboBoxItemDeleter*)::GetProp( hwnd, TSTR_SUBCOMBOBOXDATA ); + SComboBoxItemDeleter* data = reinterpret_cast(dwRefData); switch( uMsg ){ case WM_KEYDOWN: { @@ -792,17 +785,8 @@ LRESULT CALLBACK SubListBoxProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPar } break; } - case WM_DESTROY: - { - ::SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)data->pListBoxWndProc); - ::RemoveProp(hwnd, TSTR_SUBCOMBOBOXDATA); - data->pListBoxWndProc = NULL; - break; - } - default: - break; } - return CallWindowProc(data->pListBoxWndProc, hwnd, uMsg, wParam, lParam); + return ::DefSubclassProc(hwnd, uMsg, wParam, lParam); } void CDialog::SetComboBoxDeleter( HWND hwndCtl, SComboBoxItemDeleter* data ) @@ -815,10 +799,6 @@ void CDialog::SetComboBoxDeleter( HWND hwndCtl, SComboBoxItemDeleter* data ) COMBOBOXINFO info = { sizeof(COMBOBOXINFO) }; if (!::GetComboBoxInfo(hwndCtl, &info)) return; - data->pEditWndProc = reinterpret_cast(::GetWindowLongPtr(info.hwndItem, GWLP_WNDPROC)); - ::SetProp(info.hwndItem, TSTR_SUBCOMBOBOXDATA, data); - ::SetWindowLongPtr(info.hwndItem, GWLP_WNDPROC, reinterpret_cast(SubEditProc)); - data->pListBoxWndProc = reinterpret_cast(::GetWindowLongPtr(info.hwndList, GWLP_WNDPROC)); - ::SetProp(info.hwndList, TSTR_SUBCOMBOBOXDATA, data); - ::SetWindowLongPtr(info.hwndList, GWLP_WNDPROC, reinterpret_cast(SubListBoxProc)); + ::SetWindowSubclass(info.hwndItem, SubEditProc, 0, reinterpret_cast(data)); + ::SetWindowSubclass(info.hwndList, SubListBoxProc, 0, reinterpret_cast(data)); } diff --git a/sakura_core/dlg/CDialog.h b/sakura_core/dlg/CDialog.h index a667dfca46..0647cdf615 100644 --- a/sakura_core/dlg/CDialog.h +++ b/sakura_core/dlg/CDialog.h @@ -55,9 +55,7 @@ struct SComboBoxItemDeleter { CRecent* pRecent; HWND hwndCombo; - WNDPROC pEditWndProc; - WNDPROC pListBoxWndProc; - SComboBoxItemDeleter(): pRecent(NULL), hwndCombo(NULL), pEditWndProc(NULL), pListBoxWndProc(NULL){} + SComboBoxItemDeleter() : pRecent(NULL), hwndCombo(NULL) {} }; /*----------------------------------------------------------------------- From 668927cd79f063b9ba21c58dd8d45f10ebd2f574 Mon Sep 17 00:00:00 2001 From: Kengo Ide Date: Tue, 10 Nov 2020 23:38:08 +0900 Subject: [PATCH 3/5] =?UTF-8?q?SComboBoxItemDeleter=20=E3=82=92=E5=BB=83?= =?UTF-8?q?=E6=AD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit コンボボックスに CRecent を SetProp して直に紐づけ、コンボボックスのハンドルをサブクラスプロシージャに付属データとして渡す。 サブクラスプロシージャはコンボボックスのハンドルから GetProp して CRecent を取得する。 --- sakura_core/dlg/CDialog.cpp | 22 ++++++++---------- sakura_core/dlg/CDialog.h | 9 +------- sakura_core/dlg/CDlgExec.cpp | 9 ++------ sakura_core/dlg/CDlgExec.h | 2 -- sakura_core/dlg/CDlgFind.cpp | 4 +--- sakura_core/dlg/CDlgFind.h | 1 - sakura_core/dlg/CDlgGrep.cpp | 23 +++++-------------- sakura_core/dlg/CDlgGrep.h | 9 -------- sakura_core/dlg/CDlgGrepReplace.cpp | 4 +--- sakura_core/dlg/CDlgGrepReplace.h | 1 - .../dlg/CDlgOpenFile_CommonFileDialog.cpp | 10 ++------ sakura_core/dlg/CDlgReplace.cpp | 8 ++----- sakura_core/dlg/CDlgReplace.h | 2 -- sakura_core/dlg/CDlgTagJumpList.cpp | 4 +--- sakura_core/dlg/CDlgTagJumpList.h | 1 - sakura_core/window/CMainToolBar.cpp | 4 +--- sakura_core/window/CMainToolBar.h | 1 - 17 files changed, 26 insertions(+), 88 deletions(-) diff --git a/sakura_core/dlg/CDialog.cpp b/sakura_core/dlg/CDialog.cpp index 81b356b35d..fa460cf5fd 100644 --- a/sakura_core/dlg/CDialog.cpp +++ b/sakura_core/dlg/CDialog.cpp @@ -750,16 +750,15 @@ static void DeleteRecentItem( LRESULT CALLBACK SubEditProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) { - SComboBoxItemDeleter* data = reinterpret_cast(dwRefData); + HWND hwndCombo = reinterpret_cast(dwRefData); switch( uMsg ){ case WM_KEYDOWN: { if( wParam == VK_DELETE ){ - HWND hwndCombo = data->hwndCombo; BOOL bShow = Combo_GetDroppedState(hwndCombo); int nIndex = Combo_GetCurSel(hwndCombo); if( bShow && 0 <= nIndex ){ - DeleteRecentItem(hwndCombo, nIndex, data->pRecent); + DeleteRecentItem(hwndCombo, nIndex, reinterpret_cast(::GetProp(hwndCombo, TSTR_SUBCOMBOBOXDATA))); } } break; @@ -771,15 +770,14 @@ LRESULT CALLBACK SubEditProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT CALLBACK SubListBoxProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) { - SComboBoxItemDeleter* data = reinterpret_cast(dwRefData); + HWND hwndCombo = reinterpret_cast(dwRefData); switch( uMsg ){ case WM_KEYDOWN: { if( wParam == VK_DELETE ){ - HWND hwndCombo = data->hwndCombo; int nIndex = Combo_GetCurSel(hwndCombo); if( 0 <= nIndex ){ - DeleteRecentItem(hwndCombo, nIndex, data->pRecent); + DeleteRecentItem(hwndCombo, nIndex, reinterpret_cast(::GetProp(hwndCombo, TSTR_SUBCOMBOBOXDATA))); return 0; } } @@ -789,16 +787,14 @@ LRESULT CALLBACK SubListBoxProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPar return ::DefSubclassProc(hwnd, uMsg, wParam, lParam); } -void CDialog::SetComboBoxDeleter( HWND hwndCtl, SComboBoxItemDeleter* data ) +void CDialog::SetComboBoxDeleter(HWND hwndCtl, CRecent* pRecent) { - if( NULL == data->pRecent ){ - return; - } - data->hwndCombo = hwndCtl; + assert(pRecent); COMBOBOXINFO info = { sizeof(COMBOBOXINFO) }; if (!::GetComboBoxInfo(hwndCtl, &info)) return; - ::SetWindowSubclass(info.hwndItem, SubEditProc, 0, reinterpret_cast(data)); - ::SetWindowSubclass(info.hwndList, SubListBoxProc, 0, reinterpret_cast(data)); + ::SetProp(hwndCtl, TSTR_SUBCOMBOBOXDATA, pRecent); + ::SetWindowSubclass(info.hwndItem, SubEditProc, 0, reinterpret_cast(hwndCtl)); + ::SetWindowSubclass(info.hwndList, SubListBoxProc, 0, reinterpret_cast(hwndCtl)); } diff --git a/sakura_core/dlg/CDialog.h b/sakura_core/dlg/CDialog.h index 0647cdf615..54df51a35d 100644 --- a/sakura_core/dlg/CDialog.h +++ b/sakura_core/dlg/CDialog.h @@ -51,13 +51,6 @@ struct SAnchorList EAnchorStyle anchor; }; -struct SComboBoxItemDeleter -{ - CRecent* pRecent; - HWND hwndCombo; - SComboBoxItemDeleter() : pRecent(NULL), hwndCombo(NULL) {} -}; - /*----------------------------------------------------------------------- クラスの宣言 -----------------------------------------------------------------------*/ @@ -122,7 +115,7 @@ class CDialog void ResizeItem( HWND hTarget, const POINT& ptDlgDefalut, const POINT& ptDlgNew, const RECT& rcItemDefault, EAnchorStyle anchor, bool bUpdate = true); void GetItemClientRect( int wID, RECT& rc ); - static void SetComboBoxDeleter( HWND hwndCtl, SComboBoxItemDeleter* data ); + static void SetComboBoxDeleter( HWND hwndCtl, CRecent* pRecent ); public: static bool DirectoryUp(WCHAR* szDir); diff --git a/sakura_core/dlg/CDlgExec.cpp b/sakura_core/dlg/CDlgExec.cpp index 54fa35e230..f77fc310c8 100644 --- a/sakura_core/dlg/CDlgExec.cpp +++ b/sakura_core/dlg/CDlgExec.cpp @@ -81,13 +81,8 @@ BOOL CDlgExec::OnInitDialog( HWND hwnd, WPARAM wParam, LPARAM lParam ) } BOOL bRet = CDialog::OnInitDialog(hwnd, wParam, lParam); - - m_comboDel = SComboBoxItemDeleter(); - m_comboDel.pRecent = &m_cRecentCmd; - SetComboBoxDeleter(GetItemHwnd(IDC_COMBO_m_szCommand), &m_comboDel); - m_comboDelCur = SComboBoxItemDeleter(); - m_comboDelCur.pRecent = &m_cRecentCur; - SetComboBoxDeleter(GetItemHwnd(IDC_COMBO_CUR_DIR), &m_comboDelCur); + SetComboBoxDeleter(GetItemHwnd(IDC_COMBO_m_szCommand), &m_cRecentCmd); + SetComboBoxDeleter(GetItemHwnd(IDC_COMBO_CUR_DIR), &m_cRecentCur); return bRet; } diff --git a/sakura_core/dlg/CDlgExec.h b/sakura_core/dlg/CDlgExec.h index 1dbd6459f4..0da897dcfd 100644 --- a/sakura_core/dlg/CDlgExec.h +++ b/sakura_core/dlg/CDlgExec.h @@ -38,9 +38,7 @@ class CDlgExec final : public CDialog bool m_bEditable; /* 編集ウィンドウへの入力可能 */ // 2009.02.21 ryoji protected: - SComboBoxItemDeleter m_comboDel; CRecentCmd m_cRecentCmd; - SComboBoxItemDeleter m_comboDelCur; CRecentCurDir m_cRecentCur; int GetData( void ) override; /* ダイアログデータの取得 */ diff --git a/sakura_core/dlg/CDlgFind.cpp b/sakura_core/dlg/CDlgFind.cpp index 233b6756be..b3f529f1a2 100644 --- a/sakura_core/dlg/CDlgFind.cpp +++ b/sakura_core/dlg/CDlgFind.cpp @@ -90,9 +90,7 @@ void CDlgFind::ChangeView( LPARAM pcEditView ) BOOL CDlgFind::OnInitDialog( HWND hwnd, WPARAM wParam, LPARAM lParam ) { BOOL bRet = CDialog::OnInitDialog(hwnd, wParam, lParam); - m_comboDel = SComboBoxItemDeleter(); - m_comboDel.pRecent = &m_cRecentSearch; - SetComboBoxDeleter(GetItemHwnd(IDC_COMBO_TEXT), &m_comboDel); + SetComboBoxDeleter(GetItemHwnd(IDC_COMBO_TEXT), &m_cRecentSearch); // フォント設定 2012/11/27 Uchi HFONT hFontOld = (HFONT)::SendMessageAny( GetItemHwnd( IDC_COMBO_TEXT ), WM_GETFONT, 0, 0 ); diff --git a/sakura_core/dlg/CDlgFind.h b/sakura_core/dlg/CDlgFind.h index fcbb474c7f..57adbef024 100644 --- a/sakura_core/dlg/CDlgFind.h +++ b/sakura_core/dlg/CDlgFind.h @@ -45,7 +45,6 @@ class CDlgFind final : public CDialog CLogicPoint m_ptEscCaretPos_PHY; // 検索開始時のカーソル位置退避エリア CRecentSearch m_cRecentSearch; - SComboBoxItemDeleter m_comboDel; CFontAutoDeleter m_cFontText; protected: diff --git a/sakura_core/dlg/CDlgGrep.cpp b/sakura_core/dlg/CDlgGrep.cpp index 3d4f1ca81d..556a6107a9 100644 --- a/sakura_core/dlg/CDlgGrep.cpp +++ b/sakura_core/dlg/CDlgGrep.cpp @@ -331,23 +331,12 @@ BOOL CDlgGrep::OnInitDialog( HWND hwndDlg, WPARAM wParam, LPARAM lParam ) g_pOnFolderProc = (WNDPROC)GetWindowLongPtr(hFolder, GWLP_WNDPROC); SetWindowLongPtr(hFolder, GWLP_WNDPROC, (LONG_PTR)OnFolderProc); - m_comboDelText = SComboBoxItemDeleter(); - m_comboDelText.pRecent = &m_cRecentSearch; - SetComboBoxDeleter(GetItemHwnd(IDC_COMBO_TEXT), &m_comboDelText); - m_comboDelFile = SComboBoxItemDeleter(); - m_comboDelFile.pRecent = &m_cRecentGrepFile; - SetComboBoxDeleter(GetItemHwnd(IDC_COMBO_FILE), &m_comboDelFile); - m_comboDelFolder = SComboBoxItemDeleter(); - m_comboDelFolder.pRecent = &m_cRecentGrepFolder; - SetComboBoxDeleter(GetItemHwnd(IDC_COMBO_FOLDER), &m_comboDelFolder); - - m_comboDelExcludeFile = SComboBoxItemDeleter(); - m_comboDelExcludeFile.pRecent = &m_cRecentExcludeFile; - SetComboBoxDeleter(GetItemHwnd(IDC_COMBO_EXCLUDE_FILE), &m_comboDelExcludeFile); - - m_comboDelExcludeFolder = SComboBoxItemDeleter(); - m_comboDelExcludeFolder.pRecent = &m_cRecentExcludeFolder; - SetComboBoxDeleter(GetItemHwnd(IDC_COMBO_EXCLUDE_FOLDER), &m_comboDelExcludeFolder); + SetComboBoxDeleter(GetItemHwnd(IDC_COMBO_TEXT), &m_cRecentSearch); + SetComboBoxDeleter(GetItemHwnd(IDC_COMBO_FILE), &m_cRecentGrepFile); + SetComboBoxDeleter(GetItemHwnd(IDC_COMBO_FOLDER), &m_cRecentGrepFolder); + + SetComboBoxDeleter(GetItemHwnd(IDC_COMBO_EXCLUDE_FILE), &m_cRecentExcludeFile); + SetComboBoxDeleter(GetItemHwnd(IDC_COMBO_EXCLUDE_FOLDER), &m_cRecentExcludeFolder); BOOL bRet = CDialog::OnInitDialog( hwndDlg, wParam, lParam ); if( !bRet ) return bRet; diff --git a/sakura_core/dlg/CDlgGrep.h b/sakura_core/dlg/CDlgGrep.h index aef4dfe96e..a05ca54ee7 100644 --- a/sakura_core/dlg/CDlgGrep.h +++ b/sakura_core/dlg/CDlgGrep.h @@ -61,19 +61,10 @@ class CDlgGrep : public CDialog SFilePathLong m_szExcludeFolder; //!< 除外フォルダ SFilePath m_szCurrentFilePath; protected: - SComboBoxItemDeleter m_comboDelText; CRecentSearch m_cRecentSearch; - - SComboBoxItemDeleter m_comboDelFile; CRecentGrepFile m_cRecentGrepFile; - - SComboBoxItemDeleter m_comboDelFolder; CRecentGrepFolder m_cRecentGrepFolder; - - SComboBoxItemDeleter m_comboDelExcludeFile; CRecentExcludeFile m_cRecentExcludeFile; - - SComboBoxItemDeleter m_comboDelExcludeFolder; CRecentExcludeFolder m_cRecentExcludeFolder; std::vector m_cFontDeleters; diff --git a/sakura_core/dlg/CDlgGrepReplace.cpp b/sakura_core/dlg/CDlgGrepReplace.cpp index e83bf7abcc..f073934f4b 100644 --- a/sakura_core/dlg/CDlgGrepReplace.cpp +++ b/sakura_core/dlg/CDlgGrepReplace.cpp @@ -129,9 +129,7 @@ BOOL CDlgGrepReplace::OnInitDialog( HWND hwndDlg, WPARAM wParam, LPARAM lParam ) /* コンボボックスのユーザー インターフェイスを拡張インターフェースにする */ Combo_SetExtendedUI( GetItemHwnd( IDC_COMBO_TEXT2 ), TRUE ); - m_comboDelText2 = SComboBoxItemDeleter(); - m_comboDelText2.pRecent = &m_cRecentReplace; - SetComboBoxDeleter( GetItemHwnd( IDC_COMBO_TEXT2 ), &m_comboDelText2 ); + SetComboBoxDeleter(GetItemHwnd(IDC_COMBO_TEXT2), &m_cRecentReplace); BOOL bRet = CDlgGrep::OnInitDialog( hwndDlg, wParam, lParam ); if( !bRet ) return bRet; diff --git a/sakura_core/dlg/CDlgGrepReplace.h b/sakura_core/dlg/CDlgGrepReplace.h index e0b5215a9a..dd880b5e62 100644 --- a/sakura_core/dlg/CDlgGrepReplace.h +++ b/sakura_core/dlg/CDlgGrepReplace.h @@ -42,7 +42,6 @@ class CDlgGrepReplace final : public CDlgGrep protected: CRecentReplace m_cRecentReplace; - SComboBoxItemDeleter m_comboDelText2; CFontAutoDeleter m_cFontText2; /* diff --git a/sakura_core/dlg/CDlgOpenFile_CommonFileDialog.cpp b/sakura_core/dlg/CDlgOpenFile_CommonFileDialog.cpp index f60f54a878..2605579771 100644 --- a/sakura_core/dlg/CDlgOpenFile_CommonFileDialog.cpp +++ b/sakura_core/dlg/CDlgOpenFile_CommonFileDialog.cpp @@ -118,9 +118,7 @@ class CDlgOpenFileData{ bool m_bInitCodePage; - SComboBoxItemDeleter m_combDelFile; CRecentFile m_cRecentFile; - SComboBoxItemDeleter m_combDelFolder; CRecentFolder m_cRecentFolder; OPENFILENAME* m_pOf; @@ -373,12 +371,8 @@ UINT_PTR CALLBACK OFNHookProc( /* ビューモードの初期値セット */ ::CheckDlgButton( pData->m_hwndOpenDlg, chx1, pData->m_bViewMode ); - pData->m_combDelFile = SComboBoxItemDeleter(); - pData->m_combDelFile.pRecent = &pData->m_cRecentFile; - CDialog::SetComboBoxDeleter(pData->m_hwndComboMRU, &pData->m_combDelFile); - pData->m_combDelFolder = SComboBoxItemDeleter(); - pData->m_combDelFolder.pRecent = &pData->m_cRecentFolder; - CDialog::SetComboBoxDeleter(pData->m_hwndComboOPENFOLDER, &pData->m_combDelFolder); + CDialog::SetComboBoxDeleter(pData->m_hwndComboMRU, &pData->m_cRecentFile); + CDialog::SetComboBoxDeleter(pData->m_hwndComboOPENFOLDER, &pData->m_cRecentFolder); } break; diff --git a/sakura_core/dlg/CDlgReplace.cpp b/sakura_core/dlg/CDlgReplace.cpp index ff655a56f5..aae4967223 100644 --- a/sakura_core/dlg/CDlgReplace.cpp +++ b/sakura_core/dlg/CDlgReplace.cpp @@ -343,12 +343,8 @@ BOOL CDlgReplace::OnInitDialog( HWND hwndDlg, WPARAM wParam, LPARAM lParam ) ::CheckDlgButton( GetHwnd(), IDC_RADIO_ALLAREA, TRUE ); } - m_comboDelText = SComboBoxItemDeleter(); - m_comboDelText.pRecent = &m_cRecentSearch; - SetComboBoxDeleter(GetItemHwnd(IDC_COMBO_TEXT), &m_comboDelText); - m_comboDelText2 = SComboBoxItemDeleter(); - m_comboDelText2.pRecent = &m_cRecentReplace; - SetComboBoxDeleter(GetItemHwnd(IDC_COMBO_TEXT2), &m_comboDelText2); + SetComboBoxDeleter(GetItemHwnd(IDC_COMBO_TEXT), &m_cRecentSearch); + SetComboBoxDeleter(GetItemHwnd(IDC_COMBO_TEXT2), &m_cRecentReplace); BOOL bRet = CDialog::OnInitDialog( hwndDlg, wParam, lParam ); if( !bRet ) return bRet; diff --git a/sakura_core/dlg/CDlgReplace.h b/sakura_core/dlg/CDlgReplace.h index 735cd02a97..5ad655deb6 100644 --- a/sakura_core/dlg/CDlgReplace.h +++ b/sakura_core/dlg/CDlgReplace.h @@ -59,9 +59,7 @@ class CDlgReplace final : public CDialog protected: CRecentSearch m_cRecentSearch; - SComboBoxItemDeleter m_comboDelText; CRecentReplace m_cRecentReplace; - SComboBoxItemDeleter m_comboDelText2; CFontAutoDeleter m_cFontText; CFontAutoDeleter m_cFontText2; diff --git a/sakura_core/dlg/CDlgTagJumpList.cpp b/sakura_core/dlg/CDlgTagJumpList.cpp index 0f7edae7fe..abb29034bf 100644 --- a/sakura_core/dlg/CDlgTagJumpList.cpp +++ b/sakura_core/dlg/CDlgTagJumpList.cpp @@ -522,9 +522,7 @@ BOOL CDlgTagJumpList::OnInitDialog( HWND hwndDlg, WPARAM wParam, LPARAM lParam ) bRet = FALSE; //for set focus } - m_comboDel = SComboBoxItemDeleter(); - m_comboDel.pRecent = &m_cRecentKeyword; - SetComboBoxDeleter(hwndKey, &m_comboDel); + SetComboBoxDeleter(hwndKey, &m_cRecentKeyword); /* 基底クラスメンバ */ CDialog::OnInitDialog( GetHwnd(), wParam, lParam ); diff --git a/sakura_core/dlg/CDlgTagJumpList.h b/sakura_core/dlg/CDlgTagJumpList.h index d540610381..7e60ea27d3 100644 --- a/sakura_core/dlg/CDlgTagJumpList.h +++ b/sakura_core/dlg/CDlgTagJumpList.h @@ -165,7 +165,6 @@ class CDlgTagJumpList final : public CDialog BOOL m_bOldTagJumpICase; //!< 前回の大文字小文字を同一視 BOOL m_bOldTagJumpPartialMatch; //!< 前回の文字列の途中にマッチ - SComboBoxItemDeleter m_comboDel; CRecentTagjumpKeyword m_cRecentKeyword; POINT m_ptDefaultSize; diff --git a/sakura_core/window/CMainToolBar.cpp b/sakura_core/window/CMainToolBar.cpp index eb6a14c001..3ae54c4031 100644 --- a/sakura_core/window/CMainToolBar.cpp +++ b/sakura_core/window/CMainToolBar.cpp @@ -327,9 +327,7 @@ void CMainToolBar::CreateToolBar( void ) //検索ボックスを更新 // 関数化 2010/6/6 Uchi AcceptSharedSearchKey(); - m_comboDel = SComboBoxItemDeleter(); // 再表示用の初期化 - m_comboDel.pRecent = &m_cRecentSearch; - CDialog::SetComboBoxDeleter(m_hwndSearchBox, &m_comboDel); + CDialog::SetComboBoxDeleter(m_hwndSearchBox, &m_cRecentSearch); // コンボボックスの位置と幅を調整する CMyRect rcCombo; diff --git a/sakura_core/window/CMainToolBar.h b/sakura_core/window/CMainToolBar.h index b27ff43a1b..287e3744f3 100644 --- a/sakura_core/window/CMainToolBar.h +++ b/sakura_core/window/CMainToolBar.h @@ -76,7 +76,6 @@ class CMainToolBar{ //フォント HFONT m_hFontSearchBox; //!< 検索コンボボックスのフォント - SComboBoxItemDeleter m_comboDel; CRecentSearch m_cRecentSearch; CImageListMgr* m_pcIcons; }; From 50697f61905e936b94474622b48f452199d20534 Mon Sep 17 00:00:00 2001 From: Kengo Ide Date: Thu, 12 Nov 2020 19:29:11 +0900 Subject: [PATCH 4/5] =?UTF-8?q?=E3=83=AC=E3=83=93=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E6=8C=87=E6=91=98=E3=81=AB=E5=AF=BE=E5=BF=9C:=20C-style=20?= =?UTF-8?q?=E3=82=AD=E3=83=A3=E3=82=B9=E3=83=88=E3=82=92=E4=BD=BF=E3=81=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sakura_core/dlg/CDialog.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sakura_core/dlg/CDialog.cpp b/sakura_core/dlg/CDialog.cpp index fa460cf5fd..1dc1f0a177 100644 --- a/sakura_core/dlg/CDialog.cpp +++ b/sakura_core/dlg/CDialog.cpp @@ -750,7 +750,7 @@ static void DeleteRecentItem( LRESULT CALLBACK SubEditProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) { - HWND hwndCombo = reinterpret_cast(dwRefData); + HWND hwndCombo = (HWND)dwRefData; switch( uMsg ){ case WM_KEYDOWN: { @@ -758,7 +758,7 @@ LRESULT CALLBACK SubEditProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL bShow = Combo_GetDroppedState(hwndCombo); int nIndex = Combo_GetCurSel(hwndCombo); if( bShow && 0 <= nIndex ){ - DeleteRecentItem(hwndCombo, nIndex, reinterpret_cast(::GetProp(hwndCombo, TSTR_SUBCOMBOBOXDATA))); + DeleteRecentItem(hwndCombo, nIndex, (CRecent*)::GetProp(hwndCombo, TSTR_SUBCOMBOBOXDATA)); } } break; @@ -770,14 +770,14 @@ LRESULT CALLBACK SubEditProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT CALLBACK SubListBoxProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) { - HWND hwndCombo = reinterpret_cast(dwRefData); + HWND hwndCombo = (HWND)dwRefData; switch( uMsg ){ case WM_KEYDOWN: { if( wParam == VK_DELETE ){ int nIndex = Combo_GetCurSel(hwndCombo); if( 0 <= nIndex ){ - DeleteRecentItem(hwndCombo, nIndex, reinterpret_cast(::GetProp(hwndCombo, TSTR_SUBCOMBOBOXDATA))); + DeleteRecentItem(hwndCombo, nIndex, (CRecent*)::GetProp(hwndCombo, TSTR_SUBCOMBOBOXDATA)); return 0; } } @@ -795,6 +795,6 @@ void CDialog::SetComboBoxDeleter(HWND hwndCtl, CRecent* pRecent) if (!::GetComboBoxInfo(hwndCtl, &info)) return; ::SetProp(hwndCtl, TSTR_SUBCOMBOBOXDATA, pRecent); - ::SetWindowSubclass(info.hwndItem, SubEditProc, 0, reinterpret_cast(hwndCtl)); - ::SetWindowSubclass(info.hwndList, SubListBoxProc, 0, reinterpret_cast(hwndCtl)); + ::SetWindowSubclass(info.hwndItem, SubEditProc, 0, (DWORD_PTR)hwndCtl); + ::SetWindowSubclass(info.hwndList, SubListBoxProc, 0, (DWORD_PTR)hwndCtl); } From 45acfb3e2afe735016be42df4cd40a816a9244fd Mon Sep 17 00:00:00 2001 From: Kengo Ide Date: Sun, 15 Nov 2020 23:40:49 +0900 Subject: [PATCH 5/5] =?UTF-8?q?=E3=83=AC=E3=83=93=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E6=8C=87=E6=91=98=E3=81=AB=E5=AF=BE=E5=BF=9C:=20=E3=83=AA?= =?UTF-8?q?=E3=82=B9=E3=83=88=E3=83=9C=E3=83=83=E3=82=AF=E3=82=B9=E3=81=AE?= =?UTF-8?q?=E3=82=B5=E3=83=96=E3=82=AF=E3=83=A9=E3=82=B9=E5=8C=96=E3=82=92?= =?UTF-8?q?=E3=82=84=E3=82=81=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sakura_core/dlg/CDialog.cpp | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/sakura_core/dlg/CDialog.cpp b/sakura_core/dlg/CDialog.cpp index 1dc1f0a177..9706d412a6 100644 --- a/sakura_core/dlg/CDialog.cpp +++ b/sakura_core/dlg/CDialog.cpp @@ -699,8 +699,6 @@ void CDialog::GetItemClientRect( int wID, RECT& rc ) rc.bottom = po.y; } -static const WCHAR* TSTR_SUBCOMBOBOXDATA = L"SubComboBoxData"; - /*! コンボボックスのリストアイテムを関連付けられた履歴と共に削除する */ static void DeleteRecentItem( @@ -750,7 +748,7 @@ static void DeleteRecentItem( LRESULT CALLBACK SubEditProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) { - HWND hwndCombo = (HWND)dwRefData; + HWND hwndCombo = GetParent(hwnd); switch( uMsg ){ case WM_KEYDOWN: { @@ -758,27 +756,7 @@ LRESULT CALLBACK SubEditProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL bShow = Combo_GetDroppedState(hwndCombo); int nIndex = Combo_GetCurSel(hwndCombo); if( bShow && 0 <= nIndex ){ - DeleteRecentItem(hwndCombo, nIndex, (CRecent*)::GetProp(hwndCombo, TSTR_SUBCOMBOBOXDATA)); - } - } - break; - } - } - return ::DefSubclassProc(hwnd, uMsg, wParam, lParam); -} - -LRESULT CALLBACK SubListBoxProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, - UINT_PTR uIdSubclass, DWORD_PTR dwRefData) -{ - HWND hwndCombo = (HWND)dwRefData; - switch( uMsg ){ - case WM_KEYDOWN: - { - if( wParam == VK_DELETE ){ - int nIndex = Combo_GetCurSel(hwndCombo); - if( 0 <= nIndex ){ - DeleteRecentItem(hwndCombo, nIndex, (CRecent*)::GetProp(hwndCombo, TSTR_SUBCOMBOBOXDATA)); - return 0; + DeleteRecentItem(hwndCombo, nIndex, (CRecent*)dwRefData); } } break; @@ -794,7 +772,5 @@ void CDialog::SetComboBoxDeleter(HWND hwndCtl, CRecent* pRecent) COMBOBOXINFO info = { sizeof(COMBOBOXINFO) }; if (!::GetComboBoxInfo(hwndCtl, &info)) return; - ::SetProp(hwndCtl, TSTR_SUBCOMBOBOXDATA, pRecent); - ::SetWindowSubclass(info.hwndItem, SubEditProc, 0, (DWORD_PTR)hwndCtl); - ::SetWindowSubclass(info.hwndList, SubListBoxProc, 0, (DWORD_PTR)hwndCtl); + ::SetWindowSubclass(info.hwndItem, SubEditProc, 0, (DWORD_PTR)pRecent); }