|
Can i put a text box inside Shellbrowsedialog....
Or can i get what i typed in shellbrowserdialog browseflag=editbox
Mohan Kartha
|
|
|
|
|
When using this component, everything works fine except there is no text in the buttons or the Title area. This occurs both in a project I have included the component in, and in the demo project. Incidentally, in my own project, once another dialog (such as a standard Open File dialog) has been opened, the text is then visible if I open a Folder Browser dialog. I am running on Windows XP SP2,etc. Has anyone else experience anything similar or does anyone have any ideas?
Caleb
|
|
|
|
|
Replace Marshal.StringToHGlobalAuto with Marshal.StringToHGlobalAnsi
public void SetSelection(string newsel)
{
if (handle == IntPtr.Zero)
throw new InvalidOperationException();
int msg = (Environment.OSVersion.Platform == PlatformID.Win32NT) ? BFFM_SETSELECTIONA : BFFM_SETSELECTIONW;
//IntPtr strptr = Marshal.StringToHGlobalAuto(newsel);
IntPtr strptr = Marshal.StringToHGlobalAnsi(newsel);
UnManagedMethods.SendMessage(handle, msg, new IntPtr(1), strptr);
Marshal.FreeHGlobal(strptr);
}
|
|
|
|
|
I've looked into this a bit and I've decided that I really hate the FolderBrowserDialog because it doesn't support links or any of the other features of SaveFileDialog or OpenFileDialog.
Fortunately, although its not really a very neat solution, you can get the OpenFileDialog to browse for folders.
The key is setting CheckFileExists to false and setting the Filter to return no file results (by hacking it to look for "no.files"):
<br />
OpenFileDialog bob = new OpenFileDialog();<br />
bob.InitialDirectory = txt_DirPath.Text;<br />
<br />
bob.Title = "Please choose a folder";<br />
bob.CheckFileExists = false;<br />
<br />
bob.FileName = "[Get Folder...]";<br />
bob.Filter = "Folders|no.files";<br />
<br />
bob.ShowDialog();<br />
<br />
string dir_path = Path.GetDirectoryName(bob.FileName);<br />
if (dir_path != null && dir_path.Length > 0) {<br />
txt_DirPath.Text = dir_path;<br />
}<br />
Note: there is a textbox on the form called "txt_DirPath" that is used to display the folder to which the user browsed.
|
|
|
|
|
This solution is far worse. You can not choose a directory with a subdirectory.
|
|
|
|
|
Works for me..Actually its just what I was looking for. As for selecting a directory which has subdirectories, the key is "NOT" to double click the folder but simply click "Open" while the folder is not selected.
Hamid
|
|
|
|
|
I've downloaded half a dozen solutions for this problem, each one more complicated than the previous one.
And then I found this one. It's simple and works fine!. Less is more!!
|
|
|
|
|
Well, it really won't work for me after all... The way to select a folder with subfolders is not really good. Nice try!
|
|
|
|
|
Do I add a ref to the folderbrowser project . How do I put it in the toolbox? Please help!
|
|
|
|
|
First of all: it is a great submission.
I was looking a long time for such stuff.
But nevertheless I encountered the following problem:
I'm running your code on Win2K SP4 Workstation with .Net 2003 (V1.1).
But I couldn't change the text of the OK button.
Can you please help me out.
---
I modified your code slightly to set the caption as well:
---
case BFFM_INITIALIZED:
handle = hwnd;
if (Initialized != null)
{
Initialized(this, null);
//Change 'Browse for Folder' window's title bar text:
string strCaption = "Browse for a directory";
UnManagedMethods.SetWindowTextA(hwnd.ToInt32(), strCaption);
}
---
[DllImport("user32", EntryPoint="SetWindowText")]
internal extern static int SetWindowTextA(int hwnd, string lpString);
---
I hope that is of interest too.
Best regards HStrix
|
|
|
|
|
I checked the code now on WinXP SP2 and Win2003,
both with .Net 2003, and it worked fine.
So, it means, there is a problem in W2K.
But there is still a question:
I want to change the text of the OK button not in the calling program
(after diplaying the browse dialog) but in the component itself.
I could imagine that it could be solved using threading
but unfortunately I haven't any experience with this.
|
|
|
|
|
This browser is based on the shell objects support.
At older OS like NT 4.0, file browsing is not supported by the shell object (only version 4.71 and above).
Moreover, the browser performence at older shell is quite poor.
Since there is no shell update package by MS you should think twice before using such a browser if you need to support older OS. (they say that IE 4 and above update the shell but it's not true, IE 6.0 for example doesn't update the shell).
|
|
|
|
|
It'd be nice if the Title,OK button text etc. could be set before the dialog was shown, by making these into fields (or in Title's case, it already is), and not checking for a handle. These fields could then be checked to see if they're null inside ShowDialogInternal, and if they're not, set them once we've got the handle for the dialog.
|
|
|
|
|
Hi,
I'm trying to write C# code that takes in the name of a folder, then opens the folder and lists the names of the files in the folder. Any ideas on how to do this?
Thanks,
SM
|
|
|
|
|
Does anyone know how to do this in vb.net? (and not by the class already created in the .net 1.1 framework)
|
|
|
|
|
wonder what this joker (he thinks he is an eXpert) does when people call this article UN-DOT-NETish
|
|
|
|
|
How do you get the selected computer name (path) when the style is set to BrowseForComputer ???
|
|
|
|
|
Is there a way for this dialog to return the computer name instead of the Folder path?
|
|
|
|
|
Hello,
Thanks for your excellent effort. However I need to display my dialog with the new style enabled. And it isnt working. Please help.
|
|
|
|
|
Hello Rama:
How can I set the Initial folder for your component?
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
hi
im trying to use this control in a vb.net app
problem is the OK btn wont enable when i select a folder
when i add the selchanged event it just blows up
heres my code
Protected FolderDialogOpened As Boolean = False<br />
<br />
Protected openFileDialog1 As New OpenFileDialog()<br />
-------<br />
<br />
Private Sub btnModelFolderPath_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnModelFolderPath.Click<br />
FolderDialogOpened = False<br />
<br />
With OpenFolderDialog<br />
.BrowseFlags = CP.Windows.Forms.BrowseFlags.BrowseForComputer<br />
End With<br />
<br />
If OpenFolderDialog.ShowDialog = DialogResult.OK Then<br />
txtAgencyFolderPath.Text = OpenFolderDialog.FolderPath<br />
End If<br />
<br />
End Sub<br />
<br />
<br />
Private Sub OpenFolderDialog_SelChanged(ByVal sender As Object, ByVal e As CP.Windows.Forms.FolderSelChangedEventArgs) Handles OpenFolderDialog.SelChanged<br />
If FolderDialogOpened Then OpenFolderDialog.EnableOkButton(True)<br />
End Sub
can anyone tell me where im being stupid!?
|
|
|
|
|
Hi Rama:
Thanks for your useful component.
I want to use it in my project,but you don't mention how to add it in toolbox.Could you tell how can I add it to my project?(sorry for my dumb question)
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Right click on the toolbox, click on Customize. Then click on browse and browse to the assembly. Click on OK and you'll be set to go.
David Stone
But Clinton wasn't a predictable, boring, aging, lying, eloquent, maintainer-of-the-status-quo. He was a predictable, boring-but-trying-to-look-hip, aging-and-fat-but-seemingly-oblivious-to-it, lying-but-in-sadly-blatant-ways, not-eloquent-but-trying-to-make-up-for-it-by-talking-even-more, bringer-in-of-scary-and-potentially-dangerous-new-policies. And there was also Al Gore. It just wasn't *right*.
Shog9
|
|
|
|
|
Am I missing something
Where do you browse to "browse to the assembly"? What's the filename?
Many Thanks,
CM
|
|
|
|
|
This may not be very kosher, but it is an alternate method.
Although I would much rather have Visual Studio's browse for folder dialog. Does anyone know how to create that folder browsing dialog? (i.e. File->New Project, then press the browse button)
Cheers,
wharper
using System;
using System.Windows.Forms.Design;
using System.Windows.Forms;
namespace BrowseFolder
{
public class BrowseForFolder : System.Windows.Forms.Design.FolderNameEditor
{
private FolderBrowser m_Dialog;
public BrowseForFolder()
{
m_Dialog = new FolderNameEditor.FolderBrowser();
}
public string DirectoryPath
{
get{return m_Dialog.DirectoryPath;}
}
public DialogResult BrowseDialog(string Title)
{
m_Dialog.Style = FolderBrowserStyles.BrowseForEverything;
m_Dialog.StartLocation = FolderBrowserFolder.Desktop;
m_Dialog.Description = Title;
return m_Dialog.ShowDialog();
}
}
}
|
|
|
|