Solved

TBitmap To C.

Posted on 2004-03-22
9
341 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

706 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

12 Experts available now in Live!

Get 1:1 Help Now