class LboxCombobox : public LboxWintool


  コンストラクタ




コンボボックスと言っても、アプリケーションで使用するのは殆どの場合ドロップダウンリストスタイルです。本オブジェクトではそれを使用しています。

また、通常コンボボックスは表示部分であるテキストの他に内部データを必要とします。その為、リストボックスを内部に作成してペアで使用するようにしています。

一つ目のコンストラクタは既存のコンボボックスを使用するタイプで、これが通常となります。ダイアログ上で貼り付けて GetDlgItem 関数でハンドルを取得してコンストラククタに渡します。

ドロップダウンリストの初期の大きさは、ChangeWindowSize(ウインドウツール) メソッドで設定します。

  

// *********************************************************
// 拡張コンストラクタ
// *********************************************************
LboxCombobox::LboxCombobox( HWND hTarget )
{
	this->hWnd = hTarget;
	List = new LboxListbox( GetParent( hTarget ), 0 );
	LboxCombobox::bCreate = false;
}
LboxCombobox::LboxCombobox( HWND hOwner, int nID )
{
	this->hWnd = CreateWindow(
		"combobox",
		NULL,
		WS_CHILD | CBS_DROPDOWNLIST,
		0,0,0,0,
		hOwner,
		(HMENU)nID,
		LboxGetInstance( hOwner ),
		NULL
	);

	List = new LboxListbox( hOwner, 0 );
	LboxCombobox::bCreate = true;
}

// *********************************************************
// デフォルトコンストラクタ
// *********************************************************
LboxCombobox::LboxCombobox()
{
	LboxCombobox::bCreate = false;
	List = NULL;
}

// *********************************************************
// デストラクタ
// *********************************************************
LboxCombobox::~LboxCombobox()
{
	delete this->List;
	if ( LboxCombobox::bCreate ) {
		if ( this->hWnd != NULL ) {
			DestroyWindow( this->hWnd );
			this->hWnd = NULL;
		}
	}
}
  







  Add

  

// *********************************************************
// コンボボックスにコードと文字列を追加
// 戻り値 : 追加された位置
// *********************************************************
int LboxCombobox::Add( LboxString *LScode, LboxString *LString )
{
	return LboxCombobox::Add(
		LScode->szLboxString,
		LString->szLboxString
	);
}
int LboxCombobox::Add( LPTSTR pszCode, LPTSTR pszBuffer )
{
	List->Add( pszCode );
	return LboxComboAdd(
		LboxCombobox::hWnd,
		pszBuffer
	);
}
  

  Insert

  

// *********************************************************
// コンボボックスに文字列を挿入
// 戻り値 : 挿入された位置
// *********************************************************
int LboxCombobox::Insert( int nIdx, LboxString *LScode, LboxString *LString )
{
	return LboxCombobox::Insert(
		nIdx,
		LScode->szLboxString,
		LString->szLboxString
	);
}
int LboxCombobox::Insert( int nIdx, LPTSTR pszCode, LPTSTR pszBuffer )
{
	List->Insert( nIdx, pszCode );
	return LboxComboInsert(
		LboxCombobox::hWnd,
		nIdx,
		pszBuffer
	);
}
  

  Delete

  

// *********************************************************
// コンボボックスの指定行を削除
// 戻り値 : リスト内に残っている文字列の総数
// 戻り値 : 存在しない行を指定すると -1
// *********************************************************
int LboxCombobox::Delete( int nIdx )
{
	List->Delete( nIdx );
	return LboxComboDelete(
		LboxCombobox::hWnd,
		nIdx
	);
}
  

  Reset

  

// *********************************************************
// コンボボックスのリセット
// 戻り値 : 無し
// *********************************************************
void LboxCombobox::Reset( void )
{
	List->Reset();
	LboxComboReset( LboxCombobox::hWnd );
}
  

  SetWidth,SetHeight

  

// *********************************************************
// コンボボックスのリストボックス部分の幅の設定
// 戻り値 : 無し
// *********************************************************
void LboxCombobox::SetWidth( int nWidth )
{
	LboxComboSetWidth(
		LboxCombobox::hWnd,
		nWidth
	);

}
  

  

// *********************************************************
// コンボボックスの選択部分の高さの設定
// 戻り値 : 無し
// *********************************************************
void LboxCombobox::SetHeight( int nHeight )
{
	LboxComboSetHeight(
		LboxCombobox::hWnd,
		nHeight
	);
}
  

  Count

  

// *********************************************************
// コンボボックスの行数取得
// 戻り値 : 行数
// *********************************************************
int LboxCombobox::Count( void )
{
	return LboxComboCount(
		LboxCombobox::hWnd
	);
}
  

  Select

  

// *********************************************************
// コンボボックスの指定行を選択
// 戻り値 : 無し
// *********************************************************
void LboxCombobox::Select( int nIndex )
{
	LboxComboSelect(
		LboxCombobox::hWnd,
		nIndex
	);
}
  

  FindString

  

