示例#1
0
/*!
	印字可能行数と桁数を計算
	@date 2013.05.05 aroka OnTimerから移動
	@retval 印字可能領域があれば TRUE  // 2013.05.20 aroka
*/
BOOL CDlgPrintSetting::CalcPrintableLineAndColumn()
{
	int				nEnableColumns;		/* 行あたりの文字数 */
	int				nEnableLines;		/* 縦方向の行数 */
	MYDEVMODE		dmDummy;			// 2003.05.18 かろと 型変更
	short			nPaperAllWidth;		/* 用紙幅 */
	short			nPaperAllHeight;	/* 用紙高さ */
	PRINTSETTING*	pPS;

	/* ダイアログデータの取得 */
	GetData();
	pPS = &m_PrintSettingArr[m_nCurrentPrintSetting];

	dmDummy.dmFields = DM_PAPERSIZE | DMORIENT_LANDSCAPE;
	dmDummy.dmPaperSize = pPS->m_nPrintPaperSize;
	dmDummy.dmOrientation = pPS->m_nPrintPaperOrientation;
	/* 用紙の幅、高さ */
	if( !CPrint::GetPaperSize(
		&nPaperAllWidth,
		&nPaperAllHeight,
		&dmDummy
	) ){
	// 2001.12.21 hor GetPaperSize失敗時はそのまま終了
	//	nPaperAllWidth = 210 * 10;		/* 用紙幅 */
	//	nPaperAllHeight = 297 * 10;		/* 用紙高さ */
		return FALSE;
	}
	/* 行あたりの文字数(行番号込み) */
	nEnableColumns = CPrint::CalculatePrintableColumns( pPS, nPaperAllWidth, pPS->m_bPrintLineNumber?m_nLineNumberColumns:0 );	/* 印字可能桁数/ページ */
	/* 縦方向の行数 */
	nEnableLines = CPrint::CalculatePrintableLines( pPS, nPaperAllHeight );			/* 印字可能行数/ページ */

	::SetDlgItemInt( GetHwnd(), IDC_STATIC_ENABLECOLUMNS, nEnableColumns, FALSE );
	::SetDlgItemInt( GetHwnd(), IDC_STATIC_ENABLELINES, nEnableLines, FALSE );

	// フォントのポイント数	2013/5/9 Uchi
	// 1pt = 1/72in = 25.4/72mm
	int		nFontPoints = pPS->m_nPrintFontHeight * 720 / 254;
	TCHAR	szFontPoints[20];
	auto_sprintf_s( szFontPoints, _countof(szFontPoints), _T("%d.%dpt"), nFontPoints/10, nFontPoints%10 );
	::DlgItem_SetText( GetHwnd(), IDC_STATIC_FONTSIZE, szFontPoints );

	// 印字可能領域がない場合は OK を押せなくする 2013.5.10 aroka
	if( nEnableColumns == 0 || nEnableLines == 0 ){
		::EnableWindow( GetItemHwnd( IDOK ), FALSE );
		return FALSE;
	}else{
		::EnableWindow( GetItemHwnd( IDOK ), TRUE );
		return TRUE;
	}
}
/*! アクセスキー付きの文字列の作成
	@param sName ラベル
	@param sKey アクセスキー
	@return アクセスキー付きの文字列
	@data 2013.12.09 novice アクセスキーと文字列の比較で小文字も有効にする
	@date 2014.05.04 sLabelのバッファ長を300 => _MAX_PATH*2 + 30
*/
TCHAR*	CKeyBind::MakeMenuLabel(const TCHAR* sName, const TCHAR* sKey)
{
	const int MAX_LABEL_CCH = _MAX_PATH*2 + 30;
	static	TCHAR	sLabel[MAX_LABEL_CCH];
	const	TCHAR*	p;

	if (sKey == NULL || sKey[0] == L'\0') {
		return const_cast<TCHAR*>( sName );
	}
	else {
		if( !GetDllShareData().m_Common.m_sMainMenu.m_bMainMenuKeyParentheses
			  && (((p = auto_strchr( sName, sKey[0])) != NULL) || ((p = auto_strchr( sName, _totlower(sKey[0]))) != NULL)) ){
			// 欧文風、使用している文字をアクセスキーに
			auto_strcpy_s( sLabel, _countof(sLabel), sName );
			sLabel[p-sName] = _T('&');
			auto_strcpy_s( sLabel + (p-sName) + 1, _countof(sLabel), p );
		}
		else if( (p = auto_strchr( sName, _T('(') )) != NULL
			  && (p = auto_strchr( p, sKey[0] )) != NULL) {
			// (付その後にアクセスキー
			auto_strcpy_s( sLabel, _countof(sLabel), sName );
			sLabel[p-sName] = _T('&');
			auto_strcpy_s( sLabel + (p-sName) + 1, _countof(sLabel), p );
		}
		else if (_tcscmp( sName + _tcslen(sName) - 3, _T("...") ) == 0) {
			// 末尾...
			auto_strcpy_s( sLabel, _countof(sLabel), sName );
			sLabel[_tcslen(sName) - 3] = '\0';						// 末尾の...を取る
			auto_strcat_s( sLabel, _countof(sLabel), _T("(&") );
			auto_strcat_s( sLabel, _countof(sLabel), sKey );
			auto_strcat_s( sLabel, _countof(sLabel), _T(")...") );
		}
		else {
			auto_sprintf_s( sLabel, _countof(sLabel), _T("%ts(&%ts)"), sName, sKey );
		}

		return sLabel;
	}
}