cht電腦資訊LanguageC/C++
adm Find login register

win32 GetOpenFileName

eliu

joined: 2007-08-09
posted: 11446
promoted: 617
bookmarked: 187
新竹, 台灣
1subject: win32 GetOpenFileNamePromote 0 Bookmark 02009-10-09quote  

Windows win32 想用來選擇 folder/directory 不知道要怎麼做,GetOpenFileName 選folder 然後 click open 會跳到 folder 裏面,不會 close dialog。

BOOL GetOpenFileName(LPOPENFILENAME lpofn);

edited: 2
eliu

joined: 2007-08-09
posted: 11446
promoted: 617
bookmarked: 187
新竹, 台灣
2subject: Promote 0 Bookmark 02009-10-09quote  

用 msdn search 半天找不到,最後用 google 找到  function

PIDLIST_ABSOLUTE SHBrowseForFolder(      
    LPBROWSEINFO lpbi
);

eliu

joined: 2007-08-09
posted: 11446
promoted: 617
bookmarked: 187
新竹, 台灣
3subject: Promote 0 Bookmark 02009-10-13quote  

Example
            BROWSEINFO br;
            ZeroMemory(&br, sizeof(br));
            br.hwndOwner = hWnd;

            char dir[MAXPATH];
            LPITEMIDLIST pIIL = SHBrowseForFolder(&br);
            if(pIIL)
                SHGetPathFromIDList(pIIL, dir);
          
            IMalloc *pmal = 0;
            if(SHGetMalloc(&pmal) == S_OK) {
                pmal->Free(pIIL);
                pmal->Release();
            }

我覺得SHBrowseForFolder這個 function 設計得很爛,很難用。 

edited: 3

cht電腦資訊LanguageC/C++
adm Find login register
views:10220