From df44223ecb360c9d2a2edcd6fd7ce4adc86b6588 Mon Sep 17 00:00:00 2001 From: Kengo Ide Date: Wed, 9 Dec 2020 21:44:16 +0900 Subject: [PATCH 1/2] =?UTF-8?q?CBS=5FDROPDOWNLIST=E3=81=A7=E3=81=82?= =?UTF-8?q?=E3=82=8B=E3=82=B3=E3=83=B3=E3=83=9C=E3=83=9C=E3=83=83=E3=82=AF?= =?UTF-8?q?=E3=82=B9=E3=82=92=E3=82=B5=E3=83=96=E3=82=AF=E3=83=A9=E3=82=B9?= =?UTF-8?q?=E5=8C=96=E3=81=97=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sakura_core/dlg/CDialog.cpp | 2 ++ sakura_core/dlg/CDlgOpenFile_CommonFileDialog.cpp | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/sakura_core/dlg/CDialog.cpp b/sakura_core/dlg/CDialog.cpp index 7ec031ba25..05510a80aa 100644 --- a/sakura_core/dlg/CDialog.cpp +++ b/sakura_core/dlg/CDialog.cpp @@ -809,9 +809,11 @@ LRESULT CALLBACK SubEditProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, void CDialog::SetComboBoxDeleter(HWND hwndCtl, CRecent* pRecent) { assert(pRecent); + assert((::GetWindowLongPtr(hwndCtl, GWL_STYLE) & 0b11) != CBS_DROPDOWNLIST); COMBOBOXINFO info = { sizeof(COMBOBOXINFO) }; if (!::GetComboBoxInfo(hwndCtl, &info)) return; + assert(info.hwndCombo != info.hwndItem); ::SetWindowSubclass(info.hwndItem, SubEditProc, 0, (DWORD_PTR)pRecent); } diff --git a/sakura_core/dlg/CDlgOpenFile_CommonFileDialog.cpp b/sakura_core/dlg/CDlgOpenFile_CommonFileDialog.cpp index 2605579771..285255e562 100644 --- a/sakura_core/dlg/CDlgOpenFile_CommonFileDialog.cpp +++ b/sakura_core/dlg/CDlgOpenFile_CommonFileDialog.cpp @@ -370,9 +370,6 @@ UINT_PTR CALLBACK OFNHookProc( /* ビューモードの初期値セット */ ::CheckDlgButton( pData->m_hwndOpenDlg, chx1, pData->m_bViewMode ); - - CDialog::SetComboBoxDeleter(pData->m_hwndComboMRU, &pData->m_cRecentFile); - CDialog::SetComboBoxDeleter(pData->m_hwndComboOPENFOLDER, &pData->m_cRecentFolder); } break; From e7267261ee058e7146077e0b0cb883f179a80dbc Mon Sep 17 00:00:00 2001 From: Kengo Ide Date: Fri, 11 Dec 2020 18:28:55 +0900 Subject: [PATCH 2/2] =?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:=20assert?= =?UTF-8?q?=E3=82=92=E9=99=A4=E5=8E=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sakura_core/dlg/CDialog.cpp | 6 ++---- sakura_core/dlg/CDialog.h | 5 +++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/sakura_core/dlg/CDialog.cpp b/sakura_core/dlg/CDialog.cpp index 05510a80aa..ee7ac7fa69 100644 --- a/sakura_core/dlg/CDialog.cpp +++ b/sakura_core/dlg/CDialog.cpp @@ -808,12 +808,10 @@ LRESULT CALLBACK SubEditProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, void CDialog::SetComboBoxDeleter(HWND hwndCtl, CRecent* pRecent) { - assert(pRecent); - assert((::GetWindowLongPtr(hwndCtl, GWL_STYLE) & 0b11) != CBS_DROPDOWNLIST); - + if (!pRecent || (::GetWindowLongPtr(hwndCtl, GWL_STYLE) & 0b11) == CBS_DROPDOWNLIST) + return; COMBOBOXINFO info = { sizeof(COMBOBOXINFO) }; if (!::GetComboBoxInfo(hwndCtl, &info)) return; - assert(info.hwndCombo != info.hwndItem); ::SetWindowSubclass(info.hwndItem, SubEditProc, 0, (DWORD_PTR)pRecent); } diff --git a/sakura_core/dlg/CDialog.h b/sakura_core/dlg/CDialog.h index 54df51a35d..a81d8fddbc 100644 --- a/sakura_core/dlg/CDialog.h +++ b/sakura_core/dlg/CDialog.h @@ -115,6 +115,11 @@ 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 ); + + //! @brief コンボボックスに履歴削除・単語削除の機能を追加する + //! + //! @param hwndCtl コンボボックスのハンドル。CBS_DROPDOWNLISTスタイルのコンボボックスには対応していません。 + //! @param pRecent 紐づけるCRecentへのポインタ。nullptrは指定できません。 static void SetComboBoxDeleter( HWND hwndCtl, CRecent* pRecent ); public: