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

📄 cfunckeywnd.cpp

📁 日本的开源编辑器源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//	$Id: CFuncKeyWnd.cpp,v 1.13 2004/10/11 01:23:05 genta Exp $
/*!	@file
	@brief ファンクションキーウィンドウ

	@author Norio Nakatani
	$Revision: 1.13 $
*/
/*
	Copyright (C) 1998-2001, Norio Nakatani

	This source code is designed for sakura editor.
	Please contact the copyright holder to use this code for other purpose.
*/
#include "CFuncKeyWnd.h"
#include "debug.h"
#include "CEditWnd.h"
#include "global.h"
#include "KeyCode.h"// 2002/2/10 aroka
#include "etc_uty.h" // novice 2004/10/10

#define IDT_FUNCWND 1248
#define TIMER_TIMEOUT 100
#define TIMER_CHECKFUNCENABLE 300

/****
LRESULT CALLBACK CFuncKeyWndProc(
	HWND	hwnd,	// handle of window
	UINT	uMsg,	// message identifier
	WPARAM	wParam,	// first message parameter
	LPARAM	lParam 	// second message parameter
)
{
	CFuncKeyWnd*	pCFuncKeyWnd;
	pCFuncKeyWnd = ( CFuncKeyWnd* )::GetWindowLongPtr( hwnd, GWLP_USERDATA );
	if( NULL != pCFuncKeyWnd ){
		return pCFuncKeyWnd->DispatchEvent( hwnd, uMsg, wParam, lParam );
	}
	return ::DefWindowProc( hwnd, uMsg, wParam, lParam );
}
***/






//	@date 2002.2.17 YAZAKI CShareDataのインスタンスは、CProcessにひとつあるのみ。
CFuncKeyWnd::CFuncKeyWnd()
{
	strcat( m_szClassInheritances, "::CFuncKeyWnd" );

	int		i;
	LOGFONT	lf;
//	m_hInstance = NULL;
//	m_hwndParent = NULL;
//	m_hWnd = NULL;
//	m_pszAppName = "CFuncKeyWnd";
	m_pszClassName = "CFuncKeyWnd";
	m_pCEditDoc = NULL;
	/* 共有データ構造体のアドレスを返す */
	m_pShareData = CShareData::getInstance()->GetShareData();
	m_nCurrentKeyState = -1;
	for( i = 0; i < sizeof(	m_szFuncNameArr ) / sizeof(	m_szFuncNameArr[0] ); ++i ){
		strcpy( m_szFuncNameArr[i], "" );
	}
//	2002.11.04 Moca Open()側で設定
//	m_nButtonGroupNum = 4;

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

	/* 表示用フォント */
	/* LOGFONTの初期化 */
	memset( &lf, 0, sizeof(LOGFONT) );
	lf.lfHeight			= -12;
	lf.lfWidth			= 0;
	lf.lfEscapement		= 0;
	lf.lfOrientation	= 0;
	lf.lfWeight			= 400;
	lf.lfItalic			= 0x0;
	lf.lfUnderline		= 0x0;
	lf.lfStrikeOut		= 0x0;
//	lf.lfCharSet		= 0x80;
	lf.lfCharSet		= GB2312_CHARSET;
	lf.lfOutPrecision	= 0x3;
	lf.lfClipPrecision	= 0x2;
	lf.lfQuality		= 0x1;
	lf.lfPitchAndFamily	= 0x31;
//	strcpy( lf.lfFaceName, "MS Pゴシック" );
  strcpy( lf.lfFaceName, "FixedSys" );
	m_hFont = ::CreateFontIndirect( &lf );

	m_bSizeBox = FALSE;
	m_hwndSizeBox = NULL;
	m_nTimerCount = 0;

	return;
}




CFuncKeyWnd::~CFuncKeyWnd()
{
	/* 表示用フォント */
	::DeleteObject( m_hFont );
	return;
}




/* ウィンドウ オープン */
HWND CFuncKeyWnd::Open( HINSTANCE hInstance, HWND hwndParent, CEditDoc* pCEditDoc, BOOL bSizeBox )
{
//	WNDCLASS	wc;
//	HWND		hWnd;
//	ATOM		atom;

	/* 初期化 */
	m_hInstance = hInstance;
	m_hwndParent = hwndParent;

//	m_hInstance = hInstance;
//	m_hwndParent = hwndParent;

	m_pCEditDoc = pCEditDoc;
	m_bSizeBox = bSizeBox;
	m_hwndSizeBox = NULL;
	m_nCurrentKeyState = -1;

	// 2002.11.04 Moca 変更できるように
	m_nButtonGroupNum = m_pShareData->m_Common.m_nFUNCKEYWND_GroupNum;
	if( 1 > m_nButtonGroupNum || 12 < m_nButtonGroupNum ){
		m_nButtonGroupNum = 4;
	}

/*
	wc.style			= CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_BYTEALIGNCLIENT | CS_BYTEALIGNWINDOW;
	wc.lpfnWndProc		= CFuncKeyWndProc;
	wc.cbClsExtra		= 0;
	wc.cbWndExtra		= 32;
	wc.hInstance		= m_hInstance;
	wc.hIcon			= NULL;
	wc.hCursor			= LoadCursor( NULL, IDC_ARROW );
	wc.hbrBackground	= (HBRUSH)(COLOR_3DFACE + 1);
	wc.lpszMenuName		= NULL;
	wc.lpszClassName	= m_pszAppName;
	atom = RegisterClass( &wc );
*/
	/* ウィンドウクラス作成 */
	RegisterWC(
		/* WNDCLASS用 */
		NULL,// Handle to the class icon.
		NULL,	//Handle to a small icon
		::LoadCursor( NULL, IDC_ARROW ),// Handle to the class cursor.
		(HBRUSH)(COLOR_3DFACE + 1),// Handle to the class background brush.
		NULL/*MAKEINTRESOURCE( MYDOCUMENT )*/,// Pointer to a null-terminated character string that specifies the resource name of the class menu, as the name appears in the resource file.
		m_pszClassName// Pointer to a null-terminated string or is an atom.
	);

/**
	hWnd = CreateWindow(
		m_pszAppName,		// pointer to registered class name
		m_pszAppName,		// pointer to window name
		WS_VISIBLE |
		0
		| WS_VISIBLE
		| WS_CHILD
		,	// window style

		CW_USEDEFAULT,		// horizontal position of window
		0,					// vertical position of window
		100,				// window width
		::GetSystemMetrics( SM_CYMENU ),			// window height
		m_hwndParent,		// handle to parent or owner window
		NULL,				// handle to menu or child-window identifier
		m_hInstance,		// handle to application instance
		NULL				// pointer to window-creation data
	);
	m_hWnd = hWnd;
**/

	/* 基底クラスメンバ呼び出し */
	CWnd::Create(
		/* CreateWindowEx()用 */
		0, // extended window style
		m_pszClassName,	// Pointer to a null-terminated string or is an atom.
		m_pszClassName, // pointer to window name
		WS_CHILD | WS_VISIBLE, // window style
		CW_USEDEFAULT, // horizontal position of window
		0, // vertical position of window
		100, // window width
		::GetSystemMetrics( SM_CYMENU ), // window height
		NULL // handle to menu, or child-window identifier
	);


	m_hwndSizeBox = NULL;
	if( m_bSizeBox ){
		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 );
	}

	/* ボタンの生成 */
	CreateButtons();

//	if( NULL != m_hWnd ){
//		::SetWindowLong( m_hWnd, GWL_USERDATA, (LONG)this );
//	}
	::ShowWindow( m_hWnd, SW_SHOW );
	if( NULL != m_hWnd ){
		/* タイマーを起動 */
//		if( 0 == ::SetTimer( m_hWnd, IDT_FUNCWND, TIMER_TIMEOUT, (TIMERPROC)CFuncKeyWndTimerProc ) ){
		if( 0 == ::SetTimer( m_hWnd, IDT_FUNCWND, TIMER_TIMEOUT, NULL ) ){
			::MYMESSAGEBOX(	m_hWnd,	MB_OK | MB_ICONEXCLAMATION, GSTR_APPNAME,
				"CFuncKeyWnd::Open()\nタイマーが起動できません。\nシステムリソースが不足しているのかもしれません。"
			);
		}
	}
	::InvalidateRect( m_hWnd, NULL, TRUE );

	return m_hWnd;
}




/* ウィンドウ クローズ */
void CFuncKeyWnd::Close( void )
{
	::DestroyWindow( m_hWnd );
	m_hWnd = NULL;
}





///* WM_SIZE処理 */
//void CFuncKeyWnd::OnSize(
//	WPARAM	wParam,	// first message parameter
//	LPARAM	lParam 	// second message parameter

// WM_SIZE処理
LRESULT CFuncKeyWnd::OnSize( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	int			nButtonWidth;
	int			nButtonHeight;
	int			i;
	int			nX;
//	RECT		rc;
	int			nButtonNum;
	RECT		rcParent;

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

//	/* メインウィンドウが最大化されている場合はサイズボックスを表示しない */
//	BOOL			bSizeBox;
//	WINDOWPLACEMENT	wp;
//	wp.length = sizeof( WINDOWPLACEMENT );
//	::GetWindowPlacement( m_hwndParent, &wp );
//	if( SW_SHOWMAXIMIZED == wp.showCmd ){
//		bSizeBox = FALSE;
//	}else{
//		bSizeBox = TRUE;
//	}
//	/* サイズボックスの表示/非表示切り替え */
//	SizeBox_ONOFF( bSizeBox );


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

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

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

	nX = 1;
	for( i = 0; i < nButtonNum; ++i ){
		if( 0 < i  && 0 == ( i % m_nButtonGroupNum ) ){
			nX += 12;

⌨️ 快捷键说明

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