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

検索ダイアログと置換ダイアログを横方向にリサイズ出来るように変更 #1706

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 17 additions & 0 deletions sakura_core/dlg/CDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "StdAfx.h"
#include <algorithm>
#include <memory>
#include <WinUser.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

記憶が大分怪しいのですが、WinUser.hはwindows.hの一部なので、直接インクルードしないもののような気がするのですが、どうでしょうか。
インクルード順とかの関係によっては、問題になるかもしれないので。


#include "dlg/CDialog.h"
#include "CEditApp.h"
#include "env/CShareData.h"
Expand Down Expand Up @@ -358,6 +360,11 @@ BOOL CDialog::OnSize( WPARAM wParam, LPARAM lParam )
return FALSE;
}

BOOL CDialog::OnSizing(WPARAM wParam, LPARAM lParam)
{
return FALSE;
}

BOOL CDialog::OnMove( WPARAM wParam, LPARAM lParam )
{
/* ダイアログの位置の記憶 */
Expand All @@ -376,6 +383,11 @@ BOOL CDialog::OnMove( WPARAM wParam, LPARAM lParam )
return TRUE;
}

int CDialog::OnNcHitTest(WPARAM wParam, LPARAM lParam)
{
return ::DefWindowProc(m_hWnd, WM_NCHITTEST, wParam, lParam);
}

void CDialog::CreateSizeBox( void )
{
/* サイズボックス */
Expand Down Expand Up @@ -408,6 +420,7 @@ INT_PTR CDialog::DispatchEvent( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
case WM_SIZE:
m_hWnd = hwndDlg;
return OnSize( wParam, lParam );
case WM_SIZING: return OnSizing( wParam, lParam );
case WM_MOVE:
m_hWnd = hwndDlg;
return OnMove( wParam, lParam );
Expand All @@ -420,6 +433,10 @@ INT_PTR CDialog::DispatchEvent( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
case WM_CHARTOITEM: return OnCharToItem( wParam, lParam );
case WM_HELP: return OnPopupHelp( wParam, lParam ); //@@@ 2002.01.18 add
case WM_CONTEXTMENU:return OnContextMenu( wParam, lParam ); //@@@ 2002.01.18 add
case WM_NCHITTEST:
m_hWnd = hwndDlg;
SetWindowLongPtr(m_hWnd, DWLP_MSGRESULT, OnNcHitTest(wParam, lParam));
return TRUE;
}
return FALSE;
}
Expand Down
4 changes: 3 additions & 1 deletion sakura_core/dlg/CDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ class CDialog{
virtual BOOL OnDestroy( void );
virtual BOOL OnNotify(NMHDR* pNMHDR){return FALSE;}
BOOL OnSize();
virtual BOOL OnSize( WPARAM wParam, LPARAM lParam );
virtual BOOL OnSize(WPARAM wParam, LPARAM lParam);
virtual BOOL OnSizing( WPARAM wParam, LPARAM lParam );
virtual BOOL OnMove( WPARAM wParam, LPARAM lParam );
virtual int OnNcHitTest(WPARAM wParam, LPARAM lParam);
virtual BOOL OnDrawItem( WPARAM wParam, LPARAM lParam ){return TRUE;}
virtual BOOL OnTimer( WPARAM wParam ){return TRUE;}
virtual BOOL OnKeyDown( WPARAM wParam, LPARAM lParam ){return TRUE;}
Expand Down
93 changes: 93 additions & 0 deletions sakura_core/dlg/CDlgFind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ const DWORD p_helpids[] = { //11800
0, 0
}; //@@@ 2002.01.07 add end MIK

static const SAnchorList anchorList[] = {
IDC_BUTTON_SEARCHPREV, ANCHOR_RIGHT,
IDC_BUTTON_SEARCHNEXT, ANCHOR_RIGHT,
IDC_BUTTON_SETMARK, ANCHOR_RIGHT,
IDCANCEL, ANCHOR_RIGHT,
IDC_BUTTON_HELP, ANCHOR_RIGHT,
IDC_COMBO_TEXT, ANCHOR_LEFT_RIGHT,
};

CDlgFind::CDlgFind()
{
m_sSearchOption.Reset();
Expand Down Expand Up @@ -101,6 +110,21 @@ BOOL CDlgFind::OnInitDialog( HWND hwnd, WPARAM wParam, LPARAM lParam )
HFONT hFontOld = (HFONT)::SendMessageAny( GetItemHwnd( IDC_COMBO_TEXT ), WM_GETFONT, 0, 0 );
HFONT hFont = SetMainFont( GetItemHwnd( IDC_COMBO_TEXT ) );
m_cFontText.SetFont( hFontOld, hFont, GetItemHwnd( IDC_COMBO_TEXT ) );

RECT rc;
::GetClientRect(hwnd, &rc);
m_ptDefaultSizeClient.x = rc.right;
m_ptDefaultSizeClient.y = rc.bottom;

::GetWindowRect(hwnd, &rc);
m_ptDefaultSizeScreen.x = rc.right - rc.left;
m_ptDefaultSizeScreen.y = rc.bottom - rc.top;

m_rcItems.resize(_countof(anchorList));
for (int i = 0; i < _countof(anchorList); i++) {
GetItemClientRect(anchorList[i].id, m_rcItems[i]);
}

return bRet;
}

Expand Down Expand Up @@ -397,6 +421,75 @@ BOOL CDlgFind::OnActivate( WPARAM wParam, LPARAM lParam )
return CDialog::OnActivate(wParam, lParam);
}

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

POINT ptNew;
ptNew.x = LOWORD(lParam);
ptNew.y = HIWORD(lParam);

for (int i = 0; i < _countof(anchorList); i++) {
ResizeItem(GetItemHwnd(anchorList[i].id), m_ptDefaultSizeClient, ptNew, m_rcItems[i], anchorList[i].anchor);
}
return TRUE;
}

