Skip to content

Commit f9adf72

Browse files
authored
Merge pull request #2147 from gorogoro123/feature/remove_g_pOldToolBarWndProc
static変数 g_pOldToolBarWndProc 削除
2 parents de41d3e + 2ed3f01 commit f9adf72

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

sakura_core/window/CMainToolBar.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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 );

sakura_core/window/CMainToolBar.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ class CMainToolBar{
4949
void SetFocusSearchBox( void ) const; /* ツールバー検索ボックスへフォーカスを移動 */ // 2006.06.04 yukihane
5050

5151
private:
52+
static LRESULT CALLBACK ToolBarWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData );
53+
5254
CEditWnd* m_pOwner;
5355
HWND m_hwndToolBar;
5456

0 commit comments

Comments
 (0)