|
|
// *********************************************************
// 読込むファイルのパスを取得する
// *********************************************************
BOOL LboxOpenFileName(
HWND hwndOwner,
LPCTSTR lpstrTitle,
LPCTSTR lpstrFilter,
DWORD nFilterIndex,
LPTSTR lpstrFile,
DWORD Flags
)
{
OPENFILENAME ofn;
char szFilter[512];
// メモリの初期化
ZeroMemory( &ofn, sizeof( ofn ) );
ZeroMemory( szFilter, sizeof( szFilter ) );
// 環境
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwndOwner;
// タイトル
if ( lpstrTitle == NULL ||
*lpstrTitle == 0x00 ) {
ofn.lpstrTitle = "ファイルのパスの取得";
}
else {
ofn.lpstrTitle = lpstrTitle;
}
// フィルタの設定
unsigned char *pszToken;
if ( lpstrFilter == NULL ||
*lpstrFilter == 0x00 ) {
lstrcpy( szFilter, "全て,*.*" );
}
else {
lstrcpy( szFilter, lpstrFilter );
}
pszToken = _mbstok(
(unsigned char *)szFilter,
(const unsigned char *)","
);
while( pszToken != NULL ) {
pszToken = _mbstok( NULL, (const unsigned char *)"," );
}
ofn.lpstrFilter = szFilter;
if ( nFilterIndex == 0 ) {
ofn.nFilterIndex = 1;
}
else {
ofn.nFilterIndex = nFilterIndex;
}
// ファイルのパスが格納されるバッファ
ofn.lpstrFile = lpstrFile;
ofn.nMaxFile = MAX_PATH;
// オプションフラグ
if ( Flags == 0 ) {
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
}
else {
ofn.Flags = Flags;
}
// API 関数の呼び出し
BOOL ret;
ret = GetOpenFileName( &ofn );
if ( ret ) {
return TRUE;
}
return FALSE;
}
| |
|
|
|
|
// *********************************************************
// 保存するファイルのパスを取得する
// *********************************************************
BOOL LboxSaveFileName(
HWND hwndOwner,
LPCTSTR lpstrTitle,
LPCTSTR lpstrFilter,
DWORD nFilterIndex,
LPTSTR lpstrFile,
DWORD Flags
)
{
OPENFILENAME ofn;
char szFilter[512];
// メモリの初期化
ZeroMemory( &ofn, sizeof( ofn ) );
ZeroMemory( szFilter, sizeof( szFilter ) );
// 環境
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwndOwner;
// タイトル
if ( lpstrTitle == NULL ||
*lpstrTitle == 0x00 ) {
ofn.lpstrTitle = "保存ファイルのパスの取得";
}
else {
ofn.lpstrTitle = lpstrTitle;
}
// フィルタの設定
unsigned char *pszToken;
if ( lpstrFilter == NULL ||
*lpstrFilter == 0x00 ) {
lstrcpy( szFilter, "全て,*.*" );
}
else {
lstrcpy( szFilter, lpstrFilter );
}
pszToken = _mbstok(
(unsigned char *)szFilter,
(const unsigned char *)","
);
while( pszToken != NULL ) {
pszToken = _mbstok( NULL, (const unsigned char *)"," );
}
ofn.lpstrFilter = szFilter;
if ( nFilterIndex == 0 ) {
ofn.nFilterIndex = 1;
}
else {
ofn.nFilterIndex = nFilterIndex;
}
// ファイルのパスが格納されるバッファ
ofn.lpstrFile = lpstrFile;
ofn.nMaxFile = MAX_PATH;
// オプションフラグ
if ( Flags == 0 ) {
ofn.Flags = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
}
else {
ofn.Flags = Flags;
}
// API 関数の呼び出し
BOOL ret;
ret = GetSaveFileName( &ofn );
if ( ret ) {
return TRUE;
}
return FALSE;
}
| |
|
|
|