Click here to Skip to main content
Click here to Skip to main content

Customizing OpenFileDialog in .NET

By , 14 Nov 2006
 

Sample Image - OpenFileDialogEx.png

Introduction

A few days ago, I wanted to start creating an Icon Editor application to make use of my IconLib library.

I created my main form, and I thought “where do I need to start”. Then, I decided to create a menu with the Open functionality. I thought the Open feature should have a preview screen to see the icon before opening it.

If you are reading this page, probably it is because you know that .NET has an OpenFileDialog class, but it cannot be customized. The objective of this control is to allow you to add some functionality to the OpenFileDialog .NET class. The main reason why you can’t customize the OpenFileDialog in .NET is because the class is declared sealed which means you can’t inherit from it. If you go to the base class FileDialog, it will allow you to inherit from it, but is has an internal abstract method “RunFileDialog”. Because it is internal and abstract, it only allows inheriting from it inside the same assembly.

How many times have you wanted to put some extra control in the OpenFileDialog control and you couldn’t…

Searching for code for .NET, I found a couple places where they used MFC, but nothing for .NET. OpenFileDialog is not a native implementation in .NET, instead it makes use of a Win32 API “GetOpenFileName”.

At this point, I had three choices:

  1. Create my own OpenFileDialog from scratch.
  2. Create my own OpenFileDialog reusing resources, (using the API “GetOpenFileName” and providing my own template).
  3. Hack the .NET OpenFileDialog and add the functionality I need for it.

Option (a) was not an option for me because it could require a lot of development time when I have a lot more stuff to be done. Later when the product is finished, I could review it. The next option required me to provide my own template using calls to Win32 API and resources. The option (c) was the more viable option at this time; don’t think of this as a bad hack, basically a hack is when you want to make the control do some extra functionality and you must do it from a different thread or process.

So because I like challenges, I decided to “hack” the OpenFileDialog class to create my own customizable control.

What it can do for you

I could have hacked the control to do what I needed and that would be it, but I ran into this problem many times right from .NET 1.0, and no one so far had come with a solution for it, so I decided to create an interface to this control where it can be used in different applications.

Also, I wanted to create something that didn’t require changing or adding code to the current project, and be capable of adding multiple controls without knowing the details of how they work; it needed to be a standalone control that can be added just as any other control in the IDE.

I created this control and I called it “OpenFileDialogEx”.

How do I do it?

Imagine OpenFileDialogEx as an abstract class: the only reason I didn’t make this class abstract is because the VS IDE can’t create an instance of an abstract class which avoids the rendering in the screen.

You could use the OpenFileDialogEx class like it is but make no sense, because it contains no extra functionality, just an empty UserControl.

So you must inherit OpenFileDialogEx to create your own customized version of the Open File Dialog.

After you inherit OpenFileDialogEx, you have created a custom control where you can add any control, you could add extra buttons, panels, or group boxes. Basically, it is a controls container; later this container will be “appended” to the .NET OpenFileDialog object on the fly.

There are three extra properties, three methods, and two events in this control that are different from any UserControl.

DefaultViewMode:

This property lets you choose which view the OpenFileDialog should start in; by default, it opens using the “Details view”. Here you can specify a different default view like Icons, List, Thumbnail, Detail, etc.

StartLocation:

This property tells if the control created should be stacked on the right, bottom, or behind the classic OpenFileDialog. Usually, this property will be the one used to expand the OpenFileDialog horizontally. If instead, you need to add extra controls to the current OpenFileDialog, then you can specify “None” and the controls inside OpenFileDialogEx will share the same client area with the original OpenFileDialog.

OpenDialog:

This property is the embedded OpenFileDialog inside the control. Here you can setup the standards property as InitialDir, AddExtension, Filters, etc.

OpenFileDialog for default is resizable, OpenFileDialogEx will help you with that automatically; the user control “OpenFileDialogEx” will be resized automatically. When the user expands or shrinks the window, it will behave differently depending on the StartLocation property.

StartLocation

  • Right: user control will be resized vertically.
  • Bottom: user control will be resized horizontally.
  • None: user control will be resized horizontally and vertically.

Basically, when you add your controls as buttons, panels, group boxes etc., you have to set the Anchor property of every control, then you can control where your control will be when the user resizes the OpenFileDialog window.

