Solved

TBitmap To C.

Posted on 2004-03-22
9
348 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

695 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