limin123
asked on
TBitmap To C.
Hi,
I need to pass a TBitMap to a C DLL. How can I do this? Is there a compatible type in C (Microsoft Visual C)? Is TBitmap a wrapper class based on some win32 data structure?
Thanks.
I need to pass a TBitMap to a C DLL. How can I do this? Is there a compatible type in C (Microsoft Visual C)? Is TBitmap a wrapper class based on some win32 data structure?
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I meant HBITMAP instead of HBitMap in the comment above.
?? the handle is the HBITMAP-type
did you freed your TBitmap after/before you call the dll?
(do not free it until the dll is ready)
meikl ;-)
did you freed your TBitmap after/before you call the dll?
(do not free it until the dll is ready)
meikl ;-)
ASKER
Thanks for the quick response.
if object ABC is a TBitMap object, does ABC.Handle return a HBITMAP?
The TBitMap was freed only after the DLL was called.
Thanks.
if object ABC is a TBitMap object, does ABC.Handle return a HBITMAP?
The TBitMap was freed only after the DLL was called.
Thanks.
>if object ABC is a TBitMap object, does ABC.Handle return a HBITMAP?
yes,
from delphi helpfile:
Provides access to the Windows GDI bitmap handle for accessing the GDI bitmap object.
Delphi syntax:
property Handle: HBitmap;
Description
Use Handle to call a Windows API function that requires the handle of a bitmap object. Pass Handle as the bitmap handle parameter to these functions.
Handle is the HBITMAP encapsulated by the bitmap object. Avoid grabbing the handle directly since it causes the HBITMAP to be copied if more than one TBitmap shares the handle.
yes,
from delphi helpfile:
Provides access to the Windows GDI bitmap handle for accessing the GDI bitmap object.
Delphi syntax:
property Handle: HBitmap;
Description
Use Handle to call a Windows API function that requires the handle of a bitmap object. Pass Handle as the bitmap handle parameter to these functions.
Handle is the HBITMAP encapsulated by the bitmap object. Avoid grabbing the handle directly since it causes the HBITMAP to be copied if more than one TBitmap shares the handle.
ASKER
Here's my delphi wrapper. myPic is a TBitmap object.
result := TEST_DLL( HBITMAP(myPic.Handle) );
and here is the C function declaration:
IMGPRO_API IMGP_RESULT Test(HBITMAP i_HBmp);
I am still getting access violation.
result := TEST_DLL( HBITMAP(myPic.Handle) );
and here is the C function declaration:
IMGPRO_API IMGP_RESULT Test(HBITMAP i_HBmp);
I am still getting access violation.
i saw, you posted an additional q.
is the problem now solved?
meikl ;-)
is the problem now solved?
meikl ;-)
ASKER
Hi Thanks a lot.
Yes the HBITMAP problem has been solved.
Yes the HBITMAP problem has been solved.
ASKER
I tried using TBitmap.Handle to get a handle to the Tbitmap object and pass this to a C DLL which declares the input parameter as HBitMap but it didn't work. Do you know why this is so?