// *********************************************************
// コンボボックス内の文字列の検索
// 戻り値 : 一致する行のインデックス(失敗時は-1)
// *********************************************************
int LboxCombobox::FindString( LboxString *LString )
{
	return LboxCombobox::FindString( LString->szLboxString );
}
int LboxCombobox::FindString( LPTSTR lpFind )
{
	return LboxComboFindString(
		LboxCombobox::hWnd,
		lpFind
	);
}
  

  FindData

  

// *********************************************************
// コンボボックス内の内部文字列の検索
// 戻り値 : 一致する行のインデックス(失敗時は-1)
// *********************************************************
int LboxCombobox::FindData( LboxString *LString )
{
	return LboxCombobox::FindData( LString->szLboxString );
}
int LboxCombobox::FindData( LPTSTR lpFind )
{
	return List->FindString(
		lpFind
	);
}
  

  SelectedRow

  

// *********************************************************
// コンボボックスの選択された行の取得
// 戻り値 : 選択された行(選択されていない場合は -1 )
// *********************************************************
int LboxCombobox::SelectedRow( void )
{
	return LboxComboSelectedRow(
		LboxCombobox::hWnd
	);
}
  

  GetText

  

// *********************************************************
// コンボボックスから文字列を取得
// 戻り値 : 取得した文字列の長さ
// 戻り値 : エラーの場合は -1
// *********************************************************
int LboxCombobox::GetText( int nIndex, LboxString *LString )
{
	int ret;

	ret = (int)SendMessage(
		LboxCombobox::hWnd,
		CB_GETLBTEXTLEN,
		(WPARAM)nIndex,
		0L
	);
	if ( ret == CB_ERR ) {
		return -1;
	}
	if ( (DWORD)(ret + 1) > LString->nLboxString ) {
		LString->Resize( ret + 1 );
	}

	ret = (int)SendMessage(
		hWnd,
		CB_GETLBTEXT,
		(WPARAM)nIndex,
		(LPARAM)(LPCTSTR)LString->szLboxString
	);
	if ( ret == CB_ERR ) {
		return -1;
	}

	return ret;
}
  

  GetData

  

// *********************************************************
// コンボボックスから内部文字列を取得
// 戻り値 : 取得した文字列の長さ
// 戻り値 : エラーの場合は -1
// *********************************************************
int LboxCombobox::GetData( int nIndex, LboxString *LString )
{
	return List->GetText(
		nIndex,
		LString
	);
}
  

  SetText

  

// *********************************************************
// コンボボックスの指定行を更新
// 戻り値 : 挿入された位置
// 戻り値 : 失敗すると -1
// *********************************************************
int LboxCombobox::SetText( int nIndex, LboxString *LString )
{
	return LboxCombobox::SetText(
		nIndex,
		LString->szLboxString 
	);
}
int LboxCombobox::SetText( int nIndex, LPTSTR lpString )
{
	return LboxComboSetText(
		LboxCombobox::hWnd,
		nIndex,
		lpString 
	);
}
  

  SelectedGetText

  

// *********************************************************
// 選択した行の文字列を取得
// 戻り値 : 取得した文字列の長さ
// 戻り値 : エラーの場合は -1
// *********************************************************
int LboxCombobox::SelectedGetText( LboxString *LString )
{
	int ret,nIndex;

	nIndex = LboxCombobox::SelectedRow();
	if ( nIndex == -1 ) {
		return -1;
	}

	ret = LboxCombobox::GetText( nIndex, LString );
	if ( ret == -1 ) {
		return -1;
	}

	return ret;
}
  

  SelectedSetText

  

// *********************************************************
// 選択した行に文字列を設定
// 戻り値 : 挿入された位置
// 戻り値 : エラーの場合は -1
// *********************************************************
int LboxCombobox::SelectedSetText( LboxString *LString )
{
	return LboxCombobox::SelectedSetText( LString->szLboxString );
}
int LboxCombobox::SelectedSetText( LPCTSTR pszBuffer )
{
	return LboxComboSelectedSetText(
		LboxCombobox::hWnd,
		pszBuffer
	);
}
  

  SelectedDelete

  

// *********************************************************
// 選択した行を削除
// 戻り値 : リスト内に残っている文字列の総数
// 戻り値 : エラーの場合は -1
// *********************************************************
int LboxCombobox::SelectedDelete( HWND hWnd )
{
	int nIdx;
	nIdx = LboxCombobox::SelectedRow();
	List->Delete( nIdx );
	return LboxComboSelectedDelete( LboxCombobox::hWnd );
}
  

  SelectedGetData

  

// *********************************************************
// 選択した行の内部文字列を取得
// 戻り値 : 取得した文字列の長さ
// 戻り値 : エラーの場合は -1
// *********************************************************
int LboxCombobox::SelectedGetData( LboxString *LString )
{
	int ret,nIndex;

	nIndex = LboxCombobox::SelectedRow();
	if ( nIndex == -1 ) {
		return -1;
	}

	ret = LboxCombobox::GetData( nIndex, LString );
	if ( ret == -1 ) {
		return -1;
	}

	return ret;
}
  




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


[cmstd]
Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
24/04/19 21:14:48
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