Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Browse to folder

Status
Not open for further replies.

heydyrtt

Programmer
Dec 12, 2001
63
0
0
US
Need to know how to use the TOpenDialog to browse to a folder and once the folder is selected to get the path of that to display in DBEdit field.


Thanks


Heydyrtt
 
Well, first of all, you probably want to display it in a TEdit field as it is not a data-aware object.

The TOpenDialog component is just the standard windows open dialog that you see on almost any program. You implement it with it's Execute function. If you person selects a file w/ "Ok" then Execute returns true, else it returns false. Then you access the file path with the FileName property. This property is an AnsiString so you can directly assign it to the Text property of an Edit control.

Good luck,
onrdbandit

No! Try not. Do, or do not. There is no try. - Yoda
 
Do u need the path?

Once the user has pressed the OK button, u can read the path using the FileName property of the OpenDialog.

DBEdit1->Text = ExtractFilePath(OpenDialog1->FileName);



--- LastCyborg ---
 
I spend a lot of time to understand how to do a browse folder at the end I've find this:

=========START=============
#define NO_WIN32_LEAN_AND_MEAN
#include <WindowsX.h>

void __fastcall TFormQueuerAll::SpeedButton1Click(TObject *Sender)
{
// Use Windows 95 Directory box to get dir
BROWSEINFO bi;
char GDir[MAX_PATH];
char FolderName[MAX_PATH];
LPITEMIDLIST ItemID;
memset(&bi, 0, sizeof(BROWSEINFO));
memset(GDir, 0, MAX_PATH);
bi.hwndOwner = Handle;
bi.pszDisplayName = FolderName;
bi.lpszTitle = "Select Directory to Search In!";
ItemID = SHBrowseForFolder(&bi);
SHGetPathFromIDList(ItemID, GDir);
GlobalFreePtr(ItemID);
String Temp = String(GDir);
if (Temp == "") return;

Edit1->Text=Temp;
}
==================END===============

I hope that this could help you.

Bye,
Checco
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top