For example, to have an image preview, you could set the start location at the right, add a PictureBox to your inherited OpenFileDialogEx and set the Anchor property for the PictureBox to be Left, Top, Right, Bottom; this will resize the picture box dynamically when the user resizes the OpenFileDialog.

The methods are virtual methods that you will override to interact with the original OpenFileDialog.

OnFileNameChanged()

This method is called every time the user clicks on any file inside the view.

OnFolderNameChanged()

This method is called every time the user changes a folder from any control inside the OpenFileDialog.

OnClosing()

This method is called when the OpenFileDialog is closing, this is useful to release any resources allocated.

The two events are FileNameChanged and FolderNameChanged, those events are fired from their respective virtual methods “OnFileNameChanged” and “OnFolderNameChanged”. Instead of using the events, I recommend overriding the methods because it is cleaner code and also it doesn’t have another level of indirection.

How is it done?

The first problem is that OpenFileDialog is a modal dialog. This means that basically you can’t get the handle of the window because when you call ShowDialog(), you don’t have the control of the program flow as long the OpenFileDialog is open.

One way to get the handle of the OpenFileDialog is to override the WndProc method on your form and watch for the messages. When OpenFileDialog is created, the owner form will receive some messages like WM_IDLE, WM_ACTIVATE, WM_NC_ACTIVATE, etc. Those entire set of messages will set the parameter lParam with the handle to the OpenFileDialog window.

As you see, this requires overriding the WndProc methods. Some developers even don’t know that WndProc exists, so I wanted to avoid that. Also. I noticed some problems with MDI windows opening an OpenFileDialog.

Then what I did, basically, was when ShowDialog() is called, it creates a dummy form off the screen and hides it, this form will take care of opening the OpenFileDialog and taking the OpenFileDialog window handle.

At first, it listened on the WM_IDLE message, but the problem is when the message is send, it is already too late and the window is created and shown in the screen. Still, you can change the contents, but the user will see a small flicker on the screen between the original OpenFileDialog and the customized version.

Instead, we could take the message WM_ACTIVATE that happens before the OpenDialog is show on the screen.

So far it gets the handle and it is ready to be shown, now what?

How will it change the properties for the OpenFileDialog window?

Here is when the handy .NET NativeWindow comes into the picture, a NativeWindow is a window wrapper where it processes the messages sent by the handle associated to it. It creates a NativeWindow and associates the OpenFileWindow handle to it. From this point, every message sent to OpenFileWindow will be redirected to our own WndProc method in the NativeWindow instead, and we can cancel, modify, or let them pass through.

In our WndProc, we process the message WM_WINDOWPOSCHANGING. If the open dialog is opening, then we will change the original horizontal or vertical size depending of the StartLocation set by the user. It will increment the size of the window to be created. This happens only once when the control is opened.

Also, we will process the message WM_SHOWWINDOW. Here, all controls inside the original OpenFileDialog are created, and we are going to “append” our control to the open file dialog. This is done by calling a Win32 API “SetParent”. This API lets you change the parent window. Then, basically what it does is “attach” our control to the original OpenFileDialog in the location it set, depending on the value of the StartLocation property.

The advantage of it is that we still have complete control over the controls attached to the OpenFileDialog window. This means we can receive events, call methods, and do whatever we want with those controls.

Also, in the initialization, we will get the window handles for every control inside the original OpenFileDialog. This allows again to create .NET NativeWindows to process the messages in every control.

Now everything is ready, how do we watch for the messages when the user clicks on the ListView?

At first, I tried to process the messages from the ListView itself, creating a NativeWindow to it, but the problem is that every time the user changes the folder or clicks on a different view, the handler is destroyed and we have to recreate the handler to it.

Analyzing all windows inside FileOpenDialog with MS Spy, we can notice another FileDialog window inside the FileOpenDialog, and very probably it is the base window of FileOpenDialog. Checking the MSDN documentation, we see that every action made on the FileOpenDialog fires a WM_NOTIFY message filling a OFNOTIFY struct; this struct contains a code of the action made, and two of those actions are CDN_SELCHANGE and CDN_FOLDERCHANGE.

They are called when the user interacts with the folder combo box or the list view. Then, first I get the handle to the base FileWindow and I create a NativeWindow from this handle. This allows to process the messages WM_NOTIFY to analyze the OFNOTIFY struct and process CDN_SELCHANGE and CDN_FOLDERCHANGE. When this window processes those messages, they are forwarded to the OpenFileDialogEx control to the methods OnFileNameChanged and OnFolderNameChanged.

