📄 csplitterwnd.cpp
字号:
nPane = 1;
break;
case 1:
nPane = -1;
break;
}
}else{
switch( m_nActivePane ){
case 0:
nPane = 1;
break;
case 1:
nPane = 2;
break;
case 2:
nPane = 3;
break;
case 3:
nPane = -1;
break;
}
}
return nPane;
}
/* 最初のペインを返す */
int CSplitterWnd::GetFirstPane( void )
{
return 0;
}
/* 最後のペインを返す */
int CSplitterWnd::GetLastPane( void )
{
int nPane;
if( m_nAllSplitRows == 1 && m_nAllSplitCols == 1 ){
nPane = 0;
}else
if( m_nAllSplitRows == 1 && m_nAllSplitCols == 2 ){
nPane = 1;
}else
if( m_nAllSplitRows == 2 && m_nAllSplitCols == 1 ){
nPane = 2;
}else{
nPane = 3;
}
return nPane;
}
/* 描画処理 */
LRESULT CSplitterWnd::OnPaint( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
HDC hdc;
PAINTSTRUCT ps;
RECT rc;
RECT rcFrame;
int nFrameWidth = 3;
HBRUSH hBrush;
hdc = ::BeginPaint( hwnd, &ps );
::GetClientRect( m_hWnd, &rc );
hBrush = ::CreateSolidBrush( ::GetSysColor( COLOR_3DFACE ) );
if( m_nAllSplitRows > 1 ){
::SetRect( &rcFrame, rc.left, m_nVSplitPos, rc.right, m_nVSplitPos + nFrameWidth );
::FillRect( hdc, &rcFrame, hBrush );
}
if( m_nAllSplitCols > 1 ){
::SetRect( &rcFrame, m_nHSplitPos, rc.top, m_nHSplitPos + nFrameWidth, rc.bottom );
::FillRect( hdc, &rcFrame, hBrush );
}
::DeleteObject( hBrush );
::EndPaint(hwnd, &ps);
return 0L;
}
/* ウィンドウサイズの変更処理 */
LRESULT CSplitterWnd::OnSize( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
CEditWnd* pCEditWnd = (CEditWnd*)m_pCEditWnd;
CEditView* pcViewArr[MAXCOUNTOFVIEW];
int i;
RECT rcClient;
int nFrameWidth = 3;
BOOL bSizeBox;
for( i = 0; i < MAXCOUNTOFVIEW; ++i ){
pcViewArr[i] = ( CEditView* )::GetWindowLongPtr( m_ChildWndArr[i], 0 );
}
/*
|| ファンクションキーを下に表示している場合はサイズボックスを表示しない
|| ステータスパーを表示している場合はサイズボックスを表示しない
*/
if( NULL == pCEditWnd
||( NULL != pCEditWnd->m_CFuncKeyWnd.m_hWnd
&& 1 == m_pShareData->m_Common.m_nFUNCKEYWND_Place /* ファンクションキー表示位置/0:上 1:下 */
)
){
bSizeBox = FALSE;
}else{
bSizeBox = TRUE;
/* ステータスパーを表示している場合はサイズボックスを表示しない */
if( NULL != pCEditWnd->m_hwndStatusBar ){
bSizeBox = FALSE;
}
}
/* メインウィンドウが最大化されている場合はサイズボックスを表示しない */
WINDOWPLACEMENT wp;
wp.length = sizeof( WINDOWPLACEMENT );
::GetWindowPlacement( m_hwndParent, &wp );
if( SW_SHOWMAXIMIZED == wp.showCmd ){
bSizeBox = FALSE;
}
::GetClientRect( m_hWnd, &rcClient );
if( m_nAllSplitRows == 1 && m_nAllSplitCols == 1 ){
if( m_ChildWndArr[0] != NULL ){
::MoveWindow( m_ChildWndArr[0], 0, 0, rcClient.right, rcClient.bottom, TRUE ); /* 子ウィンドウ配列 */
pcViewArr[0]->SplitBoxOnOff( TRUE, TRUE, bSizeBox ); /* 縦?横の分割ボックスのON/OFF */
}
}else
if( m_nAllSplitRows == 2 && m_nAllSplitCols == 1 ){
if( m_ChildWndArr[0] != NULL ){
::MoveWindow( m_ChildWndArr[0], 0, 0, rcClient.right, m_nVSplitPos, TRUE ); /* 子ウィンドウ配列 */
pcViewArr[0]->SplitBoxOnOff( FALSE, FALSE, FALSE ); /* 縦?横の分割ボックスのON/OFF */
}
if( m_ChildWndArr[2] != NULL ){
::MoveWindow( m_ChildWndArr[2], 0, m_nVSplitPos + nFrameWidth, rcClient.right, rcClient.bottom - ( m_nVSplitPos + nFrameWidth ), TRUE ); /* 子ウィンドウ配列 */
pcViewArr[2]->SplitBoxOnOff( FALSE, TRUE, bSizeBox ); /* 縦?横の分割ボックスのON/OFF */
}
}else
if( m_nAllSplitRows == 1 && m_nAllSplitCols == 2 ){
if( m_ChildWndArr[0] != NULL ){
::MoveWindow( m_ChildWndArr[0], 0, 0, m_nHSplitPos, rcClient.bottom, TRUE ); /* 子ウィンドウ配列 */
pcViewArr[0]->SplitBoxOnOff( FALSE, FALSE, FALSE ); /* 縦?横の分割ボックスのON/OFF */
}
if( m_ChildWndArr[1] != NULL ){
::MoveWindow( m_ChildWndArr[1], m_nHSplitPos + nFrameWidth, 0, rcClient.right - ( m_nHSplitPos + nFrameWidth ), rcClient.bottom, TRUE ); /* 子ウィンドウ配列 */
pcViewArr[1]->SplitBoxOnOff( TRUE, FALSE, bSizeBox ); /* 縦?横の分割ボックスのON/OFF */
}
}else{
if( m_ChildWndArr[0] != NULL ){
::MoveWindow( m_ChildWndArr[0], 0, 0, m_nHSplitPos, m_nVSplitPos, TRUE ); /* 子ウィンドウ配列 */
pcViewArr[0]->SplitBoxOnOff( FALSE, FALSE, FALSE ); /* 縦?横の分割ボックスのON/OFF */
}
if( m_ChildWndArr[1] != NULL ){
::MoveWindow( m_ChildWndArr[1], m_nHSplitPos + nFrameWidth, 0, rcClient.right - ( m_nHSplitPos + nFrameWidth ), m_nVSplitPos, TRUE ); /* 子ウィンドウ配列 */
pcViewArr[1]->SplitBoxOnOff( FALSE, FALSE, FALSE ); /* 縦?横の分割ボックスのON/OFF */
}
if( m_ChildWndArr[2] != NULL ){
::MoveWindow( m_ChildWndArr[2], 0, m_nVSplitPos + nFrameWidth , m_nHSplitPos, rcClient.bottom - ( m_nVSplitPos + nFrameWidth ), TRUE ); /* 子ウィンドウ配列 */
pcViewArr[2]->SplitBoxOnOff( FALSE, FALSE, FALSE ); /* 縦?横の分割ボックスのON/OFF */
}
if( m_ChildWndArr[3] != NULL ){
::MoveWindow( m_ChildWndArr[3], m_nHSplitPos + nFrameWidth, m_nVSplitPos + nFrameWidth, rcClient.right - ( m_nHSplitPos + nFrameWidth ), rcClient.bottom - ( m_nVSplitPos + nFrameWidth ), TRUE ); /* 子ウィンドウ配列 */
pcViewArr[3]->SplitBoxOnOff( FALSE, FALSE, bSizeBox ); /* 縦?横の分割ボックスのON/OFF */
}
}
//デスクトップがちらつくのでだめ!
//::InvalidateRect( m_hWnd, NULL, TRUE ); //再描画してね。 //@@@ 2003.06.11 MIK
return 0L;
}
/* マウス移動時の処理 */
LRESULT CSplitterWnd::OnMouseMove( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
int nHit;
HCURSOR hcurOld; /* もとのマウスカーソル */
RECT rc;
int xPos;
int yPos;
xPos = (int)(short)LOWORD(lParam);
yPos = (int)(short)HIWORD(lParam);
nHit = HitTestSplitter( xPos, yPos );
switch( nHit ){
case 1:
hcurOld = ::SetCursor( ::LoadCursor( NULL, IDC_SIZENS ) );
break;
case 2:
hcurOld = ::SetCursor( ::LoadCursor( NULL, IDC_SIZEWE ) );
break;
case 3:
hcurOld = ::SetCursor( ::LoadCursor( NULL, IDC_SIZEALL ) );
break;
}
if( 0 != m_bDragging ){ /* 分割バーをドラッグ中か */
::GetClientRect( m_hWnd, &rc );
if( xPos < 1 ){
xPos = 1;
}
if( xPos > rc.right - 6 ){
xPos = rc.right - 6;
}
if( yPos < 1 ){
yPos = 1;
}
if( yPos > rc.bottom - 6 ){
yPos = rc.bottom - 6;
}
/* 分割トラッカーの表示 */
DrawSplitter( xPos, yPos, TRUE );
// MYTRACE( "xPos=%d yPos=%d \n", xPos, yPos );
}
return 0L;
}
/* マウス左ボタン押下時の処理 */
LRESULT CSplitterWnd::OnLButtonDown( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
int nHit;
int xPos;
int yPos;
xPos = (int)(short)LOWORD(lParam);
yPos = (int)(short)HIWORD(lParam);
::SetFocus( m_hwndParent );
/* 分割バーへのヒットテスト */
nHit = HitTestSplitter( xPos, yPos );
if( 0 != nHit ){
m_bDragging = nHit; /* 分割バーをドラッグ中か */
::SetCapture( m_hWnd );
}
/* 分割トラッカーの表示 */
DrawSplitter( xPos, yPos, FALSE );
return 0L;
}
/* マウス左ボタン解放時の処理 */
LRESULT CSplitterWnd::OnLButtonUp( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
int bDraggingOld;
int nX;
int nY;
if( m_bDragging ){
/* 分割トラッカーの表示 */
DrawSplitter( m_nDragPosX, m_nDragPosY, FALSE );
bDraggingOld = m_bDragging;
m_bDragging = 0;
::ReleaseCapture();
if( NULL != m_hcurOld ){
::SetCursor( m_hcurOld );
}
/* ウィンドウの分割 */
if( m_nAllSplitRows == 1 ){
nY = 0;
}else{
nY = m_nDragPosY;
}
if( m_nAllSplitCols == 1 ){
nX = 0;
}else{
nX = m_nDragPosX;
}
if( bDraggingOld == 1 ){
DoSplit( m_nHSplitPos, nY );
}else
if( bDraggingOld == 2 ){
DoSplit( nX, m_nVSplitPos );
}else
if( bDraggingOld == 3 ){
DoSplit( nX, nY );
}
}
return 0L;
}
/* マウス左ボタンダブルクリック時の処理 */
LRESULT CSplitterWnd::OnLButtonDblClk( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
int nX;
int nY;
int nHit;
int xPos;
int yPos;
xPos = (int)(short)LOWORD(lParam);
yPos = (int)(short)HIWORD(lParam);
nHit = HitTestSplitter( xPos, yPos );
if( nHit == 1 ){
if( m_nAllSplitCols == 1 ){
nX = 0;
}else{
nX = m_nHSplitPos;
}
DoSplit( nX , 0 );
}else
if( nHit == 2 ){
if( m_nAllSplitRows == 1 ){
nY = 0;
}else{
nY = m_nVSplitPos;
}
DoSplit( 0 , nY );
}else
if( nHit == 3 ){
DoSplit( 0 , 0 );
}
OnMouseMove( m_hWnd, 0, 0, MAKELONG( xPos, yPos ) );
return 0L;
}
/* アプリケーション定義のメッセージ(WM_APP <= msg <= 0xBFFF) */
LRESULT CSplitterWnd::DispatchEvent_WM_APP( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
int nPosX;
int nPosY;
switch( uMsg ){
case MYWM_DOSPLIT:
nPosX = (int)wParam;
nPosY = (int)lParam;
// MYTRACE( "MYWM_DOSPLIT nPosX=%d nPosY=%d\n", nPosX, nPosY );
/* ウィンドウの分割 */
if( 0 != m_nHSplitPos ){
nPosX = m_nHSplitPos;
}
if( 0 != m_nVSplitPos ){
nPosY = m_nVSplitPos;
}
DoSplit( nPosX , nPosY );
break;
case MYWM_SETACTIVEPANE:
SetActivePane( (int)wParam );
break;
}
return 0L;
}
/*[EOF]*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -