Upgrade problem - help required

  • Thread starter Thread starter Martin Horn
  • Start date Start date
M

Martin Horn

Hi,

I am upgrading a VB6 project that used a stdPicture and passed it's handle
property to a DirectX 7 API function.

VB .net doesn't support the stdPicture and advises using
system.drawing.image as an alternative, but the .net image control doesn't
have a handle property.

I have worked out how to add a stdPicture object to my .net project by
adding a reference to stdOLE, but now I can't work out how to load a picture
into it. In VB6 I used the LoadPicture() function, but this isn't available
in .net.

Can someone either suggest a way to obtain the handle for the .net image or
advise how to load a picture into a stdPicture object.

Thanks,

Martin Horn.
 
Martin Horn said:
Hi,

I am upgrading a VB6 project that used a stdPicture and passed it's handle
property to a DirectX 7 API function.

VB .net doesn't support the stdPicture and advises using
system.drawing.image as an alternative, but the .net image control doesn't
have a handle property.

I have worked out how to add a stdPicture object to my .net project by
adding a reference to stdOLE, but now I can't work out how to load a picture
into it. In VB6 I used the LoadPicture() function, but this isn't available
in .net.

Can someone either suggest a way to obtain the handle for the .net image or
advise how to load a picture into a stdPicture object.

Thanks,

Martin Horn.
 
I haven't tried this myself, but the PictureBox .NET control has a handle
property that you might be able to pass to the DirectX 7 API.

You can load an image into the picturebox with:

PictureBox1.Image = System.Drawing.Image.FromFile(fileName)

HTH,
Scott Swigart
www.swigartconsulting.com
blog.swigartconsulting.com
 
Hi Scott,

thanks for the reply, but I have already tried using a picturebox and
passing the handle property without any success.

Regards,

Martin.
 
In case anyone else has the same problem, here is a solution that worked for
me.

Dim fs As New System.IO.FileStream(Application.StartupPath &
"\Invader1_1.bmp", System.IO.FileMode.Open)
Dim b As New Bitmap(Application.StartupPath & "\Invader1_1.bmp")
Dim handle As IntPtr
handle = b.GetHbitmap()

handle can now be passed to the DirectX API function and everything works as
expected.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top