Another method was to intercept when the FileOpenDialog window is closed. At first, I used the message WM_CLOSE and it worked, but later I discovered that this message is not been called when the user double clicks on a file inside the list view. Watching the messages produced by FileOpenDialog, I saw that I could use the WM_IME_NOTIFY message. This message is sent with a wParam value of IMN_CLOSESTATUSWINDOW when the FileOpenDialog is being closed; here is when we forward the call to the method OnClosingDialog().

Now, how to resize the UserControl when the user resizes the FileOpenDialog; this is done by processing the message WM_WINDOWPOSCHANGING; here, we specify to change the size of the control relative to the FileOpenDialog size.

As an important detail, when the OpenFileWindow is closing, it must restore the original size as it was when we opened it, this is possible because OpenFileWindow remembers the last position/size. If we don’t do that, every time the OpenFileDialog is open, it will increment the size making it bigger and bigger.

Conclusion

I tested this on Windows XP and it works well, I didn’t have a chance to try on different OSs as Windows 2000/2003 or Vista, but it should work OK without problems. I don’t think it will work on Windows 95/98, because I’m setting the struct sizes only to match the WinNT OS. If you have any comments or discover a bug, let me know and I’ll update the control.

History

  • Release 1.0.1 (11/14/2006)
    • Forwards the DialogResult status to the caller.
    • Code optimization.
    • Uses the SetWindowsPos API with special flags to resize the control instead of direct size assignment to reduce flickering.
    • Control resizing is now done in WM_SIZING; this fixes a bug when the control is not resized for the last update until the mouse button is released.
  • Initial release 1.0.0 (07/14/2006)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

CastorTiu
Software Developer Microsoft
United States United States
Member
I started with programming about 19 years ago as a teenager, from my old Commodore moving to PC/Server environment Windows/UNIX SQLServer/Oracle doing gwBasic, QBasic, Turbo Pascal, Assembler, Turbo C, BC, Summer87, Clipper, Fox, SQL, C/C++, Pro*C, VB3/5/6, Java, and today loving C#.
 
Currently working as SDE on Failover Clustering team for Microsoft.
 
Passion for most programming languages and my kids Aidan&Nadia.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionError in Fileopen Dilogue box resizememberamsainju11 Dec '12 - 15:46 
Dear CastorTiu sir,
With the Help of your code I managed to make edit in the fileopen dilogue box in windows 7. But when the filopen dilogue box is resized the new modification doesn't appear. So would you please help me with how to make the file open dilogue box of fixed size.
Thank you
amsainju
AnswerRe: Error in Fileopen Dilogue box resizememberMoxxis14 Dec '12 - 4:31 
What did you have to do to get it to work in Windows 7?
Questionneed same solution for windows 7membersbalaji8329 Jun '12 - 1:45 
It works fine in xp os. But in windows7 events are not fired. How can i fire filenamechanged and foldernamechanged event?
QuestionNicememberzenwalker198522 Mar '12 - 20:07 
Nice and clever Smile | :)

BugA minor fix to work under 64-bitmemberPhilip Hotte10 Aug '11 - 6:14 
One problem - in the NMHDR struct you've got idFrom as a UInt32. That's actually supposed to be a pointer, so this causes a problem in 64-bit. My code field was always coming up 0 so events weren't recognized. Everything worked fine once I changed idFrom to an IntPtr.
GeneralRe: A minor fix to work under 64-bitmemberavramik27 Jun '12 - 23:22 
this a fix
[StructLayout(LayoutKind.Sequential)]
struct NMHDR
{
   public IntPtr hwndFrom;
   public IntPtr idFrom;
   public int code;
}

BugRe: A minor fix to work under 64-bitmembergt18424 Oct '12 - 21:52 
Should be:
 
public uint code

QuestionVery nice, it helped me to understand how to close programmatically the file open dialog from outside...memberIssaharNoam24 Jul '11 - 19:23 
Very nice, it helped me to understand how to close programmatically the file open dialog from outside...
GeneralCan it be shown modeless? [modified]memberMizan Rahman6 May '11 - 11:18 
Great article Smile | :)
 
I would actually like to embed it on a PropertyPage. Is it possible with this?
 
Thanks.

modified on Friday, May 6, 2011 5:31 PM

