[RESOLVED] opening Jpg or any picture file in windows photo viewer from within my app-VBForums
Results 1 to 11 of 11

Thread: [RESOLVED] opening Jpg or any picture file in windows photo viewer from within my app

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2015
    Posts
    30

    Resolved [RESOLVED] opening Jpg or any picture file in windows photo viewer from within my app

    Hi All
    I am developing an app that can list a lot of folders in my hard drive (each folder contains a picture file) and I want my app can open the picture in folders by windows photo viewer when I click the folder name in combobox.
    I tried the code below ,but this just open the windows explore with picture file in it that it is not focused.

    Code:
    Private Sub C_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles C.KeyPress
    
            Select Case e.KeyChar
                Case Chr(Keys.Enter)
                    Process.Start("j:\bimaran\" & C.SelectedItem)
            End Select
        End Sub
    that is a dead end for me so any help appreciated.
    thanks
    bayat

  2. #2
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    982

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2015
    Posts
    30

    Re: opening Jpg or any picture file in windows photo viewer from within my app


  4. #4
    Addicted Member
    Join Date
    Nov 2017
    Posts
    205

    Re: opening Jpg or any picture file in windows photo viewer from within my app

    Think this through. You say your ComboBox contains folder names. So C.SelectedItem will return a folder name. So

    Code:
    "j:\bimaran\" & C.SelectedItem
    will contain a path to a folder, such as "j:\bimaran\OneOfYourFolderNames"

    You are then passing that path to Process.Start. The result you describe of Windows Explorer opening that folder is exactly what I would expect to happen. You aren't referencing Windows Photo Viewer, or an image file name.

    Now, the links jdc2000 posted are absolutely relevant to your question. The fact that you dismissed them is troubling, since it suggests that you might not have fully thought through the specifics of what you are trying to accomplish (hint: Step 1 is to write code that will simply open Windows Photo Viewer. Step 2 is to modify that code to pass the full path, including filename, of the image that you want opened in Windows Photo Viewer) In any event, I'm unable to assist further with this, so good luck.
    Last edited by OptionBase1; Jan 31st, 2018 at 01:00 PM.

  5. #5
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    982

    Re: opening Jpg or any picture file in windows photo viewer from within my app

    Dim strCommand As String

    strCommand = "rundll32" & Chr$(34) & "C:\Program Files\Windows Photo Viewer\PhotoViewer.dll " & Chr$(34) & Chr$(34) & "j:\bimaran\" & C.SelectedItem & Chr$(34)

    Process.Start(strCommand)

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Aug 2015
    Posts
    30

    Re: opening Jpg or any picture file in windows photo viewer from within my app

    Quote Originally Posted by jdc2000 View Post
    Dim strCommand As String

    strCommand = "rundll32" & Chr$(34) & "C:\Program Files\Windows Photo Viewer\PhotoViewer.dll " & Chr$(34) & Chr$(34) & "j:\bimaran\" & C.SelectedItem & Chr$(34)

    Process.Start(strCommand)
    thank you for your code , each folder has a picture file with a different name , can I use ? or * to address each picture file I want to open with rundll32 or not. how?

  7. #7
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    982

    Re: [RESOLVED] opening Jpg or any picture file in windows photo viewer from within my

    You would need to get the full file name to open it. This can be done using the Dir statement. See the link below for an idea on how to use it.

    http://www.vbforums.com/showthread.p...-just-partname

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Aug 2015
    Posts
    30

    Re: [RESOLVED] opening Jpg or any picture file in windows photo viewer from within my

    Thanks again

  9. #9
    Hyperactive Member Arve K.'s Avatar
    Join Date
    Sep 2008
    Location
    Kyrksæterøra, Norway
    Posts
    439

    Re: [RESOLVED] opening Jpg or any picture file in windows photo viewer from within my

    Surely there is a more .Net-ish way to do that instead of using Dir
    Arve K.

    Please mark your thread as resolved and add reputation to those who helped you solve your problem
    Disclaimer: I am not a professional programmer

  10. #10
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    982

    Re: [RESOLVED] opening Jpg or any picture file in windows photo viewer from within my


  11. #11

    Thread Starter
    Junior Member
    Join Date
    Aug 2015
    Posts
    30

    Re: [RESOLVED] opening Jpg or any picture file in windows photo viewer from within my

    Quote Originally Posted by Arve K. View Post
    Surely there is a more .Net-ish way to do that instead of using Dir
    Which one do you mean?

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