?
Solved

TBitmap To C.

Posted on 2004-03-22
9
Medium Priority
?
349 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 400 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month15 days, 10 hours left to enroll

741 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