|
// *********************************************************
// テキストファイルの処理
// *********************************************************
void MyClass::LoadTextArea()
{
LboxTextFile Txt;
// 「ファイルを開く」ダイアログ用
LboxString LString;
LboxCommdlg Commdlg( this->hWnd );
Commdlg.lpstrTitle = "ファイルを開く";
Commdlg.lpstrFilter = "テキスト,*.txt,全て,*.*";
// コモンダイアログ呼び出し
if ( !Commdlg.OpenFileName( &LString ) ) {
MsgOk( "キャンセルされました " );
return;
}
// テキストファイルかどうかのチェック
LboxFileSystem Fs;
if ( !Fs.IsText( &LString ) ) {
MsgOk( "テキストファイルではありません " );
return;
}
// ファイルのオープン
if ( !Txt.ReadOpen( &LString ) ) {
MsgOk(
"%s をオープンできません ",
LString.szLboxString
);
return;
}
// 読み込みバッファ
LboxString LBuffer;
// 読み込み
Txt.GetAll( &LBuffer );
// データ内には \n しか含まれていないのでテキストエリア用に変換
LBuffer.Replace( "\n", "\r\n" );
LEdit->SetText( &LBuffer );
// ファイルのクローズ
Txt.Close();
}
| |