I want to create a DLL plugins to use with Delphi and other languages (mostly C++). How can I pass bitmaps in a C++ and Delphi-friendly way? Can it just be a handle to the Delphi TBitmap? C++ program should be able to decode it using WinApi, right?
相关问题
- How to know full paths to DLL's from .csproj f
- Is there a Delphi 5 component that can handle .png
- Is there a way to install Delphi 2010 on Windows 2
- how to call a C++ dll from C# windows application
- efficiently calling unmanaged method taking unmana
相关文章
- vs2017wpf项目引用dll的路径不正确的问题
- Best way to implement MVVM bindings (View <-> V
- Determine if an executable (or library) is 32 -or
- Windows EventLog: How fast are operations with it?
- C++: Callback typedefs with __stdcall in MSVC
- How to force Delphi compiler to display all hints
- Coloring cell background on firemonkey stringgrid
- Are resource files compiled as UNICODE or ANSI cod
You cannot pass a Delphi
TBitmap
object since that is only meaningful to Delphi code. What you need to pass is anHBITMAP
, a handle to a Windows bitmap.The Delphi
TBitmap
class is just a wrapper around the Windows bitmap and can provideHBITMAP
handles. The thing you need to watch out for is the ownership of those handles.If you have a Delphi
TBitmap
you can get anHBITMAP
by calling theReleaseHandle
method of aTBitmap
. The handle returned byReleaseHandle
is no longer owned and managed by theTBitmap
object which is exactly what you want. You pass that handle to the C++ code and let it become the owner. It is responsible for disposing of that handle.The documentation for
ReleaseHandle
says:In the other direction your Delphi code would receive an
HBITMAP
from the C++ code and take on ownership. Do that by assigning to theHandle
property of aTBitmap
instance.The details will vary from language to language, but no matter what, all will be able to deal with an
HBITMAP
.