⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cfunckeywnd.cpp

📁 日本的开源编辑器源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		}
		::MoveWindow( m_hwndButtonArr[i], nX, 1, nButtonWidth, nButtonHeight, TRUE );
		nX += nButtonWidth + 1;
	}
	::InvalidateRect( m_hWnd, NULL, TRUE );	//再描画してね。	//@@@ 2003.06.11 MIK
	return 0L;
}


#if 0//////////////////////////////////////////////////////////////
LRESULT CFuncKeyWnd::DispatchEvent(
	HWND	hwnd,	// handle of window
	UINT	uMsg,	// message identifier
	WPARAM	wParam,	// first message parameter
	LPARAM	lParam 	// second message parameter
)
{
//	if( NULL == m_hWnd ){
//		return 0L;
//	}

	int		i;
	WORD	wNotifyCode;
	WORD	wID;
	HWND	hwndCtl;
	switch ( uMsg ){

	case WM_TIMER:		return OnTimer( hwnd, uMsg, wParam, lParam );
	case WM_COMMAND:	return OnCommand( hwnd, uMsg, wParam, lParam );
	case WM_SIZE:		return OnSize( hwnd, uMsg, wParam, lParam );
	case WM_DESTROY:	return OnDestroy( hwnd, uMsg, wParam, lParam );

	default:
		return DefWindowProc( hwnd, uMsg, wParam, lParam );
	}
}
#endif//////////////////////////////////////////////////////////////



LRESULT CFuncKeyWnd::OnCommand( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
	int		i;
	WORD	wNotifyCode;
	WORD	wID;
	HWND	hwndCtl;

	wNotifyCode = HIWORD(wParam);	// notification code
	wID = LOWORD(wParam);			// item, control, or accelerator identifier
	hwndCtl = (HWND) lParam;		// handle of control
//	switch( wNotifyCode ){
//	case BN_PUSHED:
		for( i = 0; i < sizeof( m_hwndButtonArr ) / sizeof( m_hwndButtonArr[0] ); ++i ){
			if( hwndCtl == m_hwndButtonArr[i] ){
				if( 0 != m_nFuncCodeArr[i] ){
					::SendMessage( m_hwndParent, WM_COMMAND, MAKELONG( m_nFuncCodeArr[i], 0 ),  (LPARAM)hwnd );
				}
				break;
			}
		}
		::SetFocus( m_hwndParent );
//		break;
//	}
	return 0L;
}


