Article View: borland.public.cppbuilder.nativeapi
Article #2359Re: Shbrowseforfolder edit box problems
From: Remy Lebeau (TeamB)
Date: Mon, 05 Mar 2007 23:59
Date: Mon, 05 Mar 2007 23:59
89 lines
3434 bytes
3434 bytes
"Mark Jacobs" <mark@jacobsm.com> wrote in message
news:45eca715@newsgroups.borland.com...
> Thanks for your help. However, I also need the new UI as in
> BIF_USENEWUI
>
> This makes your code *not* return the edit box contents when
> stuff is typed in.
The following code works for me now:
#include <shlobj.h>
int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM
lParam, LPARAM lpData)
{
switch( uMsg )
{
case BFFM_INITIALIZED:
{
LPTSTR ptr = reinterpret_cast<LPTSTR>(lpData);
if( ptr[0] != 0 )
{
SendMessage(hwnd, BFFM_SETSELECTION, TRUE,
lpData);
ptr[0] = 0;
}
break;
}
case BFFM_VALIDATEFAILED:
{
lstrcpyn(reinterpret_cast<LPTSTR>(lpData),
reinterpret_cast<LPTSTR>(lParam), MAX_PATH);
break;
}
}
return 0;
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
AnsiString Dir = Edit1->Text;
if( !DirectoryExists(Dir) )
Dir = GetCurrentDir();
TCHAR path[MAX_PATH+1] = {0};
lstrcpyn(path, Dir.c_str(), MAX_PATH);
BROWSEINFO bi = {0};
bi.hwndOwner = Handle;
bi.ulFlags = BIF_USENEWUI | BIF_EDITBOX | BIF_VALIDATE;
bi.lpfn = BrowseCallbackProc;
bi.lParam = reinterpret_cast<LPARAM>(path);
LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
if( pidl )
{
if( path[0] != 0 )
{
// user text was entered ...
}
else
{
// no user text was entered ...
SHGetPathFromIDList(pidl, path);
}
CoTaskMemFree(pidl);
Edit1->Text = path;
}
else
{
// dialog canceled...
}
}
> Without the BIF_USENEWUI (as in your code), I agree, it returns
> the contents of that edit box. But I want the new UI. complete with
> make new folder functionality, and simply or'ing in the BIF_USENEWUI
> flag makes it *not* return the box contents!
That is because the TreeView has priority over the edit box when that
flag is enabled. Without it, the edit box has priority instead.
Gambit
Technical Details
Message-ID:
<45ecaee8$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<45ec10db$1@newsgroups.borland.com> <45ec6a71@newsgroups.borland.com> <45ec71a5$1@newsgroups.borland.com> <45eca715@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,149a673c2d92f69f X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <45ec10db$1@newsgroups.borland.com> <45ec6a71@newsgroups.borland.com> <45ec71a5$1@newsgroups.borland.com> <45eca715@newsgroups.borland.com> Subject: Re: Shbrowseforfolder edit box problems Date: Mon, 5 Mar 2007 15:59:15 -0800 Lines: 91 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 75.83.34.171 Message-ID: <45ecaee8$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1173139176 75.83.34.171 (5 Mar 2007 15:59:36 -0800) Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail