|
// *********************************************************
// ドラッグドロップで読み込む
// *********************************************************
void MyClass::ProcDrop()
{
if ( !LEdit->IsHandle( this->hTargetWindow ) ) {
return;
}
LboxTextFile Txt;
LboxString LString;
// ドロップされたファイルのパスの取得
LString.Resize( MAX_PATH );
DragQueryFile(
this->hDrop,
0, // 選択された先頭ファイル
LString.szLboxString,
MAX_PATH
);
// テキストフアイルかどうかのチェック
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();
}
| |