Generalblack holes in codememberMember 765788520 Feb '11 - 22:30 
include code for Dialogresult.---, as I included
GeneralMy vote of 4memberITDesign31 Aug '10 - 20:18 
very good,it's hard to do like this.
GeneralMy vote of 4memberSnakeHunter22129826 Aug '10 - 23:01 
but he doesn't work witch vista...
Question[My vote of 2] my argument is not affective?memberxunanhua25227 Feb '10 - 0:12 
the message's handle out of index when I want open another file.
Generalcenterparent / centerscreenmemberMember 476523622 Dec '09 - 22:32 
How can I apply the standard dialog startpositions "centerparent" or "centerscreen" on the openfiledialogex?
GeneralRe: centerparent / centerscreenmembercomponentage11 Jan '10 - 3:11 
Hello, just FYI: this and many other features exist in commercial components Dialog Workshop .NET (see http://www.componentage.com). The dialog components allow you to dock your own WinForms to any standard dialog(using technique similar to this article), extend file listview for Open/Save dialogs, etc.
GeneralRe: centerparent / centerscreenmemberralphoss28 Jun '12 - 22:58 
ComponentAge seems to be dead, they do not respond neither to my emails nor to my Skype messages. I found a serious bug in CaVistaOpenFileDialog preventing me from using it and I cannot get any help from their customer support.
GeneralFix the directorymembermurali_213 Sep '09 - 21:06 
HI,
Is there any way to make the savedialog fix to 1 directory ( means not allowed the client to change the directory )
QuestionHow to pre select more than one file in OpenFileDialog?memberbolenet16 Jun '09 - 5:01 
Hi,
 
I write some code for this, but every 4-5 times I get "Attempt to read or write protected memory ..." error.
Code:
if ((m.Msg == (int)Msg.WM_ENTERIDLE) && (this.mFileDialogEx.DroppedFiles.Count > 0))
                {
                    try
                    {
                        uint dialogHandle = (uint)m.LParam;
 
                        if (dialogHandle != m_lastDialogHandle)
                        {
                            //Set handle for ListView and pointers for ListViewItem position
                            Point itemPos = new Point();
                            IntPtr itemPosPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Point)));
                            Marshal.StructureToPtr(itemPos, itemPosPtr, true);
                            IntPtr listViewHandle = Win32.FindWindowEx((IntPtr)dialogHandle, (IntPtr)0, "SHELLDLL_DefView", "");
                            NativeWindow nvListView = new NativeWindow();
                            nvListView.AssignHandle(Win32.FindWindowEx(listViewHandle, (IntPtr)0, "SysListView32", "FolderView"));
                            
                            List<int> indexListForSelect = new List<int>();
                            List<string> dropedFilesOnlyNames = new List<string>();
 
                            for (int i = 0; i < this.mFileDialogEx.DroppedFiles.Count; i++)
                            {
                                FileInfo dropedFile = new FileInfo(this.mFileDialogEx.DroppedFiles[i]);
                                dropedFilesOnlyNames.Add(dropedFile.Name.Replace(dropedFile.Extension, string.Empty));
                                dropedFilesOnlyNames.Add(dropedFile.Name);
                            }
 
                            int count = Win32.SendMessage(nvListView.Handle, (uint)Lvm.LVM_GETITEMCOUNT, (IntPtr)0, (IntPtr)0);
                            LV_ITEM lvi = new LV_ITEM();
                            IntPtr lviPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(LV_ITEM)));
 
                            for (int i = 0; i < count; i++)
                            {
                                
                                lvi.iSubItem = 0;
                                lvi.cchTextMax = 1024;
                                lvi.pszText = string.Empty;
                                Marshal.StructureToPtr(lvi, lviPtr, true);
 
                                int res= Win32.SendMessage(nvListView.Handle, (uint)Lvm.LVM_GETITEMTEXT, (IntPtr)i, lviPtr);
                                if (res != 0)
                                {
                                    lvi = (LV_ITEM)Marshal.PtrToStructure(lviPtr, typeof(LV_ITEM));
                                    if (dropedFilesOnlyNames.Contains(lvi.pszText))
                                    {
                                        indexListForSelect.Add(i);
                                    }
                                }
                            }
                            indexListForSelect.Sort();
 
                            int countPerPage = Win32.SendMessage(nvListView.Handle, (uint)Lvm.LVM_GETCOUNTPERPAGE, (IntPtr)0, (IntPtr)0);
                            int countPerPageC = countPerPage;
 
                            //Select files in ListView of OpenFileDialog
                            for (int i = 0; i < indexListForSelect.Count; i++)
                            {
                                while (indexListForSelect[i] > countPerPage)
                                {
                                    Win32.SendMessage(nvListView.Handle, (uint)Msg.WM_HSCROLL, (IntPtr)Msg.SB_PAGERIGHT, (IntPtr)0);
                                    countPerPage += countPerPageC;
                                }
                                Win32.SendMessage(nvListView.Handle, (uint)Lvm.LVM_GETITEMPOSITION, (IntPtr)indexListForSelect[i], itemPosPtr);
                                itemPos = (Point)Marshal.PtrToStructure(itemPosPtr, typeof(Point));
                                Win32.SendMessage(nvListView.Handle, (uint)Msg.WM_LBUTTONDOWN, (IntPtr)Lvm.MK_CONTROL, MakeLParam(itemPos.Y, itemPos.X));
                                Win32.SendMessage(nvListView.Handle, (uint)Msg.WM_SETFOCUS, (IntPtr)0, (IntPtr)0);
                            }
 
                            // Remember last handle
                            m_lastDialogHandle = dialogHandle;
 
                            Marshal.FreeHGlobal(lviPtr);
                            Marshal.FreeHGlobal(itemPosPtr);
                        }
                    }
                    catch ()
                    {}
 