// WM_TIMERタイマーの処理
LRESULT CFuncKeyWnd::OnTimer( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
// 	HWND hwnd,	// handle of window for timer messages
//	UINT uMsg,	// WM_TIMER message
//	UINT idEvent,	// timer identifier
//	DWORD dwTime 	// current system time


	//	return;
	if( NULL == m_hWnd ){
		return 0;
	}

	if( GetActiveWindow() != m_hwndParent ) {	//	2002/06/02 MIK
		return 0;
	}

	int			nIdx;
//	int			nFuncId;
	int			i;
	int			nFuncCode;
	int			nOffF1;

// novice 2004/10/10
	/* Shift,Ctrl,Altキーが押されていたか */
	nIdx = getCtrlKeyState();
	/* ALT,Shift,Ctrlキーの状態が変化したか */
	if( nIdx != m_nCurrentKeyState ){
		m_nTimerCount = TIMER_CHECKFUNCENABLE + 1;

		/* [F1]キーの位置を捜す */
		for( i = 0; i < m_pShareData->m_nKeyNameArrNum; ++i ){
			if( VK_F1 == m_pShareData->m_pKeyNameArr[i].m_nKeyCode ){
				break;
			}
		}
		if( i >= m_pShareData->m_nKeyNameArrNum ){
			m_nCurrentKeyState = nIdx;
			return 0;
		}
		nOffF1 = i;
		/* ファンクションキーの機能名を取得 */
		for( i = 0; i < sizeof( m_szFuncNameArr ) / sizeof( m_szFuncNameArr[0] ); ++i ){
			nFuncCode = m_pShareData->m_pKeyNameArr[nOffF1 + i].m_nFuncCodeArr[nIdx];
			if( nFuncCode != m_nFuncCodeArr[i] ){
				m_nFuncCodeArr[i] = nFuncCode;
				if( 0 == m_nFuncCodeArr[i] ){
					strcpy( m_szFuncNameArr[i], "" );
				}else{
					//	Oct. 2, 2001 genta
					m_pCEditDoc->m_cFuncLookup.Funccode2Name( m_nFuncCodeArr[i],
						m_szFuncNameArr[i], sizeof(m_szFuncNameArr[i]) - 1 );
//					::LoadString( m_hInstance, m_nFuncCodeArr[i], m_szFuncNameArr[i], sizeof(m_szFuncNameArr[i]) - 1 );
				}
				::SetWindowText( m_hwndButtonArr[i], m_szFuncNameArr[i] );
			}
		}
	}
	m_nTimerCount += TIMER_TIMEOUT;
	if( m_nTimerCount > TIMER_CHECKFUNCENABLE ||
		nIdx != m_nCurrentKeyState
	){
		m_nTimerCount = 0;
		/* 機能が利用可能か調べる */
		for( i = 0; i < sizeof(	m_szFuncNameArr ) / sizeof(	m_szFuncNameArr[0] ); ++i ){
			if( CEditWnd::IsFuncEnable( (CEditDoc*)m_pCEditDoc, m_pShareData, m_nFuncCodeArr[i]  ) ){
				::EnableWindow( m_hwndButtonArr[i], TRUE );
			}else{
				::EnableWindow( m_hwndButtonArr[i], FALSE );
			}
		}
	}
//	MYTRACE( "\n" );
	m_nCurrentKeyState = nIdx;
	return 0;
}


// WM_DSESTROY処理
LRESULT CFuncKeyWnd::OnDestroy( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	int i;

	/* タイマーを削除 */
	::KillTimer( hwnd, IDT_FUNCWND );

	/* ボタンを削除 */
	for( i = 0; i < sizeof( m_hwndButtonArr ) / sizeof( m_hwndButtonArr[0] ); ++i ){
		if( NULL != m_hwndButtonArr[i] ){
			::DestroyWindow( m_hwndButtonArr[i]	);
			m_hwndButtonArr[i] = NULL;
		}
	}

	/* サイズボックスを削除 */
	if( NULL != m_hwndSizeBox ){
		::DestroyWindow( m_hwndSizeBox );
		m_hwndSizeBox = NULL;
	}

	m_hWnd = NULL;
	return 0L;

}



/*! ボタンのサイズを計算 */
int CFuncKeyWnd::CalcButtonSize( void )
{
	int			nButtonNum;
	RECT		rc;
	int			nCxHScroll;
	int			nCyHScroll;
	int			nCxVScroll;
	int			nCyVScroll;
	::GetWindowRect( m_hWnd, &rc );

	nButtonNum = sizeof( m_hwndButtonArr ) / sizeof( m_hwndButtonArr[0] );

	if( NULL == m_hwndSizeBox ){
//		return ( rc.right - rc.left - nButtonNum - ( (nButtonNum + m_nButtonGroupNum - 1) / m_nButtonGroupNum - 1 ) * 12 ) / nButtonNum;
		nCxVScroll = 0;
	}else{
		/* サイズボックスの位置、サイズ変更 */
		nCxHScroll = ::GetSystemMetrics( SM_CXHSCROLL );
		nCyHScroll = ::GetSystemMetrics( SM_CYHSCROLL );
		nCxVScroll = ::GetSystemMetrics( SM_CXVSCROLL );
		nCyVScroll = ::GetSystemMetrics( SM_CYVSCROLL );
		::MoveWindow( m_hwndSizeBox,  rc.right - rc.left - nCxVScroll, rc.bottom - rc.top - nCyHScroll, nCxVScroll, nCyHScroll, TRUE );
//		::MoveWindow( m_hwndSizeBox,  0, 0, nCxVScroll, nCyHScroll, TRUE );

//		return ( rc.right - rc.left - nCxVScroll = - nButtonNum -  ( (nButtonNum + m_nButtonGroupNum - 1) / m_nButtonGroupNum - 1 ) * 12 ) / nButtonNum;
	}
	return ( rc.right - rc.left - nCxVScroll - nButtonNum -  ( (nButtonNum + m_nButtonGroupNum - 1) / m_nButtonGroupNum - 1 ) * 12 ) / nButtonNum;

}



