Solved

Cannot Open BMP Files in VB

Posted on 2000-05-11
13
305 Views
Last Modified: 2012-08-13
I have the following function defined in VB
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

When I call it with

Call ShellExecute(Me.hwnd, "open", DataGrid1.Columns(1), vbNullString, "C:\", sw_shownormal)

if works fine and will open word documents etc. no problem HOWEVER it will not open up .bmp files (which are associated with paintbrush),  any ideas why?
0
Comment
Question by:MrTimewalk
  • 6
  • 4
  • 2
  • +1
13 Comments
 

Expert Comment

by:keerthivasan
ID: 2799435
Mrtimewalk,

it is not that difficult opening bmps' in VB , bmps' being the proprietry image formats of microsoft products.

 There are 3 ways to open a bmp file in VB.

 the ways being
 
  1. open paintbrush calling shell function (not the function you have defined) and loading the bmp from  paintbrush or directly calling the bmp using shell function.
  2. drag & drop a image control, connect it to a image and at runtime display the image control.
  3. you can use the ole link /embed option to to display images. when you create a ole object it will automatically navigate you through the channel of creating a bmp to be viewed at runtime.

thanks
0
 

Expert Comment

by:keerthivasan
ID: 2799440

Dear mrtimewalk,

i have given you the solutions, it should be solving your problem.
0
 

Author Comment

by:MrTimewalk
ID: 2799462
I agree Keethivasan, your solution was excellent however for some reason on a PC which has Paintbrush associated with bitmaps it cannot open up the bitmap using this function call.  If I have a different graphics application associated with .bmps no problem but on a new PC I'm stuck
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:mcrider
ID: 2799465
Are you sure the association is there?? what happens when you double-click on a BMP from explorer?

Also check the variable you're passing to ShellExecute to make sure the pathname is correct.

Do you have this definition in your program:

   Const sw_shownormal = 1

After you run the ShellExecute, do a CTRL-ALT-DELETE and see if MSPAINT is a running task.  If it is running, then the instance of MSPAINT has been started hidden.  This happens if sw_shownormal equals zero.


Cheers!®©

0
 

Author Comment

by:MrTimewalk
ID: 2799473
I agree Keethivasan, your solution was excellent however for some reason on a PC which has Paintbrush associated with bitmaps it cannot open up the bitmap using this function call.  If I have a different graphics application associated with .bmps no problem but on a new PC I'm stuck
0
 
LVL 14

Expert Comment

by:mcrider
ID: 2799475
By the way, if MSPAINT is running, you will have to terminate the running instances of it and set sw_shownormal to 1 before it will work...


Cheers!®©
0
 

Author Comment

by:MrTimewalk
ID: 2799479
I agree Keethivasan, your solution was excellent however for some reason on a PC which has Paintbrush associated with bitmaps it cannot open up the bitmap using this function call.  If I have a different graphics application associated with .bmps no problem but on a new PC I'm stuck
0
 

Author Comment

by:MrTimewalk
ID: 2799508
If I double click on a BMP in explorer it launches Windows PaintBrush.

The path IS correct for the bitmap

There isn't an instance of Paintbrush running in the background

The function call works perfectly for other programs like Word etc. however it doesn't do anything with Paintbrush.  

0
 
LVL 28

Expert Comment

by:Ark
ID: 2799534
Hi
Try res = ShellExecute....
and post here res value
Cheers
0
 

Author Comment

by:MrTimewalk
ID: 2799548
Folks I AM AN IDIOT

I apologise

It was running the .bmp invisibly. sw_shownormal was not defined

Thanks to everyone for the help
0
 
LVL 14

Accepted Solution

by:
mcrider earned 50 total points
ID: 2799586
You are not an idiot... It was just a bug... I'm glad I could help you. Please grade this.


Cheers!®©
0
 

Author Comment

by:MrTimewalk
ID: 2799591
Thanks very much
0
 
LVL 14

Expert Comment

by:mcrider
ID: 2799598
Thanks for the points! Again, glad I could help you.  You know where we are if you need any more help ;-)


Cheers!®©
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question