Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Cannot Open BMP Files in VB

Posted on 2000-05-11
13
Medium Priority
?
326 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 200 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

Technology Partners: 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!

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

705 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