468,738 Members | 1,752 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,738 developers. It's quick & easy.

Sending a jpg file to internet explorer from my VB program, How???

I have a VB program which loads a jpg file into a picture box. I want to be
able to d/click on the picture box and have Internet Explorer show this jpg
file.
What code do I put into the Image1_DblClick() function to show this pic in
IExplorer??
Help would be appreciated.

Thanks
Trevor.
Jul 17 '05 #1
9 3841
The easy way is to poke a browser onto your form, and on d/click, do a
BrowserName.Navigate2 "filename of picture".

The harder (and possibly more rewarding way) would be to
have your program throw together an HTML file with all all your
formatting (still using the source file), and do a ShellExecute on
the .htm file.

"The Roys" <tr*****@hotmail.com> wrote in message
news:7j*********************@news-server.bigpond.net.au...
I have a VB program which loads a jpg file into a picture box. I want to be able to d/click on the picture box and have Internet Explorer show this jpg file.
What code do I put into the Image1_DblClick() function to show this pic in
IExplorer??
Help would be appreciated.

Thanks
Trevor.

Jul 17 '05 #2
"CajunCoiler (http://www.cajuncoiler.tk)"
<po**********@totallyspamless.cox.net> wrote in message
news:hhZgb.63466$a16.50139@lakeread01...
The easy way is to poke a browser onto your form, and on d/click, do a
BrowserName.Navigate2 "filename of picture".

The harder (and possibly more rewarding way) would be to
have your program throw together an HTML file with all all your
formatting (still using the source file), and do a ShellExecute on
the .htm file.

"The Roys" <tr*****@hotmail.com> wrote in message
news:7j*********************@news-server.bigpond.net.au...
I have a VB program which loads a jpg file into a picture box. I want to

be
able to d/click on the picture box and have Internet Explorer show this

jpg
file.
What code do I put into the Image1_DblClick() function to show this pic in IExplorer??
Help would be appreciated.


I don't know the exact syntax, but can't he just use the shell command
calling the browser, and passing the images path as a parameter?
Adrian
Jul 17 '05 #3

"Adrian Parker" <no@addy.com> wrote in message
news:GJ*******************@news20.bellglobal.com.. .
"CajunCoiler (http://www.cajuncoiler.tk)"
<po**********@totallyspamless.cox.net> wrote in message
news:hhZgb.63466$a16.50139@lakeread01...
The easy way is to poke a browser onto your form, and on d/click, do a
BrowserName.Navigate2 "filename of picture".

The harder (and possibly more rewarding way) would be to
have your program throw together an HTML file with all all your
formatting (still using the source file), and do a ShellExecute on
the .htm file.

"The Roys" <tr*****@hotmail.com> wrote in message
news:7j*********************@news-server.bigpond.net.au...
I have a VB program which loads a jpg file into a picture box. I want
to
be
able to d/click on the picture box and have Internet Explorer show
this jpg
file.
What code do I put into the Image1_DblClick() function to show this
pic in IExplorer??
Help would be appreciated.


I don't know the exact syntax, but can't he just use the shell command
calling the browser, and passing the images path as a parameter?
Adrian


In theory, it can be done that way, but it's quite haphazard as final
distribution
goes. The end user may have more than one browser installed. The way I
described, whichever browser is set as the default, will take the image. If
shelling out to a specific browser is used, what happens if that browser is
uninstalled? Using the ShellExecute API eliminates the need. If you're not
sure how to impliment it, I have written a module that interfaces with your
code like: ShellExec.RunFile "picture.htm". I can send to you via e-mail.
c a j u n c o i l e r @ c o x . n e t
Jul 17 '05 #4
>>I don't know the exact syntax, but can't he just use the shell command
calling the browser, and passing the images path as a parameter?
Adrian

In theory, it can be done that way, but it's quite haphazard as final
distribution
goes. The end user may have more than one browser installed. The way I
described, whichever browser is set as the default, will take the image. If
shelling out to a specific browser is used, what happens if that browser is
uninstalled? Using the ShellExecute API eliminates the need. If you're not
sure how to impliment it, I have written a module that interfaces with your
code like: ShellExec.RunFile "picture.htm". I can send to you via e-mail.
c a j u n c o i l e r @ c o x . n e t


You rely on the association of .HTM, IMHO that's even worse...
What if you set the execution of .HTM to Notepad, like I did?
Then no image will be shown :D
I don't know the code either, but this should be used to be 'almost'
fail-proof: ShellExec.DefaultBrowser "picture.htm"
And then you can use: ShellExec.DefaultBrowser "picture.jpg"

Cookie

Jul 17 '05 #5

"Cookie" <co******@SPAMyucom.be> wrote in message
news:bm**********@news.worldonline.be...
I don't know the exact syntax, but can't he just use the shell command
calling the browser, and passing the images path as a parameter?
Adrian

In theory, it can be done that way, but it's quite haphazard as final
distribution
goes. The end user may have more than one browser installed. The way I
described, whichever browser is set as the default, will take the image. If shelling out to a specific browser is used, what happens if that browser is uninstalled? Using the ShellExecute API eliminates the need. If you're not sure how to impliment it, I have written a module that interfaces with your code like: ShellExec.RunFile "picture.htm". I can send to you via e-mail. c a j u n c o i l e r @ c o x . n e t


You rely on the association of .HTM, IMHO that's even worse...
What if you set the execution of .HTM to Notepad, like I did?
Then no image will be shown :D
I don't know the code either, but this should be used to be 'almost'
fail-proof: ShellExec.DefaultBrowser "picture.htm"
And then you can use: ShellExec.DefaultBrowser "picture.jpg"


