|
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();
}
}
}
|
|
|
|
|
|
Yes, not very .Netish, I agree, but it is interesting to the the not-.Netish part tracking text typed into the Edit box and the .Netish not tracking the text. Does anyone know of a textbox control that has similar Intellisense capabilities but implemented in .Net?
|
|
|
|
|
Hi Rama!
Thank you very much for this control! Just what I needed in my project (Nish gave me the link)!
5 points from me!
Cheers
and keep up the good work
Martin
"Situation normal - all fu***d up"
Illuminatus!
|
|
|
|
|
Thanks.
I have to update the article. For some reasons I don't get replies for comments on this article.
|
|
|
|
|
Very helpful. What would make it even better would be if you could set the initial folder.
This can be done by calling your ShellFolderBrowser.SetSelection() with the initial path you want in the ShellBrowserFolder.Callback() function in the BFFM_INITIALIZED case.
However, the SetSelection() function has a bug that prevents it from working
This
…
int msg = (Environment.OSVersion.Platform == PlatformID.Win32NT) ? BFFM_SETSTATUSTEXTA : BFFM_SETSTATUSTEXTW;
..
should be this
int msg = (Environment.OSVersion.Platform == PlatformID.Win32NT) ? BFFM_SETSTATUSTEXTW : BFFM_SETSTATUSTEXTA;
Matthew Henry
|
|
|
|
|
I tried making this suggested switch in SetSelection from:
int msg = (Environment.OSVersion.Platform == PlatformID.Win32NT) ? BFFM_SETSTATUSTEXTA : BFFM_SETSTATUSTEXTW;
to:
int msg = (Environment.OSVersion.Platform == PlatformID.Win32NT) ? BFFM_SETSTATUSTEXTW : BFFM_SETSTATUSTEXTA;
but it still doesn't work. I noticed that the SendMessage method is returning false. Do you have any suggestions?
Jeremy Holland
Software Engineer
Proquest Automotive
a business unit of Proquest Business Solutions Inc.
3900 Kinross Lakes Pkwy
Richfield, OH 44286
|
|
|
|
|
I made these changes to FolderBrowser.cs
public string FolderPath
{
get
{
...
return pathReturned.ToString();
}
set // added Matthew Henry 29-Apr-02
{
mInitialPath = value;
}
}
protected string mInitialPath; // added Matthew Henry 29-Apr-02
...
public void SetStatusText(string text)
{
if (handle == IntPtr.Zero)
throw new InvalidOperationException();
int msg = (Environment.OSVersion.Platform == PlatformID.Win32NT) ? BFFM_SETSTATUSTEXTW : BFFM_SETSTATUSTEXTA;// changed Matthew Henry 29-Apr-02
IntPtr strptr = Marshal.StringToHGlobalAuto(text);
...
private int CallBack(IntPtr hwnd, int msg, IntPtr lp, IntPtr lpData)
{
...
if (Initialized != null)
{
Initialized(this, null);
}
if (mInitialPath != null) // added Matthew Henry 29-Apr-02
SetSelection(mInitialPath);
break;
case BFFM_IUNKNOWN:
-----------------------
That's prolly a little confusing, but if you look at that and the original code, you get the idea.
|
|
|
|
|
Hello you must insert follow changes
Make a new variable:
<br />
<br />
> private string initfolderpath;<br />
<br />
Make a new Property:
<br />
<br />
> public string InitFolderPath<br />
> {<br />
> get<br />
> {<br />
> return initfolderpath;<br />
> }<br />
> set<br />
> {<br />
> initfolderpath = value;<br />
> }<br />
> }<br />
<br />
Insert line in : ShowDialogInternal(...
<br />
<br />
...<br />
bi.flags = (int)flags;<br />
> bi.lparam = Marshal.StringToHGlobalAuto(initfolderpath);<br />
...<br />
<br />
Insert lines in CalBack(...
<br />
<br />
...<br />
case BFFM_INITIALIZED:<br />
handle = hwnd;<br />
><br />
> int selmsg = (Environment.OSVersion.Platform == PlatformID.Win32NT) ? BFFM_SETSELECTIONW : BFFM_SETSELECTIONA;<br />
> UnManagedMethods.SendMessage(handle, selmsg, new IntPtr(1), lpData);<br />
><br />
if (Initialized != null)<br />
...<br />
<br />
Have Fun
_______
ASSOLI
|
|
|
|