/*! ボタンの生成 */
void CFuncKeyWnd::CreateButtons( void )
{
//	HWND	hwndButton;
	RECT	rcParent;
	int		nButtonHeight;
	int		nButtonWidth;
	int		i;
	int		nX;

	::GetWindowRect( m_hWnd, &rcParent );
	nButtonHeight = nButtonHeight = rcParent.bottom - rcParent.top - 2;

	/* ボタンのサイズを計算 */
	nButtonWidth = CalcButtonSize();

	for( i = 0; i < sizeof(	m_nFuncCodeArr ) / sizeof(	m_nFuncCodeArr[0] ); ++i ){
		m_nFuncCodeArr[i] = 0;
	}

	nX = 1;
	for( i = 0; i < sizeof( m_hwndButtonArr ) / sizeof( m_hwndButtonArr[0] ); ++i ){
		m_hwndButtonArr[i] = ::CreateWindow(
			"BUTTON",	// predefined class
			"",			// button text
			WS_VISIBLE | WS_CHILD | BS_LEFT
			,			// styles
			// Size and position values are given explicitly, because
			// the CW_USEDEFAULT constant gives zero values for buttons.
			nX,			// starting x position
			0 + 1,		// starting y position
			nButtonWidth,		// button width
			nButtonHeight,		// button height
			m_hWnd,		// parent window
			NULL,		// No menu
			// Modified by KEITA for WIN64 2003.9.6
			(HINSTANCE) GetWindowLongPtr(m_hWnd, GWLP_HINSTANCE),
			NULL		// pointer not needed
		);
		/* フォント変更 */
		::SendMessage( m_hwndButtonArr[i], WM_SETFONT, (WPARAM)m_hFont, MAKELPARAM(TRUE, 0) );

		nX += nButtonWidth + 1;
	}
	m_nCurrentKeyState = -1;
	return;
}




/*! サイズボックスの表示/非表示切り替え */
void CFuncKeyWnd::SizeBox_ONOFF( BOOL bSizeBox )
{

	RECT		rc;
	::GetWindowRect( m_hWnd, &rc );
	if( m_bSizeBox == bSizeBox ){
		return;
	}
	if( m_bSizeBox ){
		::DestroyWindow( m_hwndSizeBox );
		m_hwndSizeBox = NULL;
		m_bSizeBox = FALSE;
		OnSize( NULL, 0, 0, 0 );
	}else{
		m_hwndSizeBox = ::CreateWindowEx(
			0L, 						/* no extended styles			*/
			"SCROLLBAR",				/* scroll bar control class		*/
			(LPSTR) NULL,				/* text for window title bar	*/
			WS_VISIBLE | WS_CHILD | SBS_SIZEBOX | SBS_SIZEGRIP, /* scroll bar styles */
			0,							/* horizontal position			*/
			0,							/* vertical position			*/
			200,						/* width of the scroll bar		*/
			CW_USEDEFAULT,				/* default height				*/
			m_hWnd, 				/* handle of main window		*/
			(HMENU) NULL,				/* no menu for a scroll bar 	*/
			m_hInstance,				/* instance owning this window	*/
			(LPVOID) NULL			/* pointer not needed				*/
		);
		::ShowWindow( m_hwndSizeBox, SW_SHOW );
		m_bSizeBox = TRUE;
		OnSize( NULL, 0, 0, 0 );
	}
	return;
}


/*[EOF]*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -