class LboxWintool


  コンストラクタ




継承用の基本クラスです。単独でも使用できます

  

// *********************************************************
// デフォルトコンストラクタ
// *********************************************************
LboxWintool::LboxWintool()
{
	LboxWintool::hSolidBrush = 
		(HBRUSH)GetStockObject( WHITE_BRUSH );
}

// *********************************************************
// 単独使用用コンストラクタ
// *********************************************************
LboxWintool::LboxWintool( HWND hTarget )
{
	LboxWintool::hWndtool = hTarget;
	LboxWintool::hSolidBrush = 
		(HBRUSH)GetStockObject( WHITE_BRUSH );
}

// *********************************************************
// デストラクタ
// *********************************************************
LboxWintool::~LboxWintool()
{
	if ( LboxWintool::hSolidBrush != NULL ) {
		DeleteObject( LboxWintool::hSolidBrush );
	}
}
  

  MoveWindow

  

// *********************************************************
// ウインドウ位置の変更
// 戻り値 : 成功 true, 失敗 false
// *********************************************************
BOOL LboxWintool::MoveWindow( int x, int y )
{
	return LboxMoveWindow(
		LboxWintool::hWndtool,
		x, y
	);
}
  

LboxMoveWindow

  ChangeWindowSize

  

// *********************************************************
// ウインドウサイズの変更
// 戻り値 : 成功 true, 失敗 false
// *********************************************************
BOOL LboxWintool::ChangeWindowSize( int w, int h )
{
	return LboxChangeWindowSize(
		LboxWintool::hWndtool,
		w, h
	);
}
  

LboxChangeWindowSize

  MoveWindowTop

  

// *********************************************************
// ウインドウを最前面に移動
// 戻り値 : 成功 true, 失敗 false
// *********************************************************
BOOL LboxWintool::MoveWindowTop( void )
{
	return LboxMoveWindowTop( LboxWintool::hWndtool );
}
  


LboxMoveWindowTop

  Height

  

// *********************************************************
// 指定したウインドウの高さを取得する
// 戻り値 : 高さ
// *********************************************************
int LboxWintool::Height( )
{
	RECT rt;
	GetWindowRect( LboxWintool::hWndtool, &rt );
	return ( rt.bottom - rt.top );
}
  

  Width

  

// *********************************************************
// 指定したウインドウの幅を取得する
// 戻り値 : 幅
// *********************************************************
int LboxWintool::Width( )
{
	RECT rt;
	GetWindowRect( LboxWintool::hWndtool, &rt );
	return ( rt.right - rt.left );
}
  

  Enable, Disable

  

// *********************************************************
// ウインドウを使用可能にする
// 戻り値 : 無し
// *********************************************************
void LboxWintool::Enable( void )
{
	EnableWindow( 
		LboxWintool::hWndtool,
		true
	);
}
  

  

// *********************************************************
// ウインドウを使用不可能にする
// 戻り値 : 無し
// *********************************************************
void LboxWintool::Disable( void )
{
	EnableWindow( 
		LboxWintool::hWndtool,
		false
	);
}
  

  Show, Hide

  

// *********************************************************
// ウインドウを表示状態にする
// 戻り値 : 無し
// *********************************************************
void LboxWintool::Show(int nID )
{
	ShowWindow(
		LboxWintool::hWndtool,
		SW_SHOW
	);
}
  

  

// *********************************************************
// ウインドウを非表示状態にする
// 戻り値 : 無し
// *********************************************************
void LboxWintool::Hide(int nID )
{
	ShowWindow(
		LboxWintool::hWndtool,
		SW_HIDE
	);
}
  

  MsgBox

  

// *********************************************************
// メッセージボックス
// 戻り値 : 押されたボタンのID
// *********************************************************
int LboxWintool::MsgBox(
HWND hWndOwner, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType )
{
	return LboxMsgBox( hWndOwner, lpText, lpCaption, uType );
}
int LboxWintool::MsgBox(
LPCTSTR lpText, LPCTSTR lpCaption, UINT uType )
{
	return LboxMsgBox(
		LboxWintool::hWndtool,
		lpText,
		lpCaption,
		uType
	);
}
  

  MsgOk

  

