Page 1 of 1
linedda function from gdi32
Posted: Thu Oct 08, 2015 8:51 pm
by startup
can anybody give me a hint how to obtain a reference to this function:
linedda from gdi32
Code: Select all
BOOL LineDDA(
_In_ int nXStart,
_In_ int nYStart,
_In_ int nXEnd,
_In_ int nYEnd,
_In_ LINEDDAPROC lpLineFunc,
_In_ LPARAM lpData
);
HELP
Re: linedda function from gdi32
Posted: Thu Oct 08, 2015 10:04 pm
by netmaestro
Stand by for hint...
coming...
Here is the hint:
Code: Select all
Procedure callback(x, y, lParam)
Debug Str(x)+", "+Str(y)
EndProcedure
LineDD_(0,0,100,160,@callback(),0)
Hint successfully delivered. Contains a working sample. Reference is here:
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
Re: linedda function from gdi32
Posted: Thu Oct 08, 2015 10:17 pm
by bbanelli
Hi netmaestro,
regardless OP's incoherent post, he might be on something, since both PB 5.31 and latest PB 5.4 b8 return something like this. Tried on Win XP, W7 x64 and W10 x64.

Re: linedda function from gdi32
Posted: Thu Oct 08, 2015 10:26 pm
by startup
this is exactly what happen to me too. it doesn't work and i think its a purebasic (lib) problem. is there any other way to use that function, any trick, any workaround?
Re: linedda function from gdi32
Posted: Thu Oct 08, 2015 10:27 pm
by netmaestro
Ok, I see the issue you're referring to. Here's a version that will work under unicode or ascii:
Code: Select all
CompilerIf #PB_Compiler_Unicode = #True
Import "gdi32.lib"
LineDDA(x1, y1, x2, y2, *callback, lParam)
EndImport
CompilerElse
Macro LineDDA
LineDD_
EndMacro
CompilerEndIf
Procedure callback(x, y, lParam)
Debug Str(x)+", "+Str(y)
EndProcedure
LineDDA(0,0,100,160,@callback(),0)
Re: linedda function from gdi32
Posted: Thu Oct 08, 2015 10:29 pm
by IdeasVacuum
.... Danilo posted a very handy GDI+ lib:
gDrawing
Re: linedda function from gdi32
Posted: Thu Oct 08, 2015 10:35 pm
by bbanelli
netmaestro wrote:Ok, I see the issue you're referring to. Here's a version that will work under unicode or ascii:
Thanks, works perfectly, but could you just briefly clarify what's the issue in this case?
Re: linedda function from gdi32
Posted: Thu Oct 08, 2015 10:38 pm
by startup
thanks a million - that works.
Re: linedda function from gdi32
Posted: Thu Oct 08, 2015 10:55 pm
by netmaestro
could you just briefly clarify what's the issue in this case?
It's actually quite a common problem that crops up from time to time. If you have the "Compiler Options -> Create Unicode Executable" checked then the linker will search for a unicode version of the function from the library (with the name usually ending in "W"), as opposed to the name ending in "A" which is the ascii version. If you check gdi32.lib you will see that there is no "LineDDW" version of this function, all there is is the ascii one. But when you compile under unicode the linker won't link the ascii version in with your exe - you have to force it using code like I posted. If you think about what the function does, there really is no need for MS to have included a unicode-ready version - no strings involved. But PB could utilize a macro or something to get the function into the program seamlessly. It actually could be considered a bug, losing access to a non-string function because you flipped the Unicode switch.
Re: linedda function from gdi32
Posted: Thu Oct 08, 2015 11:28 pm
by bbanelli
netmaestro wrote:could you just briefly clarify what's the issue in this case?
It's actually quite a common problem that crops up from time to time. If you have the "Compiler Options -> Create Unicode Executable" checked then the linker will search for a unicode version of the function from the library (with the name usually ending in "W"), as opposed to the name ending in "A" which is the ascii version. If you check gdi32.lib you will see that there is no "LineDDW" version of this function, all there is is the ascii one. But when you compile under unicode the linker won't link the ascii version in with your exe - you have to force it using code like I posted. If you think about what the function does, there really is no need for MS to have included a unicode-ready version - no strings involved. But PB could utilize a macro or something to get the function into the program seamlessly. It actually could be considered a bug, losing access to a non-string function because you flipped the Unicode switch.
Hi netmaestro, thank you very much for your explanation.
But how should one tell from Microsoft documentation that this is ASCII/ANSI only version of function, usually under "Requirements" tab is says something like "Unicode and ANSI names" so you can tell. But I can't see anything similar with this function, though...
Re: linedda function from gdi32
Posted: Thu Oct 08, 2015 11:38 pm
by DontTalkToMe
bbanelli wrote: how should one tell from Microsoft documentation that this is ASCII/ANSI only version of function, usually under "Requirements" tab is says something like "Unicode and ANSI names" so you can tell. But I can't see anything similar with this function, though...
Looking at the docs there is only one API function and it's named LineDDA.
http://winapi.freetechsecrets.com/win32 ... ctions.htm
For some reason PB thinks the function is named LineDD instead (so LineDD_ in PB) and thinks there should be an ascii (LineDDA) and a unicode (LineDDW) version of it.
Re: linedda function from gdi32
Posted: Thu Oct 08, 2015 11:42 pm
by bbanelli
DontTalkToMe wrote:For some reason PB thinks the function is named LineDD instead (so LineDD_ in PB) and thinks there should be an ascii (LineDDA) and a unicode (LineDDW) version of it.
Oh, OK, that's where I got confused, probably because "DD" is capitalized so it's harder to "figure out" than MessageBoxA/W, for example.
Re: linedda function from gdi32
Posted: Fri Oct 09, 2015 2:53 pm
by Fred
It was an error in the import declaration, should be fixed for the next beta.