API & signed/unsigned values in PB

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Max..

Hi.

At the moment I'm having a rough time, understanding how to deal with that.

I'm calling a custom dll to receive a handle to a font I need later:

Code: Select all

HFONT SlpCreateFont(LPSTR lpName, int nPoints, int nAttributes);Parameters
lpName
Name of the typeface
nPoints
Height of font, in points
nAttributes
Attributes for the font. See below.
Return Value
If successful, the function returns a handle to the font, otherwise the return value is 0.
Remarks
The nAttribute parameter may be one of the values from the table below. C/C++ programs may
use one or more of the attribute constants (NORMAL, BOLD, ITALIC, and UNDERLINE) defined
in the SLPAPI.H header file.
This function creates a font with the specified typeface and attributes. The returned handle is
used to specify the font when using the text drawing functions. When the font is no longer
needed, the SlpDeleteFont function should be called to release memory used by the font.
When I call the function like

Code: Select all

fntHandle.l= CallFunction(#SLPAPI42, "SLPCREATEFONT","Arial",8,0)
I get both negative and positive values for the handle in different runs. From what I gathered from the forum, this is due to the signed/unsigned problematic & I could use StrU to get the string representation of the unsigned handle - but I do not need a string.

The tips seen so far said: use word if you want unsigned byte range, use long, if you want to use unsigned word range... but as a long is 4 bytes already, how can I store that unsigned except as string? Or is my problem a different one?

*sigh* /me confused




Max.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by freak.

Do I understand that right: You need the handle only for futher calls to API/DLL Stuff?

In that case the signed/unsigned Stuff doesn't matter.
Who cares, if PB thinks, that this handle is negative?

As long as you pass it unchanged to the other Functions, there should be no Problem.

Hope you undestand me...

Timo
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Max..

Yep. Not too unlogical. :wink: Thanks.

Max.
Post Reply