It is currently Sat Dec 05, 2020 1:31 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: linedda function from gdi32
PostPosted: Thu Oct 08, 2015 8:51 pm 
Offline
Enthusiast
Enthusiast

Joined: Wed Feb 25, 2015 5:55 pm
Posts: 105
can anybody give me a hint how to obtain a reference to this function:
linedda from gdi32

Code:
BOOL LineDDA(
  _In_ int         nXStart,
  _In_ int         nYStart,
  _In_ int         nXEnd,
  _In_ int         nYEnd,
  _In_ LINEDDAPROC lpLineFunc,
  _In_ LPARAM      lpData
);


HELP


Top
 Profile  
Reply with quote  
 Post subject: Re: linedda function from gdi32
PostPosted: Thu Oct 08, 2015 10:04 pm 
Offline
PureBasic Bullfrog
PureBasic Bullfrog
User avatar

Joined: Wed Jul 06, 2005 5:42 am
Posts: 8144
Location: Fort Nelson, BC, Canada
Stand by for hint...

coming...

Here is the hint:
Code:
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/library/windows/desktop/dd145025(v=vs.85).aspx

_________________
Veni, vidi, vici.


Top
 Profile  
Reply with quote  
 Post subject: Re: linedda function from gdi32
PostPosted: Thu Oct 08, 2015 10:17 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue May 28, 2013 10:51 pm
Posts: 540
Location: Europe
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.

Image

_________________
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/


Top
 Profile  
Reply with quote  
 Post subject: Re: linedda function from gdi32
PostPosted: Thu Oct 08, 2015 10:26 pm 
Offline
Enthusiast
Enthusiast

Joined: Wed Feb 25, 2015 5:55 pm
Posts: 105
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?


Top
 Profile  
Reply with quote  
 Post subject: Re: linedda function from gdi32
PostPosted: Thu Oct 08, 2015 10:27 pm 
Offline
PureBasic Bullfrog
PureBasic Bullfrog
User avatar

Joined: Wed Jul 06, 2005 5:42 am
Posts: 8144
Location: Fort Nelson, BC, Canada
Ok, I see the issue you're referring to. Here's a version that will work under unicode or ascii:
Code:
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)

_________________
Veni, vidi, vici.


Top
 Profile  
Reply with quote  
 Post subject: Re: linedda function from gdi32
PostPosted: Thu Oct 08, 2015 10:29 pm 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 6263
Location: Wales, UK
.... Danilo posted a very handy GDI+ lib:
gDrawing

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: linedda function from gdi32
PostPosted: Thu Oct 08, 2015 10:35 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue May 28, 2013 10:51 pm
Posts: 540
Location: Europe
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?

_________________
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/


Top
 Profile  
Reply with quote  
 Post subject: Re: linedda function from gdi32
PostPosted: Thu Oct 08, 2015 10:38 pm 
Offline
Enthusiast
Enthusiast

Joined: Wed Feb 25, 2015 5:55 pm
Posts: 105
thanks a million - that works.


Top
 Profile  
Reply with quote  
 Post subject: Re: linedda function from gdi32
PostPosted: Thu Oct 08, 2015 10:55 pm 
Offline
PureBasic Bullfrog
PureBasic Bullfrog
User avatar

Joined: Wed Jul 06, 2005 5:42 am
Posts: 8144
Location: Fort Nelson, BC, Canada
Quote:
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.

_________________
Veni, vidi, vici.


Top
 Profile  
Reply with quote  
 Post subject: Re: linedda function from gdi32
PostPosted: Thu Oct 08, 2015 11:28 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue May 28, 2013 10:51 pm
Posts: 540
Location: Europe
netmaestro wrote:
Quote:
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...

_________________
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/


Top
 Profile  
Reply with quote  
 Post subject: Re: linedda function from gdi32
PostPosted: Thu Oct 08, 2015 11:38 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Feb 04, 2013 5:28 pm
Posts: 334
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: linedda function from gdi32
PostPosted: Thu Oct 08, 2015 11:42 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue May 28, 2013 10:51 pm
Posts: 540
Location: Europe
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.

_________________
"If you lie to the compiler, it will get its revenge."
Henry Spencer
https://www.pci-z.com/


Top
 Profile  
Reply with quote  
 Post subject: Re: linedda function from gdi32
PostPosted: Fri Oct 09, 2015 2:53 pm 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 14180
Location: France
It was an error in the import declaration, should be fixed for the next beta.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 51 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye