Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

コンボボックスのサブクラス化処理を簡素化する #1463

Merged
merged 5 commits into from
Nov 22, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 10 additions & 30 deletions sakura_core/dlg/CDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
berryzplus marked this conversation as resolved.
Show resolved Hide resolved
{
SComboBoxItemDeleter* data = (SComboBoxItemDeleter*)::GetProp( hwnd, TSTR_SUBCOMBOBOXDATA );
SComboBoxItemDeleter* data = reinterpret_cast<SComboBoxItemDeleter*>(dwRefData);
switch( uMsg ){
case WM_KEYDOWN:
{
Expand All @@ -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<SComboBoxItemDeleter*>(dwRefData);
switch( uMsg ){
case WM_KEYDOWN:
{
Expand All @@ -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 )
Expand All @@ -815,10 +799,6 @@ void CDialog::SetComboBoxDeleter( HWND hwndCtl, SComboBoxItemDeleter* data )
COMBOBOXINFO info = { sizeof(COMBOBOXINFO) };
if (!::GetComboBoxInfo(hwndCtl, &info))
return;
data->pEditWndProc = reinterpret_cast<WNDPROC>(::GetWindowLongPtr(info.hwndItem, GWLP_WNDPROC));
::SetProp(info.hwndItem, TSTR_SUBCOMBOBOXDATA, data);
::SetWindowLongPtr(info.hwndItem, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(SubEditProc));
data->pListBoxWndProc = reinterpret_cast<WNDPROC>(::GetWindowLongPtr(info.hwndList, GWLP_WNDPROC));
::SetProp(info.hwndList, TSTR_SUBCOMBOBOXDATA, data);
::SetWindowLongPtr(info.hwndList, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(SubListBoxProc));
::SetWindowSubclass(info.hwndItem, SubEditProc, 0, reinterpret_cast<DWORD_PTR>(data));
::SetWindowSubclass(info.hwndList, SubListBoxProc, 0, reinterpret_cast<DWORD_PTR>(data));
}
4 changes: 1 addition & 3 deletions sakura_core/dlg/CDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
};

/*-----------------------------------------------------------------------
Expand Down