Code is used for drop files, open OpenFileDlg and then select these files.
AnswerRe: How to pre select more than one file in OpenFileDialog?memberNikyJJ13 May '10 - 0:08 
The problem was here:
lvi.iSubItem = 0;
lvi.cchTextMax = 1024;
lvi.pszText = string.Empty;
 
It should be like this:
lvi.iSubItem = 0;
lvi.cchTextMax = 1024;
lvi.pszText = new String('\0',lvi.cchTextMax+1);
GeneralControls positionsmemberfenixproductions14 Jun '09 - 16:12 
When this form is loaded label controls are shifted up. Resizing form changes their location to bottom (like on screenshot).
 
Any idea how to fix that for first run? Or maybe how to resize the form (i.e. by 1px) automatically, just to get it refreshed?
GeneralChange Dialog Sizememberdavid davies10 Jun '09 - 23:28 
Hi,
 
I am having trouble setting the size to something larger.
 
The width changes but not the height.
 
I have used controlex.ClientSize and .Size and .Width/Height but all give the same result ie a change in width but not in height.
 
Any thoughts much appreciated.
QuestionConstant valuesmemberDosihris14 Apr '09 - 7:29 
Wow, this is great. Can you explain how or where you found all these constant values? Most of them in windows.h or other header files. OK, but what about the FolderViewMode enumeration and the 0x7028 for the Default entry?
 
Have a nice day
 
Nico
GeneralNotememberAndrej Kicina16 Mar '09 - 8:59 
Great work! Thank you very much.
GeneralNot work in Vista OS.memberhuikong19 Feb '09 - 21:22 
It's OK in XP, but not work in Vista.
Generalproblem with vista 64memberhjozi3 Feb '09 - 18:41 
this program dont work in vista 64 bit
GeneralLove itmemberavramik30 Jan '09 - 9:40 
Love it.
You are right, this is the way, how to make it.Thumbs Up | :thumbsup:
 
modified on Friday, January 30, 2009 8:46 PM

GeneralLove thismemberjacobjordan2 Nov '08 - 16:27 
Exactly what i was looking for. One again, CodeProject saves the day. I see someone rated this 1 star, but i have no idea what some idiot would do that! Oh, by the way, that sure is an interesting choice of sample pictures in the download. Big Grin | :-D
 
Giveaway of the day .com
------------------------------------------------------------------
Dream.In.Code | Programmer's Heaven | CodeGuru
"Failure is only the opportunity to begin again, this time more wisely."

GeneralI want some one help about open file dialog.memberbaharehbahadori9 Oct '08 - 9:02 
I dont know how i can show my opened file dialog in one picture box or sth like this in c# D'Oh! | :doh:
 
If you have a big problem don’t say OH ! My GOD , I have a big problem ; but say hey problem ! I have a big GOD .

