Possible to change FolderBrowserDialog's title?

J

Jessica

In a windows forms application, is it possible to change the title of a
FolderBrowserDialog? It has always the default title "Browse For Folder"

-J
 
J

Jeff Johnson

In a windows forms application, is it possible to change the title of a
FolderBrowserDialog? It has always the default title "Browse For Folder"

From glancing at the class library it doesn't seem like the Framework
exposes a direct way to do this. You'll probably have to use P/Invoke and
send a WM_SETTEXT message to the form to change its title.
 
R

RobinDotNet

You can change the description that appears above the directory tree. It's
the [Description] property of the FolderBrowserDialog instance.

RobinS.
GoldMail.com
 
G

G Himangi

You'll probably have to use P/Invoke and
send a WM_SETTEXT message to the form to change its title

This is very complicated way but probably the only way - you first have to
somehow get the window handle of the dialog and then change its text.

---------
- G Himangi, LogicNP Software http://www.ssware.com
Shell MegaPack: GUI Controls For Drop-In Windows Explorer like File/Folder
Browser Functionality (.Net & ActiveX Editions).
EZNamespaceExtensions: Develop namespace extensions rapidly in .Net and
MFC/ATL/C++
EZShellExtensions: Develop all shell extensions,explorer bars and BHOs
rapidly in .Net & MFC/ATL/C++
 
A

Abhishek Dadhich

1. public partial class Form1 : Form
2. {
3. public Form1()
4. {
5. InitializeComponent();
6. }
7.
8. public delegate void ChangeTitleDelegate();
9.
10. [DllImport("user32.dll", EntryPoint = "SetWindowText", CharSet = CharSet.Ansi)]
11. public static extern bool SetWindowText(IntPtr hWnd, String strNewWindowName);
12.
13. [DllImport("user32.dll", EntryPoint = "FindWindow", CharSet = CharSet.Ansi)]
14. public static extern IntPtr FindWindow(string className, string windowName);
15.
16. private void button1_Click(object sender, EventArgs e)
17. {
18. //Change FolderBrowserBox Title.
19. this.BeginInvoke(new ChangeTitleDelegate(ChangeFolderBrowserBoxTitle));
20.
21. //Show FolderBrowserBox
22. FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
23. folderBrowserDialog.RootFolder = System.Environment.SpecialFolder.MyComputer;
24. folderBrowserDialog.ShowDialog();
25. }
26.
27. /// <summary>
28. /// Change FolderBrowserBox Title.
29. /// </summary>
30. private static void ChangeFolderBrowserBoxTitle()
31. {
32. bool titleChanged = false;
33.
34. TimerCallback timerCallback = delegate
35. {
36. try
37. {
38. IntPtr ptr = FindWindow(null, "Browse For Folder");
39. if (ptr != IntPtr.Zero)
40. {
41. SetWindowText(ptr, "Hi, i am Tarannum Banu");
42. titleChanged = true;
43. }
44. }
45. catch (Exception exception)
46. {
47. System.Diagnostics.Debug.WriteLine(exception.Message);
48. }
49. catch
50. {
51. }
52. };
53.
54. System.Threading.Timer timer = null;
55. try
56. {
57. timer = new System.Threading.Timer(timerCallback, null, 500, 500);
58. while (!titleChanged)
59. {
60. System.Windows.Forms.Application.DoEvents();
61. System.Threading.Thread.Sleep(0);
62. }
63. }
64. catch (Exception exception)
65. {
66. System.Diagnostics.Debug.WriteLine(exception.Message);
67. }
68. finally
69. {
70. if (timer != null) timer.Dispose();
71. }
72. }

http://pastebin.com/BxiJRUk8



G Himangi wrote:

You'll probably have to use P/Invoke andThis is very complicated way but
27-Nov-08

You'll probably have to use P/Invoke an

This is very complicated way but probably the only way - you first have to
somehow get the window handle of the dialog and then change its text

---------
- G Himangi, LogicNP Software http://www.ssware.co
Shell MegaPack: GUI Controls For Drop-In Windows Explorer like File/Folder
Browser Functionality (.Net & ActiveX Editions)
EZNamespaceExtensions: Develop namespace extensions rapidly in .Net and
MFC/ATL/C+
EZShellExtensions: Develop all shell extensions,explorer bars and BHOs
rapidly in .Net & MFC/ATL/C+
---------


Previous Posts In This Thread:

Possible to change FolderBrowserDialog's title?
In a windows forms application, is it possible to change the title of
FolderBrowserDialog? It has always the default title "Browse For Folder

-J

Re: Possible to change FolderBrowserDialog's title?

From glancing at the class library it doesn't seem like the Framework
exposes a direct way to do this. You'll probably have to use P/Invoke and
send a WM_SETTEXT message to the form to change its title.

You can change the description that appears above the directory tree.
You can change the description that appears above the directory tree. It's
the [Description] property of the FolderBrowserDialog instance

RobinS.
GoldMail.com
------------------------------------------

You'll probably have to use P/Invoke andThis is very complicated way but
You'll probably have to use P/Invoke and

This is very complicated way but probably the only way - you first have to
somehow get the window handle of the dialog and then change its text.

---------
- G Himangi, LogicNP Software http://www.ssware.com
Shell MegaPack: GUI Controls For Drop-In Windows Explorer like File/Folder
Browser Functionality (.Net & ActiveX Editions).
EZNamespaceExtensions: Develop namespace extensions rapidly in .Net and
MFC/ATL/C++
EZShellExtensions: Develop all shell extensions,explorer bars and BHOs
rapidly in .Net & MFC/ATL/C++
---------




Submitted via EggHeadCafe - Software Developer Portal of Choice
WPF Binding Beyond the Limitation of Name Scopes
http://www.eggheadcafe.com/tutorial...f-49faac8854c8/wpf-binding-beyond-the-li.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top