Solved

Cannot Open BMP Files in VB

Posted on 2000-05-11
13
321 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
Industry Leaders: 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month10 days, 6 hours left to enroll

628 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