// *********************************************************
// 確認メッセージボックス
// 戻り値 : 無し
// *********************************************************
void LboxWintool::MsgOk( HWND hWndOwner, LPCTSTR lpText )
{
	LboxMsgOk( hWndOwner, lpText );
}
void LboxWintool::MsgOk( LboxString *LString )
{
	LboxMsgOk( LboxWintool::hWnd, LString->szLboxString );
}
void LboxWintool::MsgOk( LPCTSTR lpText )
{
	LboxMsgOk( LboxWintool::hWnd, lpText );
}
void LboxWintool::MsgOk( LPSTR FormatString, ...)
{

	va_list marker;
	char *szBuffer = new char[1024];

	va_start(marker, FormatString);
	wvsprintf(szBuffer, FormatString, marker);
	va_end(marker);              

	LboxMsgOk( LboxWintool::hWnd, szBuffer );

	delete [] szBuffer;
}
  

  

// *********************************************************
// 確認メッセージボックス( グローバル関数 )
// 戻り値 : 無し
// *********************************************************
void LboxMsgOk( HWND hWnd, LPCTSTR lpText )
{
	MessageBox( hWnd, lpText, "確認", MB_OK | MB_ICONEXCLAMATION );
}
  

  MsgOkCancel

  

// *********************************************************
// 確認メッセージボックス1
// 戻り値 : OK は true, Cancel は false
// *********************************************************
BOOL LboxWintool::MsgOkCancel( HWND hWndOwner, LPCTSTR lpText )
{
	return LboxMsgOkCancel( hWndOwner, lpText );
}
BOOL LboxWintool::MsgOkCancel( LPCTSTR lpText )
{
	return LboxMsgOkCancel( LboxWintool::hWndtool, lpText );
}
  

  MsgYesNo

  

// *********************************************************
// 確認メッセージボックス2
// 戻り値 : YES は true, NO は false
// *********************************************************
BOOL LboxWintool::MsgYesNo( HWND hWndOwner, LPCTSTR lpText )
{
	return LboxMsgYesNo( hWndOwner, lpText );
}
BOOL LboxWintool::MsgYesNo( LPCTSTR lpText )
{
	return LboxMsgYesNo( LboxWintool::hWndtool, lpText );
}
  

  Destroy

  

// *********************************************************
// ウインドウの破棄
// 戻り値 : 成功 0以外, 失敗 0
// *********************************************************
BOOL LboxWintool::Destroy( void )
{
	return DestroyWindow( LboxWintool::hWndtool );
}
  

  SendMsg

  

// *********************************************************
// メッセージの送信
// 戻り値 : 処理の結果
// *********************************************************
LRESULT LboxWintool::SendMsg(
UINT Msg, WPARAM wParam, LPARAM lParam )
{
	return SendMessage(
		LboxWintool::hWndtool,
		Msg,
		wParam,
		lParam
	);
}
  

  PostMsg

  

// *********************************************************
// メッセージのポスト
// 戻り値 : 処理の結果
// *********************************************************
LRESULT LboxWintool::PostMsg( UINT Msg )
{
	return PostMessage(
		LboxWintool::hWnd,
		Msg,
		0L,
		0L
	);
}
LRESULT LboxWintool::PostMsg( UINT Msg, WPARAM wParam )
{
	return PostMessage(
		LboxWintool::hWnd,
		Msg,
		wParam,
		0L
	);
}
LRESULT LboxWintool::PostMsg(
UINT Msg, WPARAM wParam, LPARAM lParam )
{
	return PostMessage(
		LboxWintool::hWnd,
		Msg,
		wParam,
		lParam
	);
}
  

  Instance

  

// *********************************************************
// インスタンスハンドルの取得
// 戻り値 : インスタンスハンドル
// *********************************************************
HINSTANCE LboxWintool::Instance( void )
{
	return LboxGetInstance(
		LboxWintool::hWndtool
	);
}
  

  Parent

  

// *********************************************************
// 親ウインドウハンドルの取得
// 戻り値 : 親ウインドウハンドル(親がなければ NULL)
// *********************************************************
HWND LboxWintool::Parent( void )
{
	return GetParent(
		LboxWintool::hWndtool
	);
}
  

  TopWindow

  

