忍者ブログ
NINJA
[1] [2] [3] [4] [5] [6] [7] [8] [9]
×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

ファイル選択ダイアログから、複数のファイルを選択する


BOOL xxxxxx::GetSelectFilePath( CStringArray& strAFilePath )
{

    // http://www.g-ishihara.com/mfc_cd_01.htm

    CString         filter("Img File( *.BMP;*.TIFF )| *.BMP; *.TIFF||");
    CString         filePath, strBuf;
    POSITION        pos = NULL;
    CFileDialog     selDlg(TRUE, NULL, NULL,  OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT | OFN_NOCHANGEDIR, filter);

    int err = 0;
   
    // ファイル名リスト用メモリ確保
    if (!err)
    {
        try
        {
            selDlg.GetOFN().lpstrFile = strBuf.GetBuffer(MAX_PATH *100);
            selDlg.GetOFN().nMaxFile = MAX_PATH *100;
        }
        catch (...) {err = 1;}
    }
    if( selDlg.DoModal() != IDOK ){
        err = 1;
        return FALSE;
    }

    if ((pos = selDlg.GetStartPosition()) == NULL){
        err = 1;
    }

    if (!err){
        while (pos)
        {
            filePath = selDlg.GetNextPathName(pos);
            strAFilePath.Add( filePath );
        }
    }
    strBuf.ReleaseBuffer();
   
    return TRUE;
}


PR
ファイル選択ダイアログからファイルをひとつ選択する

BOOL xxxxxx::GetSelectFilePath( CString& strFilePath )
{
    CString        strExtName("Img File( *.BMP;*.TIFF )| *.BMP; *.TIFF||");

    CFileDialog    selDlg( TRUE, NULL , NULL, OFN_HIDEREADONLY | OFN_NOCHANGEDIR, strExtName );

    if( selDlg.DoModal() == IDOK ){
        strFilePath = selDlg.GetPathName();
        return TRUE;
    } else {
        return FALSE;
    }
}


ドラッグアンドドロップファイルを取得する。

int xxxxxxx::GetDrapFileList(HDROP hDropInfo, CStringArray& strArrFileList)
{
    TCHAR    lpStr[MAX_PATH];
    CString strFileName;

    // Dropされたファイル数をカウント
    int iFileCount = ::DragQueryFileA( hDropInfo, 0xffffffff, NULL, 0 );

    // Dropされたファイル名を取得する
    for( int i = 0; i < iFileCount; i++ ){
        int iLen    = DragQueryFileA( hDropInfo, i, NULL, 0 );

        DragQueryFileW( hDropInfo, i, strFileName.GetBuffer( iLen+1 ), iLen + 1 );
        
        strFileName.ReleaseBuffer();

        strArrFileList.Add( strFileName );
    }

    return strArrFileList.GetSize();
}

指定したフォルダの存在をチェックする


BOOL xxxxxx::CheckFolderPath(CString FolderPath)
{
    // フォルダ確認
    if( ::PathFileExists( FolderPath ) ){
        return true;
    }

    return false;
}

ファイルの存在チェック


BOOL xxxxxx::CheckFile( LPCTSTR FileName )
{
    bool bRet = false;
    WIN32_FIND_DATA    FindData;

    HANDLE hFile = FindFirstFile( FileName, &FindData );
    if ( hFile != INVALID_HANDLE_VALUE )
        bRet = true;
    FindClose( hFile );
    return bRet;

}

カレンダー
04 2025/05 06
S M T W T F S
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
フリーエリア
最新CM
最新TB
プロフィール
HN:
No Name Ninja
性別:
非公開
バーコード
ブログ内検索
アーカイブ
P R
Powered by ニンジャブログ  Designed by ゆきぱんだ
Copyright (c) Visual Studio C++のお勉強 All Rights Reserved
忍者ブログ / [PR]