Setting the OPEN method of .htm files to notepad was not a very
smart thing to do. If you're going to play around with associations,
it's a LOT better to create an EDIT option for that, instead.

That edit method should read...
"c:\windows\notepad.exe" "%1"
....do not use DDE

Jul 17 '05 #6
CajunCoiler (http://www.cajuncoiler.tk) wrote:
"Cookie" <co******@SPAMyucom.be> wrote in message
news:bm**********@news.worldonline.be...
I don't know the exact syntax, but can't he just use the shell command
calling the browser, and passing the images path as a parameter?
Adrian

In theory, it can be done that way, but it's quite haphazard as final
distribution
goes. The end user may have more than one browser installed. The way I
described, whichever browser is set as the default, will take the
image. If
shelling out to a specific browser is used, what happens if that browser
is
uninstalled? Using the ShellExecute API eliminates the need. If you're
not
sure how to impliment it, I have written a module that interfaces with
your
code like: ShellExec.RunFile "picture.htm". I can send to you via
e-mail.
c a j u n c o i l e r @ c o x . n e t


You rely on the association of .HTM, IMHO that's even worse...
What if you set the execution of .HTM to Notepad, like I did?
Then no image will be shown :D
I don't know the code either, but this should be used to be 'almost'
fail-proof: ShellExec.DefaultBrowser "picture.htm"
And then you can use: ShellExec.DefaultBrowser "picture.jpg"

Setting the OPEN method of .htm files to notepad was not a very
smart thing to do. If you're going to play around with associations,
it's a LOT better to create an EDIT option for that, instead.

That edit method should read...
"c:\windows\notepad.exe" "%1"
....do not use DDE


Excuse me, but I'm not 'playing' around... I know exactly what I'm doing...

I have an whole bunch of alternative associations.
I tweak the register a lot. I'm not an avarage user.

I edit html-pages a lot, that's why I changed the default association to
notepad. When I want to view an HTM in the browser I choose 'View'
(which I also created). BTW, links in documents etc. to html-pages still
works fine, cause they all use the method they should use. This means
not relying on the associations, but start the (defaul)browser with the
right parameters....

Cookie

Jul 17 '05 #7
On Wed, 8 Oct 2003 21:56:05 -0500, "CajunCoiler
\(http://www.cajuncoiler.tk\)" <po**********@totallyspamless.cox.net>
wrote:

<snip>
In theory, it can be done that way, but it's quite haphazard as final
distribution
goes. The end user may have more than one browser installed. The way I
described, whichever browser is set as the default, will take the image. If
shelling out to a specific browser is used, what happens if that browser is
uninstalled? Surely if that is the case then finding the default browser will fail
or come up with crud

My understanding is that ShellExecute calls FindExecutable
Using the ShellExecute API eliminates the need. If you're not
sure how to impliment it, I have written a module that interfaces with your
code like: ShellExec.RunFile "picture.htm".


There is a pretty good case for knowing that the 'viewer' one is going
to launch is _not_ the default viewer for the extension

There is nothing wrong with launching a browser to view a JPG
- but it is unlikely that ShellExecute would launch a browser ...

Jul 17 '05 #8
There is nothing wrong with launching a browser to view a JPG
- but it is unlikely that ShellExecute would launch a browser ...


If the file you're trying to execute is something browseable, such as a
website URL, or a mailto, then it would... that's how I put links on
forms.

Put this code in a module called "ShellExec" ...

Private Declare Function GetDesktopWindow Lib "user32" () As Long
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA"
(ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String,
ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As
Long) As Long
Public Const SW_SHOWNORMAL = 3
Public Function RunFile(ByVal strDocName As String) As Long
Dim Scr_hDC As Long
Dim lngRes As Long
Scr_hDC = GetDesktopWindow()
RunAssociateFile = ShellExecute(Scr_hDC, "Open", strDocName, "", "C:\",
SW_SHOWNORMAL)
End Function

Now you can do things like...

Go to a website: ShellExec.RunFile " http://www.cajuncoiler.tk "
Send an email: ShellExec.RunFile " mailto:ca*********@cox.net "
Jul 17 '05 #9
On Sat, 11 Oct 2003 17:59:21 -0500, "CajunCoiler
\(http://www.cajuncoiler.tk\)" <po**********@totallyspamless.cox.net>
wrote:
There is nothing wrong with launching a browser to view a JPG
- but it is unlikely that ShellExecute would launch a browser ...
If the file you're trying to execute is something browseable, such as a
website URL, or a mailto, then it would... that's how I put links on
forms.

Put this code in a module called "ShellExec" ...


I think you misunderstood what I was saying.

My point was that ShellExecute is useless if you want to use a
different App to display (say a JPG) than the one associated in the
Registry

Private Declare Function GetDesktopWindow Lib "user32" () As Long
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA"
(ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String,
ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As
Long) As Long
Public Const SW_SHOWNORMAL = 3
Public Function RunFile(ByVal strDocName As String) As Long
Dim Scr_hDC As Long
Dim lngRes As Long
Scr_hDC = GetDesktopWindow()
RunAssociateFile = ShellExecute(Scr_hDC, "Open", strDocName, "", "C:\",
SW_SHOWNORMAL)
End Function

Now you can do things like...

Go to a website: ShellExec.RunFile " http://www.cajuncoiler.tk "
Send an email: ShellExec.RunFile " mailto:ca*********@cox.net "


Jul 17 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Kubaton Lover | last post: by
5 posts views Thread by Michael Brennan | last post: by
reply views Thread by Reimar Bauer | last post: by
4 posts views Thread by tshad | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
xarzu
2 posts views Thread by xarzu | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.