-
January 31st, 2007, 01:59 AM
#1
SHBrowseForFolderA
I am using SHBrowseForFolderA for showing a file dialog. The length of the selected path id geeting trimmed.
I've used these flags
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT;
Is there any way by which i can increase the size of the label in the dilaog box for the currently selected path.
---Arun.
-
January 31st, 2007, 03:12 AM
#2
Re: SHBrowseForFolderA
Use CFileDialog class in MFC for browsing a file; For selecting a folder you can use the following code
char Path[MAX_PATH];
BROWSEINFO Browse;
Browse.hwndOwner = m_hWnd; // Handle
Browse.pidlRoot = NULL;
Browse.pszDisplayName = Path;
Browse.lpszTitle = "Choose";
Browse.ulFlags = BIF_RETURNONLYFSDIRS; // Chnge it to yours flags
Browse.lpfn = NULL;
Browse.lParam = 0;
Browse.iImage = 0;
Browse.pidlRoot = SHBrowseForFolder(&Browse);
SHGetPathFromIDList(Browse.pidlRoot, Path);
-
January 31st, 2007, 04:04 AM
#3
Re: SHBrowseForFolderA
To get rid of long paths truncation, you have to rearrange a little the static controls which display the title and path, respectively. Once you are using BIF_STATUSTEXT style I can presume that you already use an application-defined callback function (e.g. BrowseCallbackProc). Here is an example, that rearrange those static texts by handling BFFM_INITIALIZED message:
Code:
#define IDC_STATIC_TITLE 0x3742
#define IDC_STATIC_DIR 0x3743
// ...
int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
{
// ...
switch(uMsg)
{
case BFFM_INITIALIZED:
{
CWnd* pDlg = CWnd::FromHandle(hwnd);
CWnd* pTitle = pDlg->GetDlgItem(IDC_STATIC_TITLE);
CWnd* pDir = pDlg->GetDlgItem(IDC_STATIC_DIR);
// get the initial positions
CRect rcTitle, rcDir;
pTitle->GetWindowRect(rcTitle);
pDir->GetWindowRect(rcDir);
pDlg->ScreenToClient(rcTitle);
pDlg->ScreenToClient(rcDir);
// now re-arrange
const int nHeight = rcDir.Height();
rcTitle.bottom = rcTitle.top + nHeight;
rcDir.top = rcTitle.bottom;
rcDir.bottom = rcDir.top + 2 * nHeight;
pTitle->MoveWindow(rcTitle);
pDir->MoveWindow(rcDir);
// NOTE: above it's just an example.
// to be shorter and clearer, no error checking is made.
// ...
}
break;
// ...
}
return 0;
}
Code:
// ...
BROWSEINFO bi;
// ...
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT;
bi.lpfn = BrowseCallbackProc;
// ...
// ...
Last edited by ovidiucucu; January 31st, 2007 at 04:23 AM.
Reason: Oups! Forgot IDC_STATIC_TITLE and IDC_STATIC_DIR defines
-
January 31st, 2007, 04:14 AM
#4
Re: SHBrowseForFolderA
@to fazilvp:
Your answer does not solve the OP problem:
Originally Posted by arunperi
I am using SHBrowseForFolderA for showing a file dialog. The length of the selected path is geeting trimmed.
[...]
Is there any way by which i can increase the size of the label in the dilaog box for the currently selected path.
Please, read a little bit more carefully a question before giving an answer!
Thanks,
Ovidiu
-
January 31st, 2007, 05:44 AM
#5
Re: SHBrowseForFolderA
Thanks Ovidiu for that.
If i need to re-size ok and cancel buttons i need the $defines for them too, can you please list the #defines for "Ok" and "CANCEL" buttons.
Thanks,
Arun.
-
January 31st, 2007, 05:58 AM
#6
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|