Link to home
Start Free TrialLog in
Avatar of Vasguard
Vasguard

asked on

Using the GetObjectA Function in VB.NET

In vb6, the syntax is Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long

The Problem:  In VB.NET, the ANY datatype is no longer used so I replace ANY with OBJECT as displayed below:

Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As OBJECT) As Long

and executed the function as:

 xint = GetObject(PictureBox1.Handle.ToInt32, Len(picinfo), picinfo)

xint returns a value indicating the functions was successful, however. picinfo is all 0's.

Can anyone help?
Avatar of Erick37
Erick37
Flag of United States of America image

In .NET, 32 bit values are now Integers.  The correct declare would be:

Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Integer, ByVal nCount As Integer, ByRef lpObject As Object) As Integer
BTW, the graphics handling capabilities in VB.NET are much more powerful than in VB6, so you may be able to accomplish what you are trying to do without using API calls.  What is it you need to do using GetObjectA?
Avatar of Vasguard
Vasguard

ASKER

I am new to vb.net but where are some good sites to learn about the graphics.  All I am trying to do is compare two bitmaps and see if they are different or the same.
When you say comparing bitmaps, do you mean testing to see that each pixel is identical to the corresponding pixel in the other bitmap?

Yes, I want to detect in changes in the pixels.  Do you know how I could do that?
ASKER CERTIFIED SOLUTION
Avatar of Erick37
Erick37
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial