Skip to content

Commit

Permalink
ダイアログの表示位置が表示するたびにずれていく問題を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
beru committed Jul 24, 2021
1 parent 1071c6a commit a68e959
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 89 deletions.
51 changes: 16 additions & 35 deletions sakura_core/dlg/CDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,25 +235,25 @@ void CDialog::SetDialogPosSize()
rc.right = m_xPos + m_nWidth;
rc.bottom = m_yPos + m_nHeight;
GetMonitorWorkRect(&rc, &rcWork);
rcWork.top += 1;
rcWork.bottom -= 1;
rcWork.left += 1;
rcWork.right -= 1;
if( rc.bottom > rcWork.bottom ){
rc.top -= (rc.bottom - rcWork.bottom);
rc.bottom = rcWork.bottom;
LONG workHeight = rcWork.bottom - rcWork.top;
LONG workWidth = rcWork.right - rcWork.left;
if( rc.bottom > workHeight ){
LONG diff = rc.bottom - workHeight;
rc.top -= diff;
rc.bottom -= diff;
}
if( rc.right > rcWork.right ){
rc.left -= (rc.right - rcWork.right);
rc.right = rcWork.right;
if( rc.right > workWidth ){
LONG diff = rc.right - workWidth;
rc.left -= diff;
rc.right -= diff;
}
if( rc.top < rcWork.top ){
rc.bottom += (rcWork.top - rc.top);
rc.top = rcWork.top;
if( rc.top < 0 ){
rc.bottom += rc.top;
rc.top = 0;
}
if( rc.left < rcWork.left ){
rc.right += (rcWork.left - rc.left);
rc.left = rcWork.left;
if( rc.left < 0 ){
rc.right += rc.left;
rc.left = 0;
}
m_xPos = rc.left;
m_yPos = rc.top;
Expand Down Expand Up @@ -318,12 +318,6 @@ BOOL CDialog::OnSize( WPARAM wParam, LPARAM lParam )
RECT rc;
::GetWindowRect( m_hWnd, &rc );

/* ダイアログのサイズの記憶 */
m_xPos = rc.left;
m_yPos = rc.top;
m_nWidth = rc.right - rc.left;
m_nHeight = rc.bottom - rc.top;

/* サイズボックスの移動 */
if( NULL != m_hwndSizeBox ){
::GetClientRect( m_hWnd, &rc );
Expand Down Expand Up @@ -360,19 +354,6 @@ BOOL CDialog::OnSize( WPARAM wParam, LPARAM lParam )

BOOL CDialog::OnMove( WPARAM wParam, LPARAM lParam )
{
/* ダイアログの位置の記憶 */
if( !m_bInited ){
return TRUE;
}
RECT rc;
::GetWindowRect( m_hWnd, &rc );

/* ダイアログのサイズの記憶 */
m_xPos = rc.left;
m_yPos = rc.top;
m_nWidth = rc.right - rc.left;
m_nHeight = rc.bottom - rc.top;
DEBUG_TRACE( L"CDialog::OnMove() m_xPos=%d m_yPos=%d\n", m_xPos, m_yPos );
return TRUE;
}

Expand Down
8 changes: 4 additions & 4 deletions sakura_core/dlg/CDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,16 @@ class CDialog{
BOOL m_bModal; /* モーダル ダイアログか */
bool m_bSizable; // 可変ダイアログかどうか
int m_nShowCmd; // 最大化/最小化
int m_nWidth;
int m_nHeight;
int m_xPos;
int m_yPos;
// void* m_pcEditView;
DLLSHAREDATA* m_pShareData;
BOOL m_bInited;
HINSTANCE m_hLangRsrcInstance; // メッセージリソースDLLのインスタンスハンドル // 2011.04.10 nasukoji

protected:
int m_nWidth;
int m_nHeight;
int m_xPos;
int m_yPos;
void CreateSizeBox( void );
BOOL OnCommand(WPARAM wParam, LPARAM lParam);

Expand Down
20 changes: 11 additions & 9 deletions sakura_core/dlg/CDlgCompare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,22 @@ BOOL CDlgCompare::OnInitDialog( HWND hwndDlg, WPARAM wParam, LPARAM lParam )
return CDialog::OnInitDialog( hwndDlg, wParam, lParam );
}

BOOL CDlgCompare::OnDestroy( void )
{
CDialog::OnDestroy();
RECT& rect = GetDllShareData().m_Common.m_sOthers.m_rcCompareDialog;
rect.left = m_xPos;
rect.top = m_yPos;
rect.right = rect.left + m_nWidth;
rect.bottom = rect.top + m_nHeight;
return TRUE;
}

BOOL CDlgCompare::OnSize( WPARAM wParam, LPARAM lParam )
{
/* 基底クラスメンバ */
CDialog::OnSize( wParam, lParam );

::GetWindowRect( GetHwnd(), &GetDllShareData().m_Common.m_sOthers.m_rcCompareDialog );

RECT rc;
POINT ptNew;
::GetWindowRect( GetHwnd(), &rc );
Expand All @@ -285,13 +294,6 @@ BOOL CDlgCompare::OnSize( WPARAM wParam, LPARAM lParam )
return TRUE;
}

BOOL CDlgCompare::OnMove( WPARAM wParam, LPARAM lParam )
{
::GetWindowRect( GetHwnd(), &GetDllShareData().m_Common.m_sOthers.m_rcCompareDialog );

return CDialog::OnMove( wParam, lParam );
}

BOOL CDlgCompare::OnMinMaxInfo( LPARAM lParam )
{
LPMINMAXINFO lpmmi = (LPMINMAXINFO) lParam;
Expand Down
2 changes: 1 addition & 1 deletion sakura_core/dlg/CDlgCompare.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class CDlgCompare final : public CDialog

INT_PTR DispatchEvent( HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam ) override; // 標準以外のメッセージを捕捉する
BOOL OnInitDialog(HWND hwndDlg, WPARAM wParam, LPARAM lParam) override;
BOOL OnDestroy() override;
BOOL OnSize( WPARAM wParam, LPARAM lParam ) override;
BOOL OnMove( WPARAM wParam, LPARAM lParam ) override;
BOOL OnMinMaxInfo( LPARAM lParam );

void SetData( void ) override; /* ダイアログデータの設定 */
Expand Down
20 changes: 11 additions & 9 deletions sakura_core/dlg/CDlgDiff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,13 +517,22 @@ BOOL CDlgDiff::OnInitDialog( HWND hwndDlg, WPARAM wParam, LPARAM lParam )
return CDialog::OnInitDialog( hwndDlg, wParam, lParam );
}

BOOL CDlgDiff::OnDestroy()
{
CDialog::OnDestroy();
RECT& rect = GetDllShareData().m_Common.m_sOthers.m_rcDiffDialog;
rect.left = m_xPos;
rect.top = m_yPos;
rect.right = rect.left + m_nWidth;
rect.bottom = rect.top + m_nHeight;
return TRUE;
}

BOOL CDlgDiff::OnSize( WPARAM wParam, LPARAM lParam )
{
/* 基底クラスメンバ */
CDialog::OnSize( wParam, lParam );

::GetWindowRect( GetHwnd(), &GetDllShareData().m_Common.m_sOthers.m_rcDiffDialog );

RECT rc;
POINT ptNew;
::GetWindowRect( GetHwnd(), &rc );
Expand All @@ -537,13 +546,6 @@ BOOL CDlgDiff::OnSize( WPARAM wParam, LPARAM lParam )
return TRUE;
}

BOOL CDlgDiff::OnMove( WPARAM wParam, LPARAM lParam )
{
::GetWindowRect( GetHwnd(), &GetDllShareData().m_Common.m_sOthers.m_rcDiffDialog );

return CDialog::OnMove( wParam, lParam );
}

BOOL CDlgDiff::OnMinMaxInfo( LPARAM lParam )
{
LPMINMAXINFO lpmmi = (LPMINMAXINFO) lParam;
Expand Down
2 changes: 1 addition & 1 deletion sakura_core/dlg/CDlgDiff.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ class CDlgDiff final : public CDialog
LPVOID GetHelpIdTable(void) override;
INT_PTR DispatchEvent( HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam ) override; // 標準以外のメッセージを捕捉する
BOOL OnInitDialog(HWND hwndDlg, WPARAM wParam, LPARAM lParam) override;
BOOL OnDestroy() override;
BOOL OnSize( WPARAM wParam, LPARAM lParam ) override;
BOOL OnMove( WPARAM wParam, LPARAM lParam ) override;
BOOL OnMinMaxInfo( LPARAM lParam );

void SetData( void ) override; /* ダイアログデータの設定 */
Expand Down
20 changes: 11 additions & 9 deletions sakura_core/dlg/CDlgFavorite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,17 @@ BOOL CDlgFavorite::OnInitDialog( HWND hwndDlg, WPARAM wParam, LPARAM lParam )
return CDialog::OnInitDialog( GetHwnd(), wParam, lParam );
}

BOOL CDlgFavorite::OnDestroy( void )
{
CDialog::OnDestroy();
RECT& rect = GetDllShareData().m_Common.m_sOthers.m_rcFavoriteDialog;
rect.left = m_xPos;
rect.top = m_yPos;
rect.right = rect.left + m_nWidth;
rect.bottom = rect.top + m_nHeight;
return TRUE;
}

BOOL CDlgFavorite::OnBnClicked( int wID )
{
switch( wID )
Expand Down Expand Up @@ -1189,8 +1200,6 @@ BOOL CDlgFavorite::OnSize( WPARAM wParam, LPARAM lParam )
/* 基底クラスメンバ */
CDialog::OnSize( wParam, lParam );

::GetWindowRect( GetHwnd(), &GetDllShareData().m_Common.m_sOthers.m_rcFavoriteDialog );

RECT rc;
POINT ptNew;
::GetWindowRect( GetHwnd(), &rc );
Expand All @@ -1209,13 +1218,6 @@ BOOL CDlgFavorite::OnSize( WPARAM wParam, LPARAM lParam )
return TRUE;
}

BOOL CDlgFavorite::OnMove( WPARAM wParam, LPARAM lParam )
{
::GetWindowRect( GetHwnd(), &GetDllShareData().m_Common.m_sOthers.m_rcFavoriteDialog );

return CDialog::OnMove( wParam, lParam );
}

BOOL CDlgFavorite::OnMinMaxInfo( LPARAM lParam )
{
LPMINMAXINFO lpmmi = (LPMINMAXINFO) lParam;
Expand Down
2 changes: 1 addition & 1 deletion sakura_core/dlg/CDlgFavorite.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ class CDlgFavorite final : public CDialog
|| 実装ヘルパ関数
*/
BOOL OnInitDialog(HWND hwndDlg, WPARAM wParam, LPARAM lParam) override;
BOOL OnDestroy( void ) override;
BOOL OnBnClicked(int wID) override;
BOOL OnNotify(NMHDR* pNMHDR) override;
BOOL OnActivate( WPARAM wParam, LPARAM lParam ) override;
LPVOID GetHelpIdTable( void ) override;
INT_PTR DispatchEvent( HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam ) override; // 標準以外のメッセージを捕捉する
BOOL OnSize( WPARAM wParam, LPARAM lParam ) override;
BOOL OnMove( WPARAM wParam, LPARAM lParam ) override;
BOOL OnMinMaxInfo( LPARAM lParam );

void SetData( void ) override; /* ダイアログデータの設定 */
Expand Down
20 changes: 11 additions & 9 deletions sakura_core/dlg/CDlgTagJumpList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,17 @@ BOOL CDlgTagJumpList::OnInitDialog( HWND hwndDlg, WPARAM wParam, LPARAM lParam )
return bRet;
}

BOOL CDlgTagJumpList::OnDestroy( void )
{
CDialog::OnDestroy();
RECT& rect = GetDllShareData().m_Common.m_sOthers.m_rcTagJumpDialog;
rect.left = m_xPos;
rect.top = m_yPos;
rect.right = rect.left + m_nWidth;
rect.bottom = rect.top + m_nHeight;
return TRUE;
}

BOOL CDlgTagJumpList::OnBnClicked( int wID )
{
switch( wID )
Expand Down Expand Up @@ -601,8 +612,6 @@ BOOL CDlgTagJumpList::OnSize( WPARAM wParam, LPARAM lParam )
/* 基底クラスメンバ */
CDialog::OnSize( wParam, lParam );

::GetWindowRect( GetHwnd(), &GetDllShareData().m_Common.m_sOthers.m_rcTagJumpDialog );

RECT rc;
POINT ptNew;
::GetWindowRect( GetHwnd(), &rc );
Expand All @@ -616,13 +625,6 @@ BOOL CDlgTagJumpList::OnSize( WPARAM wParam, LPARAM lParam )
return TRUE;
}

BOOL CDlgTagJumpList::OnMove( WPARAM wParam, LPARAM lParam )
{
::GetWindowRect( GetHwnd(), &GetDllShareData().m_Common.m_sOthers.m_rcTagJumpDialog );

return CDialog::OnMove( wParam, lParam );
}

BOOL CDlgTagJumpList::OnMinMaxInfo( LPARAM lParam )
{
LPMINMAXINFO lpmmi = (LPMINMAXINFO) lParam;
Expand Down
2 changes: 1 addition & 1 deletion sakura_core/dlg/CDlgTagJumpList.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ class CDlgTagJumpList final : public CDialog
|| 実装ヘルパ関数
*/
BOOL OnInitDialog(HWND hwndDlg, WPARAM wParam, LPARAM lParam) override;
BOOL OnDestroy( void ) override;
BOOL OnBnClicked(int wID) override;
INT_PTR DispatchEvent( HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam ) override;
BOOL OnSize( WPARAM wParam, LPARAM lParam ) override;
BOOL OnMove( WPARAM wParam, LPARAM lParam ) override;
BOOL OnMinMaxInfo( LPARAM lParam );
BOOL OnNotify(NMHDR* pNMHDR) override;
// @@ 2005.03.31 MIK キーワード入力エリアのイベント処理
Expand Down
20 changes: 11 additions & 9 deletions sakura_core/dlg/CDlgWindowList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,21 @@ BOOL CDlgWindowList::OnInitDialog(HWND hwndDlg, WPARAM wParam, LPARAM lParam)
return CDialog::OnInitDialog(hwndDlg, wParam, lParam);
}

BOOL CDlgWindowList::OnDestroy( void )
{
CDialog::OnDestroy();
RECT& rect = GetDllShareData().m_Common.m_sOthers.m_rcWindowListDialog;
rect.left = m_xPos;
rect.top = m_yPos;
rect.right = rect.left + m_nWidth;
rect.bottom = rect.top + m_nHeight;
return TRUE;
}

BOOL CDlgWindowList::OnSize(WPARAM wParam, LPARAM lParam)
{
CDialog::OnSize(wParam, lParam);

::GetWindowRect(GetHwnd(), &GetDllShareData().m_Common.m_sOthers.m_rcWindowListDialog);

RECT rc;
POINT ptNew;
::GetWindowRect(GetHwnd(), &rc);
Expand All @@ -255,13 +264,6 @@ BOOL CDlgWindowList::OnSize(WPARAM wParam, LPARAM lParam)
return TRUE;
}

BOOL CDlgWindowList::OnMove(WPARAM wParam, LPARAM lParam)
{
::GetWindowRect(GetHwnd(), &GetDllShareData().m_Common.m_sOthers.m_rcWindowListDialog);

return CDialog::OnMove(wParam, lParam);
}

BOOL CDlgWindowList::OnMinMaxInfo(LPARAM lParam)
{
LPMINMAXINFO lpmmi = (LPMINMAXINFO) lParam;
Expand Down
2 changes: 1 addition & 1 deletion sakura_core/dlg/CDlgWindowList.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class CDlgWindowList final : public CDialog
LPVOID GetHelpIdTable() override;
INT_PTR DispatchEvent(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) override;
BOOL OnInitDialog(HWND hwndDlg, WPARAM wParam, LPARAM lParam) override;
BOOL OnDestroy( void ) override;
BOOL OnSize(WPARAM wParam, LPARAM lParam) override;
BOOL OnMove(WPARAM wParam, LPARAM lParam) override;
BOOL OnMinMaxInfo(LPARAM lParam);
BOOL OnActivate(WPARAM wParam, LPARAM lParam) override;

Expand Down

0 comments on commit a68e959

Please sign in to comment.