Results 1 to 11 of 11

Thread: [RESOLVED] OpenFileDialog, View Menu, Thumbnails [2003]

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    675

    Resolved [RESOLVED] OpenFileDialog, View Menu, Thumbnails [2003]

    Hello,
    I am using an OpenFileDialog to allow the user to pick the logo of their company. It works just fine, but I would like to set the View Menu option to Thumbnail instead of the users default (which for me is List). Does anyone know how to do this? I tried using intellisense to see what I could find to no avail, and I have severely limited internet access here.
    Thanks
    VB.Net 2008
    .Net Framework 2.0

    "Must you breathe? 'Cause I need heaven..."

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: OpenFileDialog, View Menu, Thumbnails [2003]

    I might have a solution for you.. need to test it

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    675

    Re: OpenFileDialog, View Menu, Thumbnails [2003]

    OK, thanks. Let me know. Also, it isn't that big of a deal. I just thought one would be able to easily set that.
    VB.Net 2008
    .Net Framework 2.0

    "Must you breathe? 'Cause I need heaven..."

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: OpenFileDialog, View Menu, Thumbnails [2003]

    It is actually really hard to set

  5. #5
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: OpenFileDialog, View Menu, Thumbnails [2003]

    Ok here you go.

    Its commented pretty well so you can see whats going on.

    Works like a charm on XP, Haven't tested on any other OS.
    Attached Files Attached Files

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    675

    Re: OpenFileDialog, View Menu, Thumbnails [2003]

    Wow, what a complete and total pain. I guess they figured no one would want to be able to set that very easily. Thanks a lot for the code. I know nothing of these things, so I am going to use this example to learn more about this. Thanks again.
    VB.Net 2008
    .Net Framework 2.0

    "Must you breathe? 'Cause I need heaven..."

  7. #7
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [RESOLVED] OpenFileDialog, View Menu, Thumbnails [2003]

    I did a bunch of google searches and compiled a few bits of knowledge from this article and that article to find what I needed to make it work.

    Once you get down to it, its actually pretty simple.

    The basic problem is the only way to show an openfiledialog, is to call its showdialog method, but once you do that, your program's code is haulted until the dialog closes. This makes it hard to get the window handle of the dialog, because its not created until you call the ShowDialog method, so you can send a message to it to change the view.

    This is why you have to filter out messages that are sent to the main form, that are basically saying "a dialog opened, here is its handle" so you grab that, and use it to send your messages to the dialog.

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    675

    Re: [RESOLVED] OpenFileDialog, View Menu, Thumbnails [2003]

    This is why you have to filter out messages that are sent to the main form, that are basically saying "a dialog opened, here is its handle" so you grab that, and use it to send your messages to the dialog.
    Is that why I can see it flash a list view for a moment before switching to the chosen view?
    VB.Net 2008
    .Net Framework 2.0

    "Must you breathe? 'Cause I need heaven..."

  9. #9
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [RESOLVED] OpenFileDialog, View Menu, Thumbnails [2003]

    Probably, I actually didn't see any flash on my box, but I am running a pretty fast machine here.

    I think its actually possible to capture a different message, instead of the WM_ENTERIDLE, there are other messages that fire when a Dialog is opened, perhaps the WM_ACTIVATE, however I figured that fires well more often than WM_ENTERIDLE, although I suppose you could set a boolean value to true right before you call ShowDialog() and set it to false after the dialog closes. Then check to see if the boolean is true before even bothering to filter the wndproc message. That way your app won't spend time trying to look for the dialog when its not open, but the main form gets a windowsmessage that you filter on. If you want I can update the code later to reflect this.

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    675

    Re: [RESOLVED] OpenFileDialog, View Menu, Thumbnails [2003]

    SendMessage(LvwHandle, WM_COMMAND, DirectCast([Enum].GetValues(GetType(DialogViewType)).GetValue(3), DialogViewType), IntPtr.Zero)
    I had to add this
    Code:
                            If Me.MessageSent = False Then
                                SendMessage(LvwHandle, WM_COMMAND, DirectCast([Enum].GetValues(GetType(DialogViewType)).GetValue(3), DialogViewType), IntPtr.Zero)
                                Me.MessageSent = True
                            End If
    so that it would only send the message once. Without it the mouse was flickering, celltips were sporatic, and I was a little leary of the whole thing. Like I said, I have no idea how this stuff works, but it works great now.

    Oh, yeah. When I was testing I found that if my OpenFileDialog has no Title, this won't work. It doesn't have to have any specific title, just anything will do. Thanks again.

    P.S. Only sending the message once also allows the user to override this setting and view the folder the way they want to.
    Last edited by 18experience; Feb 28th, 2007 at 01:48 PM.
    VB.Net 2008
    .Net Framework 2.0

    "Must you breathe? 'Cause I need heaven..."

  11. #11
    New Member
    Join Date
    Oct 2014
    Posts
    1

    Re: [RESOLVED] OpenFileDialog, View Menu, Thumbnails [2003]

    Hello,

    This does not work on windows 7/ windows 8 machine, can you please suggest a work around. Thanks in advance.

Posting Permissions

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



Click Here to Expand Forum to Full Width