|
このクラスはトップレベルウインドウを想定しています
|
// *********************************************************
//
// *********************************************************
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch( message ) {
case WM_CREATE:
Win = new LboxWin( hWnd );
Win->StatusCreate( ID_STATUS );
Win->ScreenFit( );
break;
case WM_SIZE:
Win->StatusFit( wParam, lParam );
break;
case WM_DESTROY:
delete Win;
PostQuitMessage( 0 );
break;
default:
return DefWindowProc( hWnd, message, wParam, lParam );
}
return 0;
}
| |
|
|
|
|
// *********************************************************
// デフォルトコンストラクタ
// *********************************************************
LboxWin::LboxWin()
{
LboxWin::hWnd = NULL;
LboxWin::hStatus = NULL;
LboxWintool::hWndtool = NULL;
}
// *********************************************************
// 拡張コンストラクタ
// *********************************************************
LboxWin::LboxWin( HWND hWindow )
{
LboxWin::hWnd = hWindow;
LboxWin::hStatus = NULL;
LboxWintool::hWndtool = hWindow;
}
// *********************************************************
// デストラクタ
// *********************************************************
LboxWin::~LboxWin()
{
if ( LboxWin::hStatus != NULL ) {
DestroyWindow(
LboxWin::hStatus
);
}
}
| |
|
|
|
|
// *********************************************************
// スクリーンサイズにフィットさせる
// 戻り値 : 無し
// *********************************************************
void LboxWin::ScreenFit( void )
{
HWND hDesktop;
RECT rt;
hDesktop = GetDesktopWindow( );
GetWindowRect( hDesktop, &rt );
LboxWin::MoveWindow( 0, 0 );
LboxWin::ChangeWindowSize( rt.right, rt.bottom - 32 );
}
| |
|
|
|
|
// *********************************************************
// ステータスバーの実装
// 戻り値 : 無し
// *********************************************************
void LboxWin::StatusCreate( int nID )
{
if ( LboxWin::hStatus != NULL ) {
DestroyWindow(
LboxWin::hStatus
);
}
LboxWin::hStatus =
CreateWindowEx(
0,
STATUSCLASSNAME,
(LPCTSTR)NULL,
WS_CHILD | WS_VISIBLE,
0, 0, 0, 0,
LboxWin::hWnd,
(HMENU)(nID),
LboxGetInstance(GetParent(LboxWin::hWnd)),
NULL
);
SendMessage(
LboxWin::hStatus,
SB_SIMPLE,
(WPARAM)true,
0L
);
}
| |
|
|
|
|
// *********************************************************
// ステータスバーに文字列を表示
// 戻り値 : 無し
// *********************************************************
void LboxWin::StatusSetText( LPTSTR szText )
{
if ( LboxWin::hStatus != NULL ) {
SendMessage(
LboxWin::hStatus,
SB_SETTEXT,
(WPARAM)255,
(LPARAM)szText
);
}
}
| |
|
|
|
|
// *********************************************************
// ステータスバーを親ウインドウにフィットさせる
// 戻り値 : 無し
// *********************************************************
void LboxWin::StatusFit( WPARAM wParam, LPARAM lParam )
{
if ( LboxWin::hStatus != NULL ) {
SendMessage( LboxWin::hStatus, WM_SIZE, wParam, lParam );
}
}
| |
|
|
|
|
// *********************************************************
// 指定したウインドウの高さを取得する
// 戻り値 : 高さ
// *********************************************************
int LboxWin::GetHeight( HWND hTarget )
{
RECT rt;
GetWindowRect( hTarget, &rt );
return ( rt.bottom - rt.top );
}
| |
|
|
|
|
// *********************************************************
// 指定したウインドウの幅を取得する
// 戻り値 : 幅
// *********************************************************
int LboxWin::GetWidth( HWND hTarget )
{
RECT rt;
GetWindowRect( hTarget, &rt );
return ( rt.right - rt.left );
}
| |
|
|
|
|
// *********************************************************
// ウインドウをデスクトップ中央に移動
// 戻り値 : 無し
// *********************************************************
void LboxWin::CenterWindow( void )
{
LboxCenterWindow( LboxWin::hWnd );
}
| |
|
LboxCenterWindow |
|
|
// *********************************************************
// ウインドウの最小化
// 戻り値 : 無し
// *********************************************************
void LboxWin::Minimize( void )
{
CloseWindow(
LboxWin::hWnd
);
}
| |
|
|
|
|
// *********************************************************
// ウインドウの最大化
// 戻り値 : 無し
// *********************************************************
void LboxWin::Maximize( void )
{
ShowWindow(
LboxWin::hWnd,
SW_MAXIMIZE
);
}
| |
|
|
|
|
// *********************************************************
// ウインドウの復帰
// 戻り値 : 無し
// *********************************************************
void LboxWin::Restore( void )
{
ShowWindow(
LboxWin::hWnd,
SW_RESTORE
);
}
| |
|
|
|
|
// *********************************************************
// WM_CLOSE メッセージのポスト
// 戻り値 : 処理の結果
// *********************************************************
LRESULT LboxWin::Close( void )
{
return PostMessage(
LboxWin::hWnd,
WM_CLOSE,
0L,
0L
);
}
| |
|
|
|
|
// *********************************************************
// 最大化されているかどうか
// 戻り値 : true 最大化, false 最大化されていない
// *********************************************************
BOOL LboxWin::IsMaximize( void )
{
BOOL bRet;
bRet = IsZoomed( LboxWin::hWnd );
if ( bRet == 0 ) {
return false;
}
else {
return true;
}
}
| |
|
|
|
|
// *********************************************************
// 最小化されているかどうか
// 戻り値 : true 最小化, false 最小化されていない
// *********************************************************
BOOL LboxWin::IsMinimize( void )
{
BOOL bRet;
bRet = IsIconic( LboxWin::hWnd );
if ( bRet == 0 ) {
return false;
}
else {
return true;
}
}
| |
|
|
|
|
// *********************************************************
// タイトル文字列の取得
// 戻り値 : 無し
// *********************************************************
void LboxWin::GetTitle( LPTSTR lpString, int nSize )
{
GetWindowText( LboxWin::hWnd, lpString, nSize );
}
// *********************************************************
// タイトル文字列の設定
// 戻り値 : 無し
// *********************************************************
void LboxWin::SetTitle( LPTSTR lpString )
{
SetWindowText( LboxWin::hWnd, lpString );
}
| |
|
|
|
|
// *********************************************************
// ステータスバーより文字列を取得
// 戻り値 : 無し
// *********************************************************
void LboxWin::StatusGetText( LPTSTR szText )
{
if ( LboxWin::hStatus != NULL ) {
SendMessage(
LboxWin::hStatus,
SB_GETTEXT,
(WPARAM)0,
(LPARAM)szText
);
}
}
| |
|
|
|
|
// *********************************************************
// ステータスバーにフォーマットした文字列を表示
// 戻り値 : 無し
// *********************************************************
void LboxWin::StatusPrintf( LPSTR FormatString, ...)
{
if ( LboxWin::hStatus == NULL ) {
return;
}
va_list marker;
char *szBuffer = new char[1024];
va_start(marker, FormatString);
wvsprintf(szBuffer, FormatString, marker);
va_end(marker);
SendMessage(
LboxWin::hStatus,
SB_SETTEXT,
(WPARAM)255,
(LPARAM)szBuffer
);
delete [] szBuffer;
}
| |
|
|
|
|
// *********************************************************
// アイコンハンドルの書き換え
// 戻り値 : 無し
// *********************************************************
void LboxWin::ChangeIcon( int nID )
{
SetClassLong(
LboxWin::hWnd,
GCL_HICON,
(LONG)(LoadIcon(
LboxGetInstance( LboxWin::hWnd ),
MAKEINTRESOURCE( nID )
))
);
}
| |
|
|
|