BOOL CDlgFind::OnSizing(WPARAM wParam, LPARAM lParam)
{
RECT& rc = *(RECT*)lParam;

switch (wParam) {
case WMSZ_BOTTOMRIGHT:
case WMSZ_RIGHT:
case WMSZ_TOPRIGHT:
if (rc.right - rc.left < m_ptDefaultSizeScreen.x) {
rc.right = rc.left + m_ptDefaultSizeScreen.x;
}
break;
case WMSZ_BOTTOMLEFT:
case WMSZ_LEFT:
case WMSZ_TOPLEFT:
if (rc.right - rc.left < m_ptDefaultSizeScreen.x) {
rc.left = rc.right - m_ptDefaultSizeScreen.x;
}
break;
}

switch (wParam) {
case WMSZ_BOTTOM:
case WMSZ_BOTTOMLEFT:
case WMSZ_BOTTOMRIGHT:
rc.bottom = rc.top + m_ptDefaultSizeScreen.y;
break;
case WMSZ_TOP:
case WMSZ_TOPLEFT:
case WMSZ_TOPRIGHT:
rc.top = rc.bottom - m_ptDefaultSizeScreen.y;
break;
}

return TRUE;
}

int CDlgFind::OnNcHitTest(WPARAM wParam, LPARAM lParam)
{
int ret = CDialog::OnNcHitTest(wParam, lParam);
switch (ret) {
case HTTOPLEFT:
case HTBOTTOMLEFT:
return HTLEFT;
case HTTOPRIGHT:
case HTBOTTOMRIGHT:
return HTRIGHT;
case HTBOTTOM:
case HTTOP:
return HTBORDER;
default:
return ret;
}
}

//@@@ 2002.01.18 add start
LPVOID CDlgFind::GetHelpIdTable(void)
{
Expand Down
7 changes: 7 additions & 0 deletions sakura_core/dlg/CDlgFind.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,15 @@ class CDlgFind final : public CDialog
BOOL OnDestroy() override;
BOOL OnBnClicked(int wID) override;
BOOL OnActivate( WPARAM wParam, LPARAM lParam ) override; // 2009.11.29 ryoji
BOOL OnSize( WPARAM wParam, LPARAM lParam ) override;
BOOL OnSizing(WPARAM wParam, LPARAM lParam) override;
int OnNcHitTest(WPARAM wParam, LPARAM lParam) override;

// BOOL OnKeyDown( WPARAM wParam, LPARAM lParam ) override;
LPVOID GetHelpIdTable(void) override; //@@@ 2002.01.18 add

POINT m_ptDefaultSizeScreen;
POINT m_ptDefaultSizeClient;
std::vector<RECT> m_rcItems;
};
#endif /* SAKURA_CDLGFIND_AF260AA4_6075_4B87_9F03_2CEEDAD64094_H_ */
97 changes: 97 additions & 0 deletions sakura_core/dlg/CDlgGrep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,20 @@ const DWORD p_helpids[] = { //12000
0, 0
}; //@@@ 2002.01.07 add end MIK

static const SAnchorList anchorList[] = {
IDC_COMBO_TEXT, ANCHOR_LEFT_RIGHT,
IDC_COMBO_FOLDER, ANCHOR_LEFT_RIGHT,
IDC_BUTTON_FOLDER, ANCHOR_RIGHT,
IDC_BUTTON_FOLDER_UP, ANCHOR_RIGHT,
IDC_BUTTON_CURRENTFOLDER, ANCHOR_RIGHT,
IDC_COMBO_FILE, ANCHOR_LEFT_RIGHT,
IDC_COMBO_EXCLUDE_FILE, ANCHOR_LEFT_RIGHT,
IDC_COMBO_EXCLUDE_FOLDER, ANCHOR_LEFT_RIGHT,
IDOK, ANCHOR_RIGHT,
IDCANCEL, ANCHOR_RIGHT,
IDC_BUTTON_HELP, ANCHOR_RIGHT,
};