// *********************************************************
// トップレベルウインドウハンドルの取得
// 戻り値 : トップレベルウインドウハンドル
// *********************************************************
HWND LboxWintool::TopWindow( void )
{
	HWND hParent,hWork;
	int nCnt;

	hWork = LboxWintool::hWndtool;

	nCnt = 0;
	while( 1 ) {
		hParent = GetParent( hWork );
		if ( hParent == NULL ) {
			return hWork;
		}
		hWork = hParent;
		nCnt++;
		if ( nCnt > 50 ) {
			return NULL;
		}
	}
}
  

  ClientHeight

  

// *********************************************************
// クライアント領域の高さを取得する
// 戻り値 : クライアント領域の高さ
// *********************************************************
int LboxWintool::ClientHeight( )
{
	RECT rt;
	GetClientRect( LboxWintool::hWndtool, &rt );
	return ( rt.bottom - rt.top );
}
  

  ClientWidth

  

// *********************************************************
// クライアント領域の幅を取得する
// 戻り値 : クライアント領域の幅
// *********************************************************
int LboxWintool::ClientWidth( )
{
	RECT rt;
	GetClientRect( LboxWintool::hWndtool, &rt );
	return ( rt.right - rt.left );
  

  IsVisible

  

// *********************************************************
// 表示状態かどうか
// 戻り値 : true 表示, false 非表示
// *********************************************************
BOOL LboxWintool::IsVisible( void )
{
	return IsWindowVisible( LboxWintool::hWndtool );
}
  

  ClientToScreen

  

// *********************************************************
// クライアント座標からスクリーン座標へ変換
// 戻り値 : true 成功, false 失敗
// *********************************************************
BOOL LboxWintool::ClientToScreen( LPPOINT lpPoint )
{
	return ::ClientToScreen(
		LboxWintool::hWndtool,
		lpPoint
	);
}
  

  ChangeStyle, ChangeExStyle

  

// *********************************************************
// ウインドウスタイルの変更
// 戻り値 : 無し
// *********************************************************
void LboxWintool::ChangeStyle( DWORD dwOn, DWORD dwOff )
{
	DWORD dwWork;

	dwWork = GetWindowLong(
		LboxWintool::hWndtool,
		GWL_STYLE
	);
	dwWork = dwWork | dwOn;
	dwWork = dwWork & ( dwOff ^ 0xffffffff );
	SetWindowLong(
		LboxWintool::hWndtool,
		GWL_STYLE,
		dwWork
	);
}

// *********************************************************
// 拡張ウインドウスタイルの変更
// 戻り値 : 無し
// *********************************************************
void LboxWintool::ChangeExStyle( DWORD dwOn, DWORD dwOff )
{
	DWORD dwWork;

	dwWork = GetWindowLong(
		LboxWintool::hWndtool,
		GWL_EXSTYLE
	);
	dwWork = dwWork | dwOn;
	dwWork = dwWork & ( dwOff ^ 0xffffffff );
	SetWindowLong(
		LboxWintool::hWndtool,
		GWL_EXSTYLE,
		dwWork
	);
}
  

  CreateSolidBrush

  

// *********************************************************
// 指定された色の論理ブラシを作成
// 戻り値 : 無し
// *********************************************************
void LboxWintool::CreateSolidBrush( int red, int green, int blue )
{
	if ( LboxWintool::hSolidBrush != NULL ) {
		DeleteObject( LboxWintool::hSolidBrush );
	}
	LboxWintool::hSolidBrush = 
		::CreateSolidBrush( RGB( red, green, blue ) );
}
  

以下使用例

  

// *********************************************************
//   関数: TestDialogListbox
// *********************************************************
LRESULT CALLBACK TestDialogListbox(
HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
	switch( message ) {
		case WM_INITDIALOG:
			// ダイアログ登録
			Dlg = new LboxDlg( hDlg );
			Dlg->CenterWindow( );
			Dlg->CreateSolidBrush( 0, 128, 0 );
			return TRUE;

		case WM_CTLCOLORDLG:
			return (LRESULT)Dlg->hSolidBrush;
  

  DragAccept

  

// *********************************************************
// ドラッグドロップの実装と解除
// 戻り値 : 無し
// *********************************************************
void LboxWintool::DragAccept( BOOL bFlg )
{
	DragAcceptFiles( LboxWintool::hWndtool, bFlg );
}
  

  DragQuery

  

// *********************************************************
// ドラッグドロップしたファイル一覧をリストボックスにセット
// 戻り値 : ドロップしたファイル数
// *********************************************************
int LboxWintool::DragQuery( HWND hListDrop, WPARAM wParam )
{
	if ( hListDrop == NULL ) {
		return 0;
	}

	char *szBuffer = new char[MAX_PATH];

	int nFileCnt;
	nFileCnt = (int)DragQueryFile(
		(HDROP)wParam,
		0xffffffff ,
		szBuffer,
		MAX_PATH
	);

	LboxListReset( hListDrop );

	int i;

	for( i = 0; i < nFileCnt; i++ ) {
		DragQueryFile( (HDROP)wParam, i , szBuffer, MAX_PATH );
		LboxListAdd( hListDrop, szBuffer );
	}

	delete [] szBuffer;

	DragFinish( (HDROP)wParam );

	return nFileCnt;
}
  

  SavePositonAndSize

  

// *********************************************************
// ウインドウの位置とサイズを初期化ファイルに保存
// 戻り値 : 無し
// *********************************************************
void LboxWintool::SavePositonAndSize( LPTSTR lpSection, LboxInifile *obj )
{
	if ( IsIconic( LboxWintool::hWnd ) ) {
		return;
	}
	if ( IsZoomed( LboxWintool::hWnd ) ) {
		return;
	}

	RECT rt;
	char szWork[20];
	GetWindowRect( LboxWintool::hWnd, &rt );
	if( rt.left < 0 ) {
		return;
	}
	if( rt.top < 0 ) {
		return;
	}
	if( rt.right-rt.left <= 0 ) {
		return;
	}
	if( rt.bottom-rt.top <= 0 ) {
		return;
	}

	wsprintf( szWork, "%d", rt.left );
	obj->WriteString( lpSection, "Left", szWork );
	wsprintf( szWork, "%d", rt.top );
	obj->WriteString( lpSection, "Top", szWork );
	wsprintf( szWork, "%d", rt.right-rt.left );
	obj->WriteString( lpSection, "Width", szWork );
	wsprintf( szWork, "%d", rt.bottom-rt.top );
	obj->WriteString( lpSection, "Height", szWork );
}
  

  RestorePositonAndSize

  

// *********************************************************
// ウインドウの位置とサイズを初期化ファイルより復帰
// 戻り値 : 通常は true, Left エントリが無かった場合は false
// でなにもしない
// *********************************************************
BOOL LboxWintool::RestorePositonAndSize( LPTSTR lpSection, LboxInifile *obj )
{
	int x,y,w,h;
	char szWork[20],szSize[20];

	obj->GetString( lpSection, "Left", "NOTHING", szWork, 20 );
	if ( lstrcmp( szWork, "NOTHING" ) == 0 ) {
		return false;
	}
	else {
		x = StrToInt( szWork );
	}

	obj->GetString( lpSection, "Top", "0", szWork, 20 );
	y = StrToInt( szWork );

	HWND hDesktop;
	RECT rt;

	hDesktop = GetDesktopWindow( );
	GetWindowRect( hDesktop, &rt );

	wsprintf( szSize, "%d", rt.right );
	obj->GetString( lpSection, "Width", szSize, szWork, 20 );
	w = StrToInt( szWork );

	wsprintf( szSize, "%d", rt.bottom - 32 );
	obj->GetString( lpSection, "Height", szSize, szWork, 20 );
	h = StrToInt( szWork );

	LboxWintool::MoveWindow( x, y );
	LboxWintool::ChangeWindowSize( w, h );

	return true;
}
  

  IsHandle

  

// *********************************************************
// ウインドウハンドルが一致するかどうか
// 戻り値 : 一致 true, 不一致 false
// *********************************************************
BOOL LboxWintool::IsHandle( HWND hTarget )
{
	return ( (LboxWintool::hWndtool) == hTarget );
}
  

  SetFocus

  

// *********************************************************
// フォーカスセット
// 戻り値 : 無し
// *********************************************************
void LboxWintool::SetFocus( void )
{
	::SetFocus( LboxWintool::hWndtool );
}
  

  ParentFit

  

// *********************************************************
// 親ウインドウにフィットさせる
// 戻り値 : 無し
// *********************************************************
void LboxWintool::ParentFit( DWORD dwSizeType,
	int x, int y, int sub_w, int sub_h )
{
	HWND hParent;
	RECT rt;

	if ( dwSizeType == SIZE_RESTORED || SIZE_MAXIMIZED ) {
		hParent = GetParent( this->hWnd );
		if ( hParent != NULL ) {
			GetClientRect( hParent, &rt );
			LboxMoveWindow( this->hWnd, x, y );
			LboxChangeWindowSize(
				this->hWnd,
				rt.right - x - sub_w,
				rt.bottom - y - sub_h
			);
		}
	}
}
  

  SetFont

  

// *********************************************************
// フォントのセット
// 戻り値 : true 成功, false 失敗
// *********************************************************
BOOL LboxWintool::SetFont( int nType, int nSize, BOOL bBold )
{
	if ( LboxWintool::hFont != NULL ) {
		DeleteObject( LboxWintool::hFont );
	}
	LboxWintool::hFont = LboxCreateFont(
		nType,
		nSize,
		bBold
	);
	if ( LboxWintool::hFont == NULL ) {
		return false;
	}

	SendMessage(
		LboxWintool::hWnd,
		WM_SETFONT,
		(WPARAM)(LboxWintool::hFont),
		MAKELPARAM(true, 0)
	);

	return true;
}
  

  

// *********************************************************
// フォント作成
// 戻り値 : フォントハンドル
// nType
// 0 : MS Pゴシック
// 1 : MS P明朝
// 2 : MS ゴシック
// 3 : MS 明朝
// サイズ : 8 〜 18
// *********************************************************
HFONT LboxCreateFont( int nType, int nSize, BOOL bBold )
{
	HFONT hFont;

	if ( nSize < 8 || nSize > 18 ) {
		return NULL;
	}

	LboxFontbase.lfHeight = LboxFontSize[nSize];
	if ( bBold ) {
		LboxFontbase.lfWeight = 700;
	}
	else {
		LboxFontbase.lfWeight = 400;
	}

	switch( nType ) {
		case 0:
			lstrcpy( LboxFontbase.lfFaceName, "MS Pゴシック" );
			break;
		case 1:
			lstrcpy( LboxFontbase.lfFaceName, "MS P明朝" );
			break;
		case 2:
			lstrcpy( LboxFontbase.lfFaceName, "MS ゴシック" );
			break;
		case 3:
			lstrcpy( LboxFontbase.lfFaceName, "MS 明朝" );
			break;
		default:
			return NULL;
	}

	hFont = CreateFontIndirect( &LboxFontbase );

	return hFont;
}
  

  Redraw

  

// *********************************************************
// 再描画
// 戻り値 : 無し
// *********************************************************
void LboxWintool::Redraw( void )
{
	RedrawWindow(
		this->hWnd,
		NULL,
		NULL,
		RDW_INVALIDATE | RDW_ERASENOW
	);
}
  

  IsEnabled

  

// *********************************************************
// 有効状態かどうか
// 戻り値 : true 表示, false 非表示
// *********************************************************
BOOL LboxWintool::IsEnabled( void )
{
	return IsWindowEnabled( this->hWnd );
}
BOOL LboxWintool::IsEnabled( HWND hTarget )
{
	return IsWindowEnabled( hTarget );
}
  

  GetWidth, GetHeight

  

// *********************************************************
// 指定したウインドウの幅を取得する
// 戻り値 : 幅
// *********************************************************
int LboxWintool::GetWidth( HWND hTarget )
{
	RECT rt;
	GetWindowRect( hTarget, &rt );
	return ( rt.right - rt.left );
}

// *********************************************************
// 指定したウインドウの高さを取得する
// 戻り値 : 高さ
// *********************************************************
int LboxWintool::GetHeight( HWND hTarget )
{
	RECT rt;
	GetWindowRect( hTarget, &rt );
	return ( rt.bottom - rt.top );
}
  

  GetClientWidth, GetClientHeight

  

int LboxWintool::GetClientWidth( HWND hTarget )
{
	RECT rt;
	GetClientRect( hTarget, &rt );
	return ( rt.right - rt.left );
}

int LboxWintool::GetClientHeight( HWND hTarget )
{
	RECT rt;
	GetClientRect( hTarget, &rt );
	return ( rt.bottom - rt.top );
}
  

  PostCommand

  

// *********************************************************
// WM_COMMAND メッセージのポスト
// 戻り値 : 処理の結果
// *********************************************************
// ウインドウ ID のみ
LRESULT LboxWintool::PostCommand( WORD wID )
{
	return PostMessage(
		LboxWintool::hWnd,
		WM_COMMAND,
		MAKEWPARAM(wID,0),
		0L
	);
}
// ウインドウ ID と NotifyCode
LRESULT LboxWintool::PostCommand( WORD wID, WORD wNotifyCode )
{
	return PostMessage(
		LboxWintool::hWnd,
		WM_COMMAND,
		MAKEWPARAM(wID,wNotifyCode),
		0L
	);
}
// ウインドウ ID と NotifyCode と lParam
LRESULT LboxWintool::PostCommand(
	 WORD wID, WORD wNotifyCode, DWORD lParam )
{
	return PostMessage(
		LboxWintool::hWnd,
		WM_COMMAND,
		MAKEWPARAM(wID,wNotifyCode),
		(LPARAM)lParam
	);
}
  




yahoo  google  MSDN  MSDN(us)  WinFAQ  Win Howto  tohoho  ie_DHTML  vector  wdic  辞書  天気 


[cmstd]
claudebot
24/03/29 21:19:01
InfoBoard Version 1.00 : Language=Perl

1 BatchHelper COMprog CommonSpec Cprog CprogBase CprogSAMPLE CprogSTD CprogSTD2 CprogWinsock Cygwin GameScript HTML HTMLcss InstallShield InstallShieldFunc JScript JScriptSAMPLE Jsfuncs LLINK OldProg OracleGold OracleSilver PRO PRObrowser PROc PROconePOINT PROcontrol PROftpclient PROjscript PROmailer PROperl PROperlCHAT PROphp PROphpLesson PROphpLesson2 PROphpLesson3 PROphpfunction PROphpfunctionArray PROphpfunctionMisc PROphpfunctionString PROsql PROvb PROvbFunction PROvbString PROvbdbmtn PROvbonepoint PROwebapp PROwin1POINT PROwinSYSTEM PROwinYOROZU PROwindows ProjectBoard RealPHP ScriptAPP ScriptMaster VBRealtime Vsfuncs a1root access accreq adsi ajax amazon argus asp aspSample aspVarious aspdotnet aw2kinst cappvariety centura ckeyword classStyle cmaterial cmbin cmdbapp cmenum cmlang cmlistbox cmstd cmstdseed cmtxt cs daz3d db dbCommon dbaccess dnettool dos download flex2 flex3 flex4 framemtn framereq freeWorld freesoft gimp ginpro giodownload google hdml home hta htmlDom ie9svg install java javaSwing javascript jetsql jquery jsp jspTest jspVarious lightbox listasp listmsapi listmsie listmsiis listmsnt listmspatch listmsscript listmsvb listmsvc memo ms msde mysql netbeans oraPlsql oracle oracleWiper oraclehelper orafunc other panoramio pear perl personal pgdojo pgdojo_cal pgdojo_holiday pgdojo_idx pgdojo_ref pgdojo_req php phpVarious phpguide plsql postgres ps r205 realC realwebapp regex rgaki ruby rule sboard sc scprint scquest sdb sdbquest seesaa setup sh_Imagick sh_canvas sh_dotnet sh_google sh_tool sh_web shadowbox shgm shjquery shvbs shweb sjscript skadai skywalker smalltech sperl sqlq src systemdoc tcpip tegaki three toolbox twitter typeface usb useXML vb vbdb vbsfunc vbsguide vbsrc vpc wcsignup webanymind webappgen webclass webparts webtool webwsh win8 winofsql wmi work wp youtube