Questioncould folderbrowserdialog use such way?memberhowlet4 Oct '08 - 0:50 
hi,you are very nice.I have try it,it can work very well!
now,I want to apply it to FolderBrowserDialog,and create a FolderBrowserDialogEx.I just change "OpenFileDialog" to "FolderBrowserDialog",but the result is unsatisfied,the FormFolderBrowseDialog is drawed in the same position.
Could you give me some advice? thank yous!
AnswerRe: could folderbrowserdialog use such way?memberCheeso1 Jun '09 - 13:42 
Here is a FolderBrowserDialogEx that does something like what you want:
http://dotnetzip.codeplex.com/SourceControl/changeset/view/29832#432677[^]
QuestionIt does not work from WPF in Vista..memberMember 24383797 Jul '08 - 23:44 
I tried to use this code from my WPF app and had no any result - no extended controls had been added.
It's very strange because under WinXP it works good.
 
Could someone help me with it?
GeneralHelp,help,help!membershengcheng_jin7 May '08 - 13:15 
Why these codes doesn't work in Vista System.
I can't view attached form such as Review Image Panel.
Thany u very much!
Best Regards
Jin Shengcheng Jimmy
 
www.codeproject.com is a good web for our programer.
 
I like life and I think it is living.

GeneralRe: Help,help,help!memberScruffyDuck27 May '08 - 0:43 
Did you see the post by Jeff J Anderson a couple below this one?
 
Jon

GeneralRe: Help,help,help!membershengcheng_jin4 Aug '08 - 13:14 
Thanks Just as you said, Jeff J Anderson solved it.
Best Regards
 
www.codeproject.com is a good web for our programer.
 
I like life and I think it is living.

