BFFM_SETSELECTION question
-
The MSDN docs say "The path can be specified as a Unicode string or a PIDL" for the BFFM_SETSELECTION message (inside a BrowseCallbackProc function after calling SHBrowseForFolder), but when I send a Unicode string instead of an ansi one it fails. Is the documentation wrong?
-
The MSDN docs say "The path can be specified as a Unicode string or a PIDL" for the BFFM_SETSELECTION message (inside a BrowseCallbackProc function after calling SHBrowseForFolder), but when I send a Unicode string instead of an ansi one it fails. Is the documentation wrong?
Did you set the wParam as true?
-Prakash
-
Did you set the wParam as true?
-Prakash
-
How are you sending the unicode string ? can you dump the section of code ?
-Prakash
-
How are you sending the unicode string ? can you dump the section of code ?
-Prakash
if you uncomment the commented out lines it works fine in unicode builds but not ansi. it's being converted to unicode ok because OutputDebugStringW prints what it's supposed to.
int CALLBACK BrowseCallbackProc_SetInitFolder(HWND hWnd, UINT uMsg, LPARAM lParam, LPARAM lpData) { if (uMsg == BFFM_INITIALIZED) { //#ifdef UNICODE SendMessage(hWnd, BFFM_SETSELECTION, TRUE, lpData); //#else // WCHAR sz[MAX_PATH]; // MultiByteToWideChar(CP_ACP, 0, (LPTSTR)lpData, -1, sz, MAX_PATH); // OutputDebugStringW(sz); // SendMessage(hWnd, BFFM_SETSELECTION, TRUE, (LPARAM)sz); //#endif } return 0; }
-
if you uncomment the commented out lines it works fine in unicode builds but not ansi. it's being converted to unicode ok because OutputDebugStringW prints what it's supposed to.
int CALLBACK BrowseCallbackProc_SetInitFolder(HWND hWnd, UINT uMsg, LPARAM lParam, LPARAM lpData) { if (uMsg == BFFM_INITIALIZED) { //#ifdef UNICODE SendMessage(hWnd, BFFM_SETSELECTION, TRUE, lpData); //#else // WCHAR sz[MAX_PATH]; // MultiByteToWideChar(CP_ACP, 0, (LPTSTR)lpData, -1, sz, MAX_PATH); // OutputDebugStringW(sz); // SendMessage(hWnd, BFFM_SETSELECTION, TRUE, (LPARAM)sz); //#endif } return 0; }
In Ansi build you should NOT convert the string to Unicode while using windows APIs, Check this link[^] and search for BFFM_SETSELECTION The Microsoft documentation has a couple of minor errors I should point out in case you try to program SHBrowseForFolder in C. The documentation says to pass the string for BFFM_SETOKTEXT in WPARAM; actually, it's LPARAM. It also says that BFFM_SETSELECTION requires a Unicode string, but BFFM_SETSELECTION is available in both A and W flavors, so you can use LPCTSTR.
-Prakash -- modified at 23:38 Sunday 8th January, 2006
-
In Ansi build you should NOT convert the string to Unicode while using windows APIs, Check this link[^] and search for BFFM_SETSELECTION The Microsoft documentation has a couple of minor errors I should point out in case you try to program SHBrowseForFolder in C. The documentation says to pass the string for BFFM_SETOKTEXT in WPARAM; actually, it's LPARAM. It also says that BFFM_SETSELECTION requires a Unicode string, but BFFM_SETSELECTION is available in both A and W flavors, so you can use LPCTSTR.
-Prakash -- modified at 23:38 Sunday 8th January, 2006