|
|
// *********************************************************
//コンストラクタ
// *********************************************************
LboxString::LboxString( DWORD nSize )
{
LboxString::szLboxString = (char *)GlobalAlloc(
GMEM_FIXED,
nSize+10
);
if ( LboxString::szLboxString != NULL ) {
ZeroMemory(
LboxString::szLboxString,
nSize+10
);
}
}
LboxString::~LboxString()
{
if ( LboxString::szLboxString != NULL ) {
GlobalFree(
(HGLOBAL)LboxString::szLboxString
);
}
}
| |
|
|
|
|
// *********************************************************
// 追加オペレータ ( LPTSTR 用 )
// 戻り値 : 文字列へのポインタ
// *********************************************************
LPTSTR LboxString::operator += ( LPTSTR szBuffer )
{
if ( LboxString::szLboxString == NULL ) {
return NULL;
}
lstrcat(
LboxString::szLboxString,
szBuffer
);
return LboxString::szLboxString;
}
// *********************************************************
// 追加オペレータ ( LboxString 用 )
// 戻り値 : 文字列へのポインタ
// *********************************************************
LPTSTR LboxString::operator += ( LboxString *obj )
{
if ( LboxString::szLboxString == NULL ) {
return NULL;
}
if ( obj->szLboxString == NULL ) {
return LboxString::szLboxString;
}
lstrcat(
LboxString::szLboxString,
obj->szLboxString
);
return LboxString::szLboxString;
}
// *********************************************************
// 代入オペレータ ( LPTSTR 用 )
// 戻り値 : 文字列へのポインタ
// *********************************************************
LPTSTR LboxString::operator = ( LPTSTR szBuffer )
{
if ( LboxString::szLboxString == NULL ) {
return NULL;
}
lstrcpy(
LboxString::szLboxString,
szBuffer
);
return LboxString::szLboxString;
}
// *********************************************************
// 代入オペレータ ( LboxString 用 )
// 戻り値 : 文字列へのポインタ
// *********************************************************
LPTSTR LboxString::operator = ( LboxString *obj )
{
if ( LboxString::szLboxString == NULL ) {
return NULL;
}
if ( obj->szLboxString == NULL ) {
return LboxString::szLboxString;
}
lstrcpy(
LboxString::szLboxString,
obj->szLboxString
);
return LboxString::szLboxString;
}
| |
|
|
|
|
LboxString *Lstr,*Lstr2;
// *********************************************************
// 関数: About
// *********************************************************
LRESULT CALLBACK About( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
{
switch( message )
{
case WM_INITDIALOG:
Lstr = new LboxString( 4096 );
Lstr2 = new LboxString( 80 );
Lstr2->operator = ( "XYZ" );
Lstr->operator += ("ABC");
Lstr->operator += (Lstr2);
MessageBox( hDlg,
Lstr->operator += ("DEF"),
"",
MB_OK
);
| |
|
|
|