static void SetGrepFolder( HWND hwndCtrl, LPCWSTR folder );

CDlgGrep::CDlgGrep()
Expand Down Expand Up @@ -359,6 +373,20 @@ BOOL CDlgGrep::OnInitDialog( HWND hwndDlg, WPARAM wParam, LPARAM lParam )
m_cFontDeleters[i].SetFont( hFontOld, hFont, hwndItem );
}

RECT rc;
::GetClientRect(hwndDlg, &rc);
m_ptDefaultSizeClient.x = rc.right;
m_ptDefaultSizeClient.y = rc.bottom;

::GetWindowRect(hwndDlg, &rc);
m_ptDefaultSizeScreen.x = rc.right - rc.left;
m_ptDefaultSizeScreen.y = rc.bottom - rc.top;

m_rcItems.resize(_countof(anchorList));
for (int i = 0; i < _countof(anchorList); i++) {
GetItemClientRect(anchorList[i].id, m_rcItems[i]);
}

return bRet;
}

Expand Down Expand Up @@ -581,6 +609,75 @@ BOOL CDlgGrep::OnBnClicked( int wID )
return CDialog::OnBnClicked( wID );
}

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

POINT ptNew;
ptNew.x = LOWORD(lParam);
ptNew.y = HIWORD(lParam);

for (int i = 0; i < _countof(anchorList); i++) {
ResizeItem(GetItemHwnd(anchorList[i].id), m_ptDefaultSizeClient, ptNew, m_rcItems[i], anchorList[i].anchor);
}
return TRUE;
}

BOOL CDlgGrep::OnSizing(WPARAM wParam, LPARAM lParam)
{
RECT& rc = *(RECT*)lParam;

switch (wParam) {
case WMSZ_BOTTOMRIGHT:
case WMSZ_RIGHT:
case WMSZ_TOPRIGHT:
if (rc.right - rc.left < m_ptDefaultSizeScreen.x) {
rc.right = rc.left + m_ptDefaultSizeScreen.x;
}
break;
case WMSZ_BOTTOMLEFT:
case WMSZ_LEFT:
case WMSZ_TOPLEFT:
if (rc.right - rc.left < m_ptDefaultSizeScreen.x) {
rc.left = rc.right - m_ptDefaultSizeScreen.x;
}
break;
}

switch (wParam) {
case WMSZ_BOTTOM:
case WMSZ_BOTTOMLEFT:
case WMSZ_BOTTOMRIGHT:
rc.bottom = rc.top + m_ptDefaultSizeScreen.y;
break;
case WMSZ_TOP:
case WMSZ_TOPLEFT:
case WMSZ_TOPRIGHT:
rc.top = rc.bottom - m_ptDefaultSizeScreen.y;
break;
}

return TRUE;
}

int CDlgGrep::OnNcHitTest(WPARAM wParam, LPARAM lParam)
{
int ret = CDialog::OnNcHitTest(wParam, lParam);
switch (ret) {
case HTTOPLEFT:
case HTBOTTOMLEFT:
return HTLEFT;
case HTTOPRIGHT:
case HTBOTTOMRIGHT:
return HTRIGHT;
case HTBOTTOM:
case HTTOP:
return HTBORDER;
default:
return ret;
}
}

/* ダイアログデータの設定 */
void CDlgGrep::SetData( void )
{
Expand Down
7 changes: 7 additions & 0 deletions sakura_core/dlg/CDlgGrep.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,19 @@ class CDlgGrep : public CDialog

std::vector<CFontAutoDeleter> m_cFontDeleters;

POINT m_ptDefaultSizeScreen;
POINT m_ptDefaultSizeClient;
std::vector<RECT> m_rcItems;

/*
|| 実装ヘルパ関数
*/
BOOL OnInitDialog(HWND hwndDlg, WPARAM wParam, LPARAM lParam) override;
BOOL OnDestroy() override;
BOOL OnBnClicked(int wID) override;
BOOL OnSize(WPARAM wParam, LPARAM lParam) override;
BOOL OnSizing(WPARAM wParam, LPARAM lParam) override;
int OnNcHitTest(WPARAM wParam, LPARAM lParam) override;
LPVOID GetHelpIdTable(void) override; //@@@ 2002.01.18 add

void SetData( void ) override; /* ダイアログデータの設定 */
Expand Down
Loading