OpenFileDialog Component with preselect Thumbnails view, Details view etc.-VBForums
Results 1 to 11 of 11

Thread: OpenFileDialog Component with preselect Thumbnails view, Details view etc.

  1. #1

    Thread Starter
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    2,467

    OpenFileDialog Component with preselect Thumbnails view, Details view etc.

    An enhanced OpenFileDialog you can put into your Toolbox
    If you're a graphics nut like me, the standard OpenFileDialog can be pretty irritating because it always opens in List view, when really you want Thumbnails view. So I wanted to make an OpenFileDialog where you can set the opening view to Thumbnails, Icons, Details or whatever, instead of having to change it every time you open it.

    How it was made
    It isn't possible to subclass the standard OpenFileDialog because it's NonInheritable. But I found an article on the Code Project where the author, Robert Rohde, had a clever idea. He found a way to intercept a message that the dialog passes to its owner form, and used information form that message to set the view mode. The snag is that you had to code everything on the Form itself, because the message concerned, WM_ENTERIDLE, is only detected by the WndProc sub on the form itself (and not by an IMessageFilter, for instance). This seemed rule out putting the method into a simple component you could just drag onto your form. But I found a way to do it.

    My solution consists of two main parts. Firstly, there is a Class which inherits from IComponent. The component exposes its own version of the OpenFileDialog properties which you can set in the Forms Designer. It has an additional DefaultView property, which you use to set the opening view of the dialog. Like the original OpenFileDialog component, it also has ShowDialog method which returns a DialogResult.

    The OFDForm is the second part. It's a Form which is called from the component's ShowDialog and it does most of the work. It has its own copy of the standard OpenFileDialog, which it displays, collects the results and then closes. At the same time, the form has a WndProc sub which picks up the WM_ENTERIDLE message and uses it to set the view to Thumbnails, Icons or whatever you chose using SendMessage. The OFD form is itself invisible: all you see is the Dialog. I made the form's Opacity = 0% and its size to 1*1 pixels because just hiding it wouldn't work (WndProc wouldn't fire).

    The attachments contain the above two parts plus a toolbox icon.

    How to build the project in Visual Studio
    Use this if you want to study the code or modify it. I'll see if I can post the DLL to the Utilities forum so you can skip these steps.

    1. Download the attachments below to a convenient folder.
    2. Start a new Control Library project in Visual Studio.
    3. Right-click on the project name in Solution Explorer, and select Add Existing Item ... Use this to add all the downloaded items.
    4. Delete the default empty class.
    5. Right-click on the project name in Solution Explorer and select Properties.
    5a. On the Compile tab, browse for a folder where you want to store the DLL. That's where it will live if you put it in the Toolbox.
    5b. On the References tab, make sure you have references to System.Drawing and System.Windows.Forms.
    6. Right click on the bitmap (OpenFileDialogEx.bmpP in Solution Explorer. Check that its Build Action is set to Embedded Resource.
    7. Build the Solution.

    How to add the component to your toolbox
    1. Open any Windows Forms project and view the Form.
    2. Open the Toolbox and right click wherever you want to put the new comonent. Select Choose Items ...
    3. Click the Browse button and browse to the folder where you have stored the DLL (step 5b above). Select it. The OpenFileDialogEx component should now appear in your Toolbox with the following icon: Name:  OpenFileDialogEx.bmp
Views: 2262
Size:  822 Bytes.

    Now you can drag the component onto a form and set its properties in the same way as a normal OpenFileDialog. Except it now has a new DefaultView property. Alternatively you could use it in code like this, for example:
    Code:
       Using ofdx As New BBComponents.OpenFileDialogEx
                If ofdx.ShowDialog = DialogResult.OK Then
                    zoomablepicturebox1.Image = Image.FromFile(ofdx.FileName)
                End If
            End Using
    Comments and suggestions gladly received. BB
    Attached Files Attached Files

  2. #2
    vb Coda .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    19,278

    Re: File Dialog component with preselect Thumbnails view, Details view etc.)

    Quote Originally Posted by boops boops View Post
    It isn't possible to subclass the standard OpenFileDialog because it's NonInheritable.
    you can get around that problem with NativeWindow:

    Customizing OpenFileDialog in .NET

  3. #3

    Thread Starter
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    2,467

    Re: File Dialog component with preselect Thumbnails view, Details view etc.)

    Quote Originally Posted by .paul. View Post
    you can get around that problem with NativeWindow:

    Customizing OpenFileDialog in .NET
    Yes. And I got around it using a Windows Form. Please see the complete post above, I accidentally submitted it while I was just starting.

  4. #4

    Thread Starter
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    2,467

    Re: OpenFileDialog Component with preselect Thumbnails view, Details view etc.

    Me again Paul, it's clear the article you linked to is a more sophisticated approach than mine. It's nice having a preview box, and who could complain about the lovely Sandra?

    Perhaps I could provide a preview box using my presently "hidden" form. The purpose of the Native Window seems to be to provide a way of passing properties from the dialog to the form; I'll have to study that a bit.

    Meanwhile, I'm not dissatisfied with my own component, even if it is a case of reinventing the wheel. I can drag the component from the Toolbox and use it exactly like a standard OpenFileDialong, but also rely on it opening in Thumbnails view. That's what I wanted. And it's pretty "lightweight" at just over 100 lines of code.

    I should point out that it I have only tested the component on WinXPsp3 and that the Enum values may have to be different for Vista+. I found these values which could be added to the present Enum:

    Code:
        Extra Large Icons = &H704D
        Large Icons = &H704F
        Medium Icons = &H704E
        Small Icons = &H7050
        List = &H7051
        Details = &H704B]
        Tiles = &H704C
    I dont know if Thumbnails remains unchanged at &H702D. I'd be interested to hear if anyone has the time to try these options out.

    Finally, it seems the icon wasn't attached as intended. I'll try adding it to this message. Ah, there it is in preview. In Firefox you can right-click on it and choose Save As; no doubt other browsers offer something similar. Make sure the name of the file is the same as the Component Class + .bmp: OpenFileDialogEx.bmp. Also make sure you add it to the build project as an Embedded Resource (see post #1). Otherwise the icon won't appear in the toolbox, just a boring cogwheel.

    BB
    Attached Images Attached Images  

  5. #5
    vb Coda .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    19,278

    Re: OpenFileDialog Component with preselect Thumbnails view, Details view etc.

    100 lines is still impressive if not sophisticated. i haven't had a look at it but i'll remember it when i need a custom ofd

  6. #6
    New Member LDeeJay's Avatar
    Join Date
    Feb 2002
    Location
    UK
    Posts
    7

    Re: OpenFileDialog Component with preselect Thumbnails view, Details view etc.

    You seem to have all the tools I'd like to use
    For this final 'nice to have' feature I'd like the thumbnail view as default in my app. So I followed the instructions and immediately after loading the .vb's I get an error message:
    Quote Originally Posted by My computer
    Error 1 'DefaultView' is not a member of 'WindowsControlLibrary1.OpenFileDialogEx'.
    Both files give me errors but I have to start somewhere. Seems my experience with VB.net 2008 is not enough to solve it so any help is appreciated.

    ps. If you have a readymade .dll I can use, maybe I can skip all the bughunting?

  7. #7

    Thread Starter
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    2,467

    Re: OpenFileDialog Component with preselect Thumbnails view, Details view etc.

    I hadn't looked at this code since a year ago, since there were no reactions except from Paul who pointed out that there were more advanced equivalents elsewhere. So it took some puzzling to see what was going wrong.

    In fact it's simple. I coded it in VisualBasic 2010 (Express). The only thing that won't compile properly in 2008 is the properties, because 2010 introduced a very convenient abbreviated syntax for standard properties.

    For example, in VS 2010:
    Code:
    	Public Property Filter As String
    is an abbreviation for:
    Code:
    	Private _Filter As String
    	Public Property Filter As String
    		Get
    			Return _Filter
    		End Get
    		Set(value As String)
    			_Filter = value
    		End Set
    	End Property
    in 2008 and earlier.

    If you want to use this component, you should replace all the single-line properties in OpenFileDialogEx.vb by full versions as above. Then it should build correctly in 2008.

    BB

  8. #8
    New Member LDeeJay's Avatar
    Join Date
    Feb 2002
    Location
    UK
    Posts
    7

    Re: OpenFileDialog Component with preselect Thumbnails view, Details view etc.

    Thank you, thank you, thank you.

    It appeared to be my knowledge of .NET 2010 (non-existent until now) . I can't upgrade to that since it doesn't support .NET Compact Framework (which I use it mainly for).

    Here's one happy chap who can now speed up the production-process with a fantastic application that can browse for images with a preview, zoom, pan, crop and combine them into one and automatically upload them to a specified server.

    A few hours of intensive labour and the help from some fantastic .NET guru's a lot of time will be saved it the future.

    Cheers!

    Léon

    (btw.. did I thank you already? )

  9. #9
    New Member
    Join Date
    Feb 2012
    Posts
    2

    Re: OpenFileDialog Component with preselect Thumbnails view, Details view etc.

    Your Code has me inspired. I have completed your work with Events and all other propertys. And wonder it works now under Windows 7 without changes in WndProc and Interop. Its the old dialog view, but it works.



    I have uploaded your old reworked code to a German Projectsite.

    VB-Paradise

  10. #10
    New Member
    Join Date
    Feb 2012
    Posts
    2

    Re: OpenFileDialog Component with preselect Thumbnails view, Details view etc.

    vb Code:
    1. Imports System.Windows.Forms
    2. Imports System.Drawing
    3. Imports System.ComponentModel
    4.  
    5. '<ToolboxBitmap("OpenFileDialogEx.bmp")> _
    6. Public Class OpenFileDialogEx
    7.     Inherits Component
    8.  
    9.     ''' <summary>
    10.     ''' Der RückgabeWert des Dialogs
    11.     ''' </summary>
    12.     ''' <remarks></remarks>
    13.     Protected Friend Result As DialogResult
    14.  
    15.  
    16.     ''' <summary>
    17.     ''' Einige Punkte arbeiten nur unter Vista/Windows 7
    18.     ''' </summary>
    19.     ''' <remarks></remarks>
    20.     Public Enum Views
    21.         Icons = &H7029
    22.         List = &H702B
    23.         Details = &H702C
    24.         Tiles = &H702E
    25.         Thumbnails = &H702D
    26.         SmallIcons = &H7050 'Windows 7
    27.         MediumIcons = &H704E 'Windows 7
    28.         LargeIcons = &H704F 'Windows 7
    29.         ExtraLargeIcons = &H704D 'Windows 7
    30.         'List = &H7051 'Windows 7
    31.         'Details = &H704B 'Windows 7
    32.         'Tiles = &H704C 'Windows 7
    33.     End Enum
    34.  
    35. #Region "Sonstiges"
    36.  
    37.     ''' <summary>
    38.     ''' Ruft einen Wert ab, der angibt, ob diese System.Windows.Forms.FileDialog-Instanz automatisch Darstellung und Verhalten aktualisieren soll, wenn Sie unter Windows Vista ausgeführt wird, oder legt diesen Wert fest.
    39.     ''' </summary>
    40.     ''' <value></value>
    41.     ''' <returns></returns>
    42.     ''' <remarks>Wenn dieses Property nicht gesetzt ist, egal ob true oder false, dann funktioniert es nicht unter Vista / Windows7</remarks>
    43.     <Description("Ruft einen Wert ab, der angibt, ob diese System.Windows.Forms.FileDialog-Instanz automatisch Darstellung und Verhalten aktualisieren soll, wenn Sie unter Windows Vista ausgeführt wird, oder legt diesen Wert fest."), _
    44.      DefaultValue(True)> _
    45.     Public Property AutoUpgradeEnabled As Boolean
    46.  
    47. #End Region
    48.  
    49. #Region "Verhalten"
    50.  
    51.     <Description("Ruft einen Wert ab, der angibt, ob einem Dateinamen im Dialogfeld automatisch eine Erweiterung hinzugefügt wird, wenn der Benutzer keine Erweiterung angibt, oder legt diesen fest."), _
    52.      DefaultValue(True)> _
    53.     Public Property AddExtension As Boolean
    54.  
    55.     <Description("Gibt an, ob eine Warnung angezeigt wird, wenn der Benutzer eine Datei anklickt, die nicht vorhanden ist."), _
    56.      DefaultValue(True)> _
    57.     Public Property CheckFileExist As Boolean
    58.  
    59.     <Description("Überprüft ob der angegebene Pfad vorhanden ist bevor vom Dialog zurückgekehrt wird."), _
    60.      DefaultValue(True)> _
    61.     Public Property CheckPathExist As Boolean
    62.  
    63.     <Description("Die Standartdateierweiterung. Wenn der Benutzer einen Dateinamen eingibt wird diese Erweiterung an die Datei angehängt sofern noch keine angegeben wurde."), _
    64.      DefaultValue("")> _
    65.     Public Property DefaultExt As String
    66.  
    67.     <Description("Ruft einen Wert ab, der angibt, ob das Dialogfeld den Speicherort der Datei, auf die die Verknüpfung verweist, oder den Speicherort der Verknüpfung (.lnk) zurückgibt, oder legt diesen fest."), _
    68.      DefaultValue(True)> _
    69.     Public Property DereferenceLinks As Boolean
    70.  
    71.     <Description("Steuert, ob mehrere Dateien im Dialogfeld ausgewählt werden können."), _
    72.      DefaultValue(False)> _
    73.     Public Property Multiselect As Boolean
    74.  
    75.     <Description("Der Zustand des schreibgeschützten Kontrollkästchens im Dialog."), _
    76.      DefaultValue(False)> _
    77.     Public Property ReadOnlyChecked As Boolean
    78.  
    79.     <Description("Steuert, ob das Dialogfeld das aktuelle Verzeichnis vor dem Schließen wiederherstellt."), _
    80.      DefaultValue(False)> _
    81.     Public Property RestoreDirectory As Boolean
    82.  
    83.     <Description("Aktiviert die Schaltfläche Hilfe."), _
    84.      DefaultValue(False)> _
    85.     Public Property ShowHelp As Boolean
    86.  
    87.     <Description("Steuert, ob das schreibgeschützte Kästchen im Dialogfeld angezeigt wird."), _
    88.      DefaultValue(False)> _
    89.     Public Property ShowReadOnly As Boolean
    90.  
    91.     <Description("Ruft ab oder legt fest, ob das Dialogfeld Anzeige und Speichern von Dateien mit mehreren Dateinamenerweiterungen unterstützt."), _
    92.      DefaultValue(False)> _
    93.     Public Property SupportMultiDottedExtension As Boolean
    94.  
    95.     <Description("Ruft einen Wert ab, der angibt, ob das Dialogfeld nur gültige Win32-Dateinamen akzeptiert, oder legt diesen fest."), _
    96.      DefaultValue(True)> _
    97.     Public Property ValidateNames As Boolean
    98.  
    99.     <Description("Die im Dialogfeld angezeigten Filter z.B.: Images(*.jpg)|*.jpg|All Files|*.*"), _
    100.      DefaultValue("")> _
    101.     Public Property Filter As String
    102.  
    103.     <Description("Ruft den Index des derzeit im Dateidialogfeld ausgewählten Filters ab oder legt diesen fest."), _
    104.      DefaultValue(0)> _
    105.     Public Property FilterIndex As Integer
    106.  
    107.     <Description("Ruft eine Zeichenfolge ab, die den im Dateidialogfeld ausgewählten Dateinamen enthält, oder legt diese fest."), _
    108.      DefaultValue("")> _
    109.     Public Property FileName As String
    110.  
    111.     'Privat
    112.     Private _FileNames As String()
    113.  
    114.     <Description("Ruft die Dateinamen aller im Dialogfeld ausgewählten Dateien ab."), _
    115.      DefaultValue({""})> _
    116.     Public ReadOnly Property FileNames As String()
    117.         Get
    118.             If Multiselect Then
    119.                 Return _FileNames
    120.             Else
    121.                 Return {FileName}
    122.             End If
    123.         End Get
    124.     End Property
    125.  
    126.     <Description("Ruft das Ausgangsverzeichnis ab, das im Dateidialogfeld angezeigt wird, oder legt dieses fest."), _
    127.      DefaultValue("")> _
    128.     Public Property InitialDirectory As String
    129.  
    130.     <Description("Ruft den Titel des Dateidialogfelds ab oder legt diesen fest."), _
    131.      DefaultValue("Datei öffnen...")> _
    132.     Public Property Title As String
    133.  
    134.     <Description("Standartansicht der Anzeige im Dialogfeld."), _
    135.     DefaultValue(Views.Thumbnails)> _
    136.     Public Property DefaultView As Views = Views.Thumbnails
    137.  
    138. #End Region
    139.  
    140. #Region "Events"
    141.  
    142.     <Description("Tritt ein, wenn der Benutzer in einem Dateidialogfeld auf die Schaltfläche Öffnen oder Speichern klickt."), _
    143.      DefaultValue("")> _
    144.     Public Event FileOk(sender As System.Object, e As System.EventArgs)
    145.  
    146.     <Description("Tritt ein, wenn der Benutzer in einem Standarddialogfeld auf die Hilfeschaltfläche klickt."), _
    147.      DefaultValue("")> _
    148.     Public Event HelpRequest(sender As System.Object, e As System.EventArgs)
    149.  
    150. #End Region
    151.  
    152. #Region "Protected Friend HelperSubs"
    153.  
    154.     ''' <summary>
    155.     ''' Stellt eine Funktion bereit, um die schreibgeschützte Property FileNames zu füllen.
    156.     ''' </summary>
    157.     ''' <param name="values"></param>
    158.     ''' <remarks></remarks>
    159.     Protected Friend Sub SetFileNames(values As String())
    160.         _FileNames = values
    161.     End Sub
    162.  
    163.     ''' <summary>
    164.     ''' Auslösen des Events und durchreichen der Argumente
    165.     ''' </summary>
    166.     ''' <param name="sender"></param>
    167.     ''' <param name="e"></param>
    168.     ''' <remarks></remarks>
    169.     Protected Friend Sub RaiseFileOK(sender As System.Object, e As System.EventArgs)
    170.         RaiseEvent FileOk(sender, e)
    171.     End Sub
    172.  
    173.     ''' <summary>
    174.     ''' Auslösen des Events und durchreichen der Argumente
    175.     ''' </summary>
    176.     ''' <param name="sender"></param>
    177.     ''' <param name="e"></param>
    178.     ''' <remarks></remarks>
    179.     Protected Friend Sub RaiseHelpRequest(sender As System.Object, e As System.EventArgs)
    180.         RaiseEvent HelpRequest(sender, e)
    181.     End Sub
    182.  
    183. #End Region
    184.  
    185.     Public Function ShowDialog() As DialogResult
    186.         Using frm As New OFDForm(Me)
    187.             frm.ShowDialog()
    188.         End Using
    189.         Return Result
    190.     End Function
    191.  
    192.     Public Function ShowDialog(value As Windows.Forms.IWin32Window) As DialogResult
    193.         Using frm As New OFDForm(Me, value)
    194.             frm.ShowDialog()
    195.         End Using
    196.         Return Result
    197.     End Function
    198.  
    199. End Class

    vb Code:
    1. Imports System.Runtime.InteropServices
    2. Imports System.Windows.Forms
    3. Imports System.Drawing
    4. Imports System.ComponentModel
    5.  
    6. Friend Class OFDForm
    7.     Inherits Form
    8.  
    9.     Private _Owner As OpenFileDialogEx
    10.     Private View As OpenFileDialogEx.Views
    11.     Private Once As Boolean
    12.     Private RealOwner As Windows.Forms.IWin32Window
    13.     Private WithEvents ofd As New OpenFileDialog
    14.  
    15.  
    16.     ''' <summary>
    17.     ''' Initialisiert eine Form und macht sie komplett unsichtbar. Zudem wird die Kommunikation mit der Elternklasse hergestellt.
    18.     ''' </summary>
    19.     ''' <param name="owner"></param>
    20.     ''' <remarks></remarks>
    21.     Public Sub New(ByVal owner As OpenFileDialogEx)
    22.         _Owner = owner
    23.         View = _Owner.DefaultView
    24.         'Fenstertitel + Buttons abschalten
    25.         Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
    26.         'Unsichtbar
    27.         Me.Opacity = 0
    28.         'Aus der Taskbar bannen
    29.         Me.ShowInTaskbar = False
    30.         'Größe auf 1 Pixel reduizieren
    31.         Me.Size = New Size(1, 1)
    32.     End Sub
    33.  
    34.     ''' <summary>
    35.     ''' Initialisiert eine Form und macht sie komplett unsichtbar. Zudem wird die Kommunikation mit der Elternklasse hergestellt.
    36.     ''' </summary>
    37.     ''' <param name="owner"></param>
    38.     ''' <remarks></remarks>
    39.     Public Sub New(ByVal owner As OpenFileDialogEx, value As Windows.Forms.IWin32Window)
    40.         Me.New(owner)
    41.         RealOwner = value
    42.     End Sub
    43.  
    44.     ''' <summary>
    45.     ''' Reicht alles an einen Normalen OpenFileDialog weiter
    46.     ''' </summary>
    47.     ''' <param name="e"></param>
    48.     ''' <remarks></remarks>
    49.     Protected Overrides Sub OnShown(ByVal e As System.EventArgs)
    50.         Once = False
    51.         ofd.AddExtension = _Owner.AddExtension
    52.         ofd.AutoUpgradeEnabled = _Owner.AutoUpgradeEnabled
    53.         ofd.CheckFileExists = _Owner.CheckFileExist
    54.         ofd.CheckPathExists = _Owner.CheckPathExist
    55.         ofd.DefaultExt = _Owner.DefaultExt
    56.         ofd.DereferenceLinks = _Owner.DereferenceLinks
    57.         ofd.FileName = _Owner.FileName
    58.         ofd.Filter = _Owner.Filter
    59.         ofd.FilterIndex = _Owner.FilterIndex
    60.         ofd.InitialDirectory = _Owner.InitialDirectory
    61.         ofd.Multiselect = _Owner.Multiselect
    62.         ofd.ReadOnlyChecked = _Owner.ReadOnlyChecked
    63.         ofd.ShowHelp = _Owner.ShowHelp
    64.         ofd.ShowReadOnly = _Owner.ShowReadOnly
    65.         ofd.SupportMultiDottedExtensions = _Owner.SupportMultiDottedExtension
    66.         ofd.Title = _Owner.Title
    67.         ofd.ValidateNames = _Owner.ValidateNames
    68.         If IsNothing(RealOwner) Then
    69.             _Owner.Result = ofd.ShowDialog()
    70.         Else
    71.             _Owner.Result = ofd.ShowDialog(RealOwner)
    72.         End If
    73.         Me.Close()
    74.     End Sub
    75.  
    76. #Region "WndProc and Interop"
    77.     Private Const WM_ENTERIDLE = &H121
    78.     Private Const WM_COMMAND As Integer = &H111
    79.  
    80.     ''' <summary>
    81.     ''' Setzt die DefaultAnsicht wenn WM_ENTERIDLE erkannt wird.
    82.     ''' </summary>
    83.     ''' <param name="m"></param>
    84.     ''' <remarks></remarks>
    85.     Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
    86.         If Not Once AndAlso m.Msg = WM_ENTERIDLE Then
    87.             Dim dialogHandle As New IntPtr(m.LParam.ToInt32)
    88.             Dim listViewHandle As IntPtr = (FindWindowEx(dialogHandle, IntPtr.Zero, "SHELLDLL_DefView", String.Empty))
    89.             SendMessage(listViewHandle, WM_COMMAND, CType(View, IntPtr), IntPtr.Zero)
    90.             Once = True
    91.         End If
    92.         MyBase.WndProc(m)
    93.     End Sub
    94.  
    95.     'Interop Funktionen:
    96.     <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    97.     Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
    98.     End Function
    99.  
    100.     <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    101.     Private Shared Function FindWindowEx(ByVal parentHandle As IntPtr, ByVal childAfter As IntPtr, ByVal lclassName As String, ByVal windowTitle As String) As IntPtr
    102.     End Function
    103.  
    104.     <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    105.     Private Shared Function FindWindow(lpClassName As String, lpWindowName As String) As IntPtr
    106.     End Function
    107.  
    108. #End Region
    109.  
    110.  
    111. #Region "Events abfangen und durchreichen"
    112.  
    113.     Private Sub ofd_FileOk(sender As System.Object, e As System.ComponentModel.CancelEventArgs) Handles ofd.FileOk
    114.         If _Owner.Multiselect Then
    115.             'Setzen aller Filenames
    116.             _Owner.SetFileNames(ofd.FileNames)
    117.             'Keine Ahnung ob das jetzt hier so sein muss
    118.             _Owner.FileName = ofd.FileName
    119.         Else
    120.             'Setzen des Dateinames
    121.             _Owner.FileName = ofd.FileName
    122.         End If
    123.         'Event in der Elternklasse auslösen
    124.         _Owner.RaiseFileOK(sender, e)
    125.     End Sub
    126.  
    127.     Private Sub ofd_HelpRequest(sender As System.Object, e As System.EventArgs) Handles ofd.HelpRequest
    128.         'Event in der Elternklasse auslösen
    129.         _Owner.RaiseHelpRequest(sender, e)
    130.     End Sub
    131.  
    132. #End Region
    133. End Class

  11. #11

    Thread Starter
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    2,467

    Re: OpenFileDialog Component with preselect Thumbnails view, Details view etc.

    Hi Sio_x,

    Welcome to VB.Forums, and thank you for your kind words. You code looks like an interesting development on my initial efforts and I shall have to find time to give it the attention it deserves. I'm pleased you got it working on Win7 (which I don't have and I am not planning to get soon). I have not tried to develop my version further because it has been good enough for my own needs.

    I notice that you use a NativeWindow rather than a form to handle the Windows messages, as in the CodeProject design which Paul linked to in post #2. My own idea of using a form should make it easy to add an image preview box, although I still have to try it. Adding previews of other file types e.g. docs could be a lot of work though.

    BB

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.