| |
| Posted by Matthew in reply to Dejan Lekic | PermalinkReply |
|
Matthew
Posted in reply to Dejan Lekic
| I don't know if it's directly germane to your issue, but you can now use dl_call (from WinSTL sub-project of STLSoft; also one for UNIX in UNIXSTL) for invoking, in a type-safe manner, any C function from any DLL, in occasions such as when confronted with not having up-to-date libraries.
For example, AlphaBlend can be invoked thusly:
HDC hdcDest;
int nXOriginDest;
int nYOriginDest;
int nWidthDest;
int nHeightDest;
HDC hdcSrc;
int nXOriginSrc;
int nYOriginSrc;
int nWidthSrc;
int nHeightSrc;
BLENDFUNCTION blendFunction;
winstl::dl_call<BOOL>( "msimg32.dll"
, "S:AlphaBlend"
, hdcDest
, nXOriginDest
, nYOriginDest
, nWidthDest
, nHeightDest
, hdcSrc
, nXOriginSrc
, nYOriginSrc
, nWidthSrc
, nHeightSrc
, blendFunction);
Note: For safety, dl_call() does a static assert on the type of each
argument, to ensure that it is:
- fundamental type, or
- pointer type, or
- function pointer type.
Some functions, and AlphaBlend is one of them, take arguments of structure by value. This, by default, causes the static assert to fire. However, the user may stipulate any type as compatible by specialising the winstl::is_valid_dl_call_arg traits, as follows:
template <>
struct winstl::is_valid_dl_call_arg<BLENDFUNCTION>
{
enum { value = 1 };
};
As long as this is defined in the same compilation unit as the function that invokes AlphaBlend, the code shown above will work correctly.
(Note: the is_valid_dl_call_arg traits mechanism was added in the latest
beta (6), which was released a couple of days ago.)
HTH
Cheers
Matthew
"Dejan Lekic" <dejan@nu6.org> wrote in message news:e3v14o$vha$1@digitaldaemon.com...
> Yeah, i did it, i got msimg32.lib, but than i have discovered that
> actual problem lies in old headers... I could not just copy headers from
> MS PSDK or MinGW's Win32 API package because they are not compatible
> with DM C/C++.
> What i did was to declare all AlphaBlend-related types and functions
> inside #if __DMC__ at the top of my C++ sources and everything seemed to
> work until it came to the linking.
> Btw. i am using Code::Blocks for this little adventure.
> Than i got this:
> -------------- Build: fltk-static-debug in windows-dmc ---------------
> Linking static library: ..\..\lib\fltk2-debug.lib
> Digital Mars Librarian Version 8.00n
> Copyright (C) Digital Mars 2000-2002 All Rights Reserved
www.digitalmars.com
> Warning: Public '_main' already in library, redefinition ignored.
> Error: /PAGESIZE:16 is too small
> Process terminated with status 1 (0 minutes, 0 seconds)
> 0 errors, 0 warnings
>
> When i added -p32 in the additional link properties (even though it is actually a librarian's flag) build passed well.
>
> But, executable does not do anything... How to debug it? It can be bad msimg32.lib or somehing else...
>
> Kind regards
>
> Dejan Lekic
|