@@ -81,9 +81,7 @@ void CMainToolBar::ProcSearchBox( MSG *msg )
8181 @author ryoji
8282 @date 2006.09.06 ryoji
8383*/
84- static WNDPROC g_pOldToolBarWndProc; // ツールバーの本来のウィンドウプロシージャ
85-
86- static LRESULT CALLBACK ToolBarWndProc ( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
84+ LRESULT CALLBACK CMainToolBar::ToolBarWndProc ( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, [[maybe_unused]] DWORD_PTR dwRefData )
8785{
8886 switch ( msg )
8987 {
@@ -95,10 +93,12 @@ static LRESULT CALLBACK ToolBarWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPAR
9593
9694 case WM_DESTROY:
9795 // サブクラス化解除
98- ::SetWindowLongPtr ( hWnd, GWLP_WNDPROC, (LONG_PTR)g_pOldToolBarWndProc );
96+ ::RemoveWindowSubclass (hWnd, &ToolBarWndProc, uIdSubclass);
97+ return 0L ;
98+ default :
9999 break ;
100100 }
101- return ::CallWindowProc ( g_pOldToolBarWndProc, hWnd, msg, wParam, lParam );
101+ return ::DefSubclassProc ( hWnd, msg, wParam, lParam );
102102}
103103
104104/* ツールバー作成
@@ -179,11 +179,7 @@ void CMainToolBar::CreateToolBar( void )
179179 }
180180 else {
181181 // 2006.09.06 ryoji ツールバーをサブクラス化する
182- g_pOldToolBarWndProc = (WNDPROC)::SetWindowLongPtr (
183- m_hwndToolBar,
184- GWLP_WNDPROC,
185- (LONG_PTR)ToolBarWndProc
186- );
182+ ::SetWindowSubclass (m_hwndToolBar, &ToolBarWndProc, 0 , 0 );
187183
188184 // pixel数をベタ書きするとHighDPI環境でずれるのでシステム値を取得して使う
189185 const int cxBorder = DpiScaleX ( 1 );
0 commit comments