Solved

TBitmap To C.

Posted on 2004-03-22
9
343 Views
Last Modified: 2010-04-05
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.
0
Comment
Question by:limin123
  • 5
  • 4
9 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 100 total points
ID: 10647885
it should be enough to forward the handle
0
 
LVL 1

Author Comment

by:limin123
ID: 10657898
How do I forward the handle to the C DLL?

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?
0
 
LVL 1

Author Comment

by:limin123
ID: 10657915
I meant HBITMAP instead of HBitMap in the comment above.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 10657943
?? 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 ;-)
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:limin123
ID: 10658131
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.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 10658202
>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.
0
 
LVL 1

Author Comment

by:limin123
ID: 10663988
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.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 10667472
i saw, you posted an additional q.

is the problem now solved?

meikl ;-)
0
 
LVL 1

Author Comment

by:limin123
ID: 10673295
Hi Thanks a lot.
Yes the HBITMAP problem has been solved.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now