• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            天下

            記錄修行的印記

            為SHBrowseForFolder指定初始目錄

            SHBrowseForFolder可以用來得到一個(gè)用戶選擇的目錄。

            可是有時(shí)候會(huì)有需要去指定一個(gè)初始目錄,比如希望上次用戶選擇的目錄可以保存下來。這該如何去做?

            在BROWSEINFO結(jié)構(gòu)體中提供了一個(gè)成員,這是一個(gè)指向函數(shù)的指針,通過這個(gè)回調(diào)函數(shù),可以處理初始化的時(shí)候需要做的一些事情。

            其中函數(shù)名是固定的:BrowseCallbackProc()

            BrowseCallbackProc Function


            Specifies an application-defined callback function used to send messages to, and process messages from, a Browse dialog box displayed in response to a call to SHBrowseForFolder.

            Syntax

            int CALLBACK BrowseCallbackProc(      
                HWND hwnd,
                UINT uMsg,
                LPARAM lParam,
                LPARAM lpData
            );

            Parameters

            hwnd
            The window handle of the browse dialog box.
            uMsg
            The dialog box event that generated the message. One of the following values.
            BFFM_INITIALIZED
            The dialog box has finished initializing.
            BFFM_IUNKNOWN
            An IUnknown interface is available to the dialog box.
            BFFM_SELCHANGED
            The selection has changed in the dialog box.
            BFFM_VALIDATEFAILED
            Version 4.71. The user typed an invalid name into the dialog's edit box. A nonexistent folder is considered an invalid name.
            lParam
            A value whose meaning depends on the event specified in uMsg as follows:
            uMsg lParam
            BFFM_INITIALIZED Not used, value is NULL.
            BFFM_IUNKNOWN A pointer to an IUnknown interface.
            BFFM_SELCHANGED A pointer to an item identifier list (PIDL) identifying the newly selected item.
            BFFM_VALIDATEFAILED A pointer to a string containing the invalid name. An application can use this data in an error dialog informing the user that the name was not valid.
            lpData
            An application-defined value that was specified in the lParam member of the BROWSEINFO structure used in the call to SHBrowseForFolder.

            Return Value

            Returns zero except in the case of BFFM_VALIDATEFAILED. For that flag, returns zero to dismiss the dialog or nonzero to keep the dialog displayed.

            Remarks

            To attach your BrowseCallbackProc to a dialog, specify its address in the lpfn member of the BROWSEINFO structure used in a SHBrowseForFolder call.

            BrowseCallbackProc can also send messages to the dialog box through SendMessage, controlling these aspects of that dialog box.

            • OK button enabled/disabled
            • OK button text
            • Selected folder
            • Expanded folder
            • Status text
            Set the SendMessage function's Msg parameter to one of the following values, providing additional information in the wParam and lParam parameters as indicated for each message type.

            BFFM_ENABLEOK

            Enables or disables the dialog box's OK button.

            • wParam. Not used.
            • lParam. To enable, set to a nonzero value. To disable, set to zero.

            BFFM_SETOKTEXT

            Version 6.0. Sets the text that is displayed on the dialog box's OK button.

            • wParam. Not used.
            • lParam. A pointer to a null-terminated Unicode string containing the desired text.

            BFFM_SETSELECTION

            Specifies the path of a folder to select. The path can be specified as a string or a PIDL.

            To use a string:

            • wParam. Set to TRUE.
            • lParam. A pointer to the null-terminated Unicode string that specifies the path.

            To use a PIDL:

            • wParam. Set to FALSE.
            • lParam. The PIDL that specifies the path.

            BFFM_SETEXPANDED

            Version 6.0. Specifies the path of a folder to expand in the Browse dialog box. The path can be specified as a Unicode string or a PIDL.

            To use a Unicode string:

            • wParam. Set to TRUE
            • lParam. A pointer to the null-terminated Unicode string that specifies the path.

            To use a PIDL:

            • wParam. Set to FALSE
            • lParam. The PIDL that specifies the path.

            BFFM_SETSTATUSTEXT

            Sets the status text. Set lpData to point to a null-terminated string with the desired text.

            • wParam. Not used.
            • lParam. A pointer to a null-terminated string containing the desired text.
            具體寫法如下:

             

            int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)   
            {   
                
            if  (uMsg == BFFM_INITIALIZED )
                {   
                    ::SendMessage(hwnd,BFFM_SETSELECTION,TRUE,lpData);   
                }   
                
            return 0;  
            }
             

                //使用:
                CString strLastPath = GetLastOpenDirectory();
                LPITEMIDLIST pidlRoot 
            = NULL;

                BROWSEINFO bi;
                ZeroMemory(
            &bi,sizeof(BROWSEINFO));
                bi.hwndOwner    
            = GetSafeHwnd();
                bi.lpszTitle    
            = _T("請(qǐng)選擇目錄");
                bi.ulFlags      
            = BIF_RETURNONLYFSDIRS | BIF_USENEWUI | BIF_NONEWFOLDERBUTTON; 
                bi.lpfn         
            = NULL;
                bi.pidlRoot     
            = pidlRoot;
                bi.lParam       
            = (LPARAM)strLastPath.GetBuffer();
                bi.lpfn         
            = BrowseCallbackProc;

                if(pidl == NULL)
                    return;

                SHGetPathFromIDList(pidl, csPath.GetBuffer(MAX_PATH));
                csPath.ReleaseBuffer();


            posted on 2010-12-13 17:49 天下 閱讀(2336) 評(píng)論(0)  編輯 收藏 引用 所屬分類: Win32

            <2010年12月>
            2829301234
            567891011
            12131415161718
            19202122232425
            2627282930311
            2345678

            導(dǎo)航

            統(tǒng)計(jì)

            常用鏈接

            留言簿(4)

            隨筆分類(378)

            隨筆檔案(329)

            鏈接

            最新隨筆

            搜索

            最新評(píng)論

            久久se精品一区精品二区国产| 久久丝袜精品中文字幕| 少妇熟女久久综合网色欲| 四虎久久影院| 久久99热只有频精品8| 国内精品久久久久影院优| 伊人丁香狠狠色综合久久| 久久精品亚洲男人的天堂| 香蕉久久夜色精品国产尤物| 青青草原精品99久久精品66| 久久九九亚洲精品| 久久精品亚洲AV久久久无码| 国产精品99久久免费观看| 亚洲国产成人久久一区WWW| 久久久久久久人妻无码中文字幕爆| 一本色道久久88加勒比—综合| 久久久SS麻豆欧美国产日韩| 精品久久久久久无码中文字幕| 人妻无码精品久久亚瑟影视| 久久国产免费直播| 97久久综合精品久久久综合| 久久精品成人欧美大片| 久久久免费观成人影院| 久久九九亚洲精品| 国产99精品久久| 亚洲AV无码久久| 午夜天堂精品久久久久| 亚洲欧美日韩精品久久亚洲区| 国产精品日韩欧美久久综合| 996久久国产精品线观看| 精品久久8x国产免费观看| 亚洲精品乱码久久久久久按摩 | 久久国产精品久久| 亚洲午夜久久久影院| 久久综合久久综合亚洲| 一本大道久久东京热无码AV| 久久精品这里只有精99品| 日韩久久无码免费毛片软件| 欧美精品丝袜久久久中文字幕 | 久久精品国产日本波多野结衣 | 久久天天躁狠狠躁夜夜av浪潮 |