1 Attachment(s)
[RESOLVED] [2005] Custom OpenFileDialog problem
Attached is a project to illustrate my issue.
There is a VB.NET windows forms app, and a C# Class Library (so you need both to run this)
The C# library is a wrapper to using the OpenFileDialog control via unmanaged code in order to customize the OpenFileDialog. In the example, the dialog is looking for text files, and when you select a textfile, the openfiledialog will display a preview of it right in the dialog. You can apply this to anything really, like showing a picture preview when opening picture files etc...
So anyway, it works fine and all, however I have 2 issues with it:
1) It does not open as a dialog, but rather just as a standard window. It should open modal like the .NET openfiledialog (or the VB6 one for that matter)
2) It puts itself in the taskbar when its opened, which it shouldn't do. This issue may actually resolve itself if I can get it opening as a dialog (#1)
Any thoughts? I looked through the help files on MSDN for this structure, but I did not see any flags indicating a way to set it modal or not.
Re: [RESOLVED] [2005] Custom OpenFileDialog problem
I ended up resolving this.
Basically what I found was that the OFD structure was not having its hwndOwner value set properly.
This was due to the fact that the C# code was setting up the structure before assiging the hwndOwner of the parent form to the custom class.
I reworked the code just a little bit and it solved #1, which in turn, solved #2
Re: [RESOLVED] [2005] Custom OpenFileDialog problem
I had an email question from T120 about how to hide the readonly checkbox in the custom dialog. I figured I would post the answer here incase anyone else could benefit.
The line of code in the C# project where flags for the custom openfiledialog are set looks like this
Code:
_ofn.Flags = OpenFileNameFlags.EnableHook | OpenFileNameFlags.EnableTemplateHandle | OpenFileNameFlags.EnableSizing | OpenFileNameFlags.Explorer;
These flags make up how the OFD will behave. You can specify an additional flag to hide the readonly checkbox like this:
Code:
_ofn.Flags = OpenFileNameFlags.EnableHook | OpenFileNameFlags.EnableTemplateHandle | OpenFileNameFlags.EnableSizing | OpenFileNameFlags.Explorer | OpenFileNameFlags.HideReadOnly;