dcsimg
Results 1 to 8 of 8

Thread: [RESOLVED] Image Viewer Application

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2016
    Posts
    51

    Resolved [RESOLVED] Image Viewer Application

    How can I do a program that shows the image I open with. I know how to make a program, run it and make a button to open an image but I'm wondering if there's a way to open a image choosing my program and my program reads the image I clicked.
    I wanna be able to right click an image, select open with and open with my program, I just don't know how to make my program to open that especific image...
    When someone talks sh*t about me:


    Are you ta'king to me?..
    Are you ta'king to the special one?..
    Are you ta'king to the special one?..
    There's nobody else here,
    you must be talking to the special one!
    Are you ta'king to me?
    Are are, are you ta'king to me?


  2. #2
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    457

    Re: Image Viewer Application

    This exact question was asked like a week ago. It has to do with file associations. Search and you should be able to find it.

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2016
    Posts
    51

    Re: Image Viewer Application

    Can you please link me to the threat?
    When someone talks sh*t about me:


    Are you ta'king to me?..
    Are you ta'king to the special one?..
    Are you ta'king to the special one?..
    There's nobody else here,
    you must be talking to the special one!
    Are you ta'king to me?
    Are are, are you ta'king to me?


  4. #4

    Thread Starter
    Member
    Join Date
    Jan 2016
    Posts
    51

    Re: Image Viewer Application

    I tried to find a post about this on the last 10 days and I didn't find any. I searched about file associations but there's nothing about images and I'm not even sure if that's what I want.
    Summing up, I wanna make a program in Windows Forms Application where I have a Picture Box on the Form and save the program, then, with the program closed I wanna go to my desktop (for example) and right click a image and do open with and choose my program, witch will automaticaly open the form with the image on the picture box... (only need the code, or how it's done to make on load event, picturebox1= image that i opened)
    When someone talks sh*t about me:


    Are you ta'king to me?..
    Are you ta'king to the special one?..
    Are you ta'king to the special one?..
    There's nobody else here,
    you must be talking to the special one!
    Are you ta'king to me?
    Are are, are you ta'king to me?


  5. #5
    PowerPoster SJWhiteley's Avatar
    Join Date
    Feb 2009
    Location
    South of the Mason-Dixon Line
    Posts
    2,256

    Re: Image Viewer Application

    When you select 'open with...' on a file and browse for your executable, the file name will passed to your application as a command line. You can look at the command line parameters and act accordingly (i.e. open the image and put in the picture box).
    "Ok, my response to that is pending a Google search" - Bucky Katt.
    "There are two types of people in the world: Those who can extrapolate from incomplete data sets." - Unk.
    "Before you can 'think outside the box' you need to understand where the box is."

  6. #6

    Thread Starter
    Member
    Join Date
    Jan 2016
    Posts
    51

    Re: Image Viewer Application

    But what's the command line? And most importantly, how can I executate my program before starting it with the image, do I do a catch, so that if the command is not sending, there's no image... Like, I need to executate the program before I try it opening it with the image.
    EDIT: I only need the name of what I need to search to find examples of the using of that command, because I really don't know how to search about that (and I tried).
    When someone talks sh*t about me:


    Are you ta'king to me?..
    Are you ta'king to the special one?..
    Are you ta'king to the special one?..
    There's nobody else here,
    you must be talking to the special one!
    Are you ta'king to me?
    Are are, are you ta'king to me?


  7. #7
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    5,202

    Re: Image Viewer Application

    Try
    Dim myfile As String = My.Application.CommandLineArgs(0)

  8. #8

    Thread Starter
    Member
    Join Date
    Jan 2016
    Posts
    51

    Re: Image Viewer Application

    It worked!
    I used the code like this...
    Code:
    Public Class Form1
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Try
                PictureBox1.Image = Image.FromFile(My.Application.CommandLineArgs(0))
            Catch ex As Exception
                PictureBox1.Image = Nothing
            End Try
        End Sub
    End Class
    ...so that I could compile it without the image and then tried to open a image with it and it's exactly as I wanted.

    Thanks Passel, when you answer, you know it. Your the best
    When someone talks sh*t about me:


    Are you ta'king to me?..
    Are you ta'king to the special one?..
    Are you ta'king to the special one?..
    There's nobody else here,
    you must be talking to the special one!
    Are you ta'king to me?
    Are are, are you ta'king to me?


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