GeneralSuccessful VB.Net PortmemberSimon Turner28 Apr '08 - 0:06 
Hi. I have successfully converted the whole solution to VB.Net 2008.
I simply copied the C# code to a web-site that converted it to VB for me.
What took the most time was working out that ImeNotify.IMN_CLOSESTATUSWINDOW in WM_NOTIFY gets called twice by VB for some reason (even if you use the original C# FileExtenders dll). The first time it gets called is when the window is being initialised, so you need to filter that out when setting mIsClosing to True.
Also, that notification doesn't seem to get fired when double clicking on a file to open, so I moved all the code for resizing the window to the original size back into WM_DESTROY, which seems to get called properly by VB.
 
Hope this is useful to someone.
GeneralRe: Successful VB.Net PortmemberSimon Turner28 Apr '08 - 1:20 
I should mention that I started with Decebal Mihailescu's source code (see his article).
GeneralRe: Successful VB.Net Portmembervideoed30 Oct '09 - 0:38 
Can you upload your VB solution?
 
Shurely it would help not only me.
QuestionHow could i change the selected folder programatically?memberrodrigo881 Apr '08 - 9:35 
Hi, first of all, nice job...
 
I need yo limit the browsing of the dialog to a folder, so if the users selects another folder, i can catch it on the OnFolderNameChanged Event, and redirect it to the base folder again, but how can i redirect the OpenFileDialog?...Thx
GeneralA couple Fixes for Vista and x64memberJeff J Anderson9 Mar '08 - 13:11 
If you want this component to work with Vista add:
 
dlgOpen.AutoUpgradeEnabled = false;
 
to OpenFileDialogEx.InitializeComponent(). Note this will revert the dialog to XP style Open dialog, but otherwise it won't work.
 
To be compatible with x64, the NMHDR struct must be defined as:
 
[StructLayout(LayoutKind.Sequential)]
public struct NMHDR
{
public IntPtr hwndFrom;
public IntPtr idFrom;
public uint code;
}
 
The system C header file incorrectly defines idFrom as a UINT.
GeneralRe: A couple Fixes for Vista and x64memberCheeso1 Jun '09 - 14:13 
Thanks for this fix. When I ran the code unchanged on Vista, I didn't see the preview box. Adding in the "AutoUpgradeEnabled = false" allowed the preview to show.
 
(I have Vista with .NET 3.5. )
GeneralRe: A couple Fixes for Vista and x64memberRealityIsCrewel10 Sep '09 - 15:29 
The ViewMode Enum may appear to work on 32 bit Vista, but Vista uses a different Enum for the ViewModes, I guess mainly because Vista introduced several new ViewModes.
 
The existing Enum values are correct for: Windows XP, and Windows Server 2003 32/64 bit (probably windows 2000 too.)
 
The following new Enum Values work on: Windows Vista 32/64 bit, and Windows 7 32/64 bit (probably Windows Server 2008 too.)
 
ViewMode = Value (HEX)
Extra Large Icons = 28749 (0x704D)
Large Icons = 28751 (0x704F)
Medium Icons = 28750 (0x704E)
Small Icons = 28752 (0x7050)
List = 28753 (0x7051)
Details = 28747 (0x704B)
Tiles = 28748 (0x704C)
QuestionStartLocation Bottom and alignmentmemberMassalla19 Feb '08 - 21:24 
Hi,
 
first of all: Excellent solution. That makes it real easy to extend these dialog.
 
I probably missed it, but is there a way to automatically align newly added controls in StartLocation Bottom-mode with the standard controls?
 
I simply added a label and a textbox, but the controls showed up all the way to the left of the dialog. It's no problem to add some extra space and simply move these controls on the exteded UserControl, but I thought, there would be a better way.
 
Regards,
Sascha
Questionhow to open exe of notepadmembermrd12 Feb '08 - 21:55 
hi
friends do u have any idea of how to open exe of notepad in c#
i have used openfilediaolog box ,i can get the file path ,but when we
click on open button of openfiledialog box file does not get open.
does anybody can help me to solve this problem
 
Thank and Regards
Mukesh.

GeneralVS2003memberdocrob112 Feb '08 - 7:19 
Any tips on how to convert the project to VS 2003 (which is the only version I have)? It's a great solution, and I'm sure it will be helpful.
GeneralCatch WM_SIZEmemberRobKirk18 Dec '07 - 3:17 
How you suggest to catch WM_SIZE event of the main dialog window to be able to resize the custom panel?
GeneralAlignment messed up with .NET 3.5memberTibord4 Dec '07 - 23:01 
Because they've changed the OpenFileDialog's layout in .NET 3.5 the preview window is pushed to the side and the labels scattered all over. this happens when you run it on a system that has .NET 3.5 installed.
 
is there some sort of a workaround to make it work for both pre .NET 3.5 users and for .NET 3.5 users
 
Thanks in advance
 
Tibor
GeneralSorting order problem in multiselectmemberigor_ilnitsky20 Oct '07 - 2:58 
I want to select several pictures (multiselect). The problem is when i select several pictures I can not manager their order: if i select, for example, 5 pictures with the following names:
 
Picture_1 Picture_3 Picture_5 picture_4 picture_2
 
the my_diag.OpenFileDialog.FileNames returns an array of strings:
 
c:\Picture_1
c:\Picture_2
c:\Picture_3
c:\Picture_4
c:\Picture_5
 
or in some other sorting order while i want the first file name to correspond the picture i have selected first, the second - which was selected the second and so forth.
 
For example when I select 5 somebodies photos from my photocamera, I want it to be a portrait photo(with i select first of all), but in the opposite to my expactation i see the person's back Smile | :)
 
Can somebody suggest how can I handle this problem?
 
Strassebahn
GeneralShowDialog expectationsmemberGrenMeera12 Oct '07 - 8:05 
Just wanted to offer a suggestion for the ShowDialog function in the OpenFileDialogEx class.
 
I was expecting a similar functionality to the standard OpenFileDialog when calling ShowDialog with no parameters, which is that the dialog opens with the currently active window as it's owner. It wouldn't be an issue except that when the dialog closed, I was getting focus to another random window instead of the form that was active previously.
 
To make this run smoother and similarly to the standard OpenFileDialog, try this instead:
 
public DialogResult ShowDialog()
{
return ShowDialog(Form.ActiveForm);
}

GeneralRe: ShowDialog expectationsmemberigor_ilnitsky20 Oct '07 - 3:03 
use "this" keyword
 

FormOpenFileDialog frm;
frm.ShowDialog(this);
GeneralUnfortunately will not work through COM interopmemberJoe H-4211 Oct '07 - 6:57 
I really like this tool, it works great. I ran into a problem, though, when I tried to have the dialog called from a COM application. Numerous constants are defined as long or as uint, because COM applications do not know what to do with these types an interop cannot be created. I changed my application so that the dialog was not actually in the assembly that COM called, but this trick was not successful.
 
If you have an idea how I could modify this to get it to work with COM it would be great.
 
-joe

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130516.1 | Last Updated 14 Nov 2006
Article Copyright 2006 by CastorTiu
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid