class MyDlg : public CLDlg { public: MyDlg(); virtual ~MyDlg(); };
#include "stdafx.h" #include "resource.h" #include "MyClass.h" #include "MyDlg.h" MyClass App; MyDlg Dlg; DEFINE_DLG(Dlg) WINMAIN(App) App.MenuId = IDC_APP01; App.IconId = IDI_APP01; App.IconIdSmall = IDI_SMALL; INIT_DLG(Dlg) END_WINMAIN
// MyClass.cpp: MyClass クラスのインプリメンテーション // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "resource.h" #include "MyClass.h" #include "MyDlg.h" USE_OBJECT(MyDlg,Dlg) ////////////////////////////////////////////////////////////////////// // 構築/消滅 ////////////////////////////////////////////////////////////////////// // ********************************************************* // コンストラクタ // ********************************************************* MyClass::MyClass() { } // ********************************************************* // デストラクタ // ********************************************************* MyClass::~MyClass() { } // ********************************************************* // オペレータイベント // ********************************************************* void MyClass::ProcOperator() { switch( ControlId ) { case IDM_FILEOPEN: Dlg.Open( this, IDD_DIALOG1 ); break; } } // ********************************************************* // メインウインドウ作成イベント // ********************************************************* void MyClass::WMCreate() { // ツールバーにボタンを一つ追加 LTbar->AddStandardButton( 1, STD_FILEOPEN, IDM_FILEOPEN ); // リストビューにポップアップメニューを実装 LView->CreatePopup( IDC_APP01, 1 ); }
// MyDlg.cpp: MyDlg クラスのインプリメンテーション // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "resource.h" #include "MyDlg.h" ////////////////////////////////////////////////////////////////////// // 構築/消滅 ////////////////////////////////////////////////////////////////////// // ********************************************************* // コンストラクタ // ********************************************************* MyDlg::MyDlg() { } // ********************************************************* // デストラクタ // ********************************************************* MyDlg::~MyDlg() { } // ********************************************************* // オペレータイベント // ********************************************************* void MyDlg::ProcOperator() { switch( ControlId ) { case IDOK: MsgOk( "OK ボタンがクリックされました " ); break; } } // ********************************************************* // ダイアログ初期化イベント // ********************************************************* void MyDlg::WMInitdialog() { // ダイアログを親ウインドウの中央へ this->CenterWindow(); } // ********************************************************* // ダイアログ終了処理 // ********************************************************* void MyDlg::ProcEnd() { }
// ********************************************************* // ダイアログ初期化イベント // ********************************************************* void MyDlg::WMInitdialog() { // ダイアログを親ウインドウの中央へ this->CenterWindow(); // 背景色設定 this->SetBackgroundColor( 58,109,165 ); // テキスト色設定 this->SetTextColor( 255, 255, 255 ); // ステータスバー実装 this->StatusCreate( 0 ); // ESC キーで終了させない this->bEscCancel = true; // 初期フォーカスを変更したい場合 this->ReturnValue = false; this->EditFocus( IDC_EDIT2 ); }
// ********************************************************* // オペレータイベント // ********************************************************* void MyDlg::ProcOperator() { switch( ControlId ) { case IDOK: this->MsgOk( "OK ボタンがクリックされました " ); this->PostCommand( IDCANCEL ); break; } }
class MyDlg : public CLDlg { public: void WMAll(); void ProcEnd(); void ProcOperator(); void WMInitdialog(); MyDlg(); virtual ~MyDlg(); LboxListview *LView; };
// ********************************************************* // ダイアログ初期化イベント // ********************************************************* void MyDlg::WMInitdialog() { LView = new LboxListview( ::GetDlgItem( hDlg, IDC_LIST1 ), 0 ); LView->Grid(); LView->AddColumn( "名前" ); LView->AddColumn( LVCFMT_RIGHT, 100, "サイズ" ); LView->AddColumn( "更新日時" ); LView->AddColumn( LVCFMT_CENTER, 100, "作成日時" ); }
// ********************************************************* // ダイアログ終了処理 // ********************************************************* void MyDlg::ProcEnd() { delete this->LView; }
// ********************************************************* // 初期化とオペレータイベント以外の処理 // ********************************************************* void MyDlg::WMAll() { USE_LVIEW(LView) } // ********************************************************* // クリックイベント // ********************************************************* void MyDlg::LVClick() { LboxString LWork; if ( LView->IsHandle( this->hTargetWindow ) ) { LView->GetColumnText( this->LVCol, &LWork ); this->StatusSetText( &LWork ); } } // ********************************************************* // ダブルクリックイベント // ********************************************************* void MyDlg::LVDblclick() { LboxString LWork; if ( LView->IsHandle( this->hTargetWindow ) ) { LView->GetColumnText( this->LVCol, &LWork ); this->MsgOk( &LWork ); } } // ********************************************************* // ヘッダークリックイベント // ********************************************************* void MyDlg::LVHeadclick() { LboxString LWork; if ( LView->IsHandle( this->hTargetWindow ) ) { LView->GetColumnTitle( this->LVCol, &LWork ); this->MsgOk( &LWork ); } }