Converting API Constants to PureBasic

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 darryl_bartlett.

Hi guys,

Just a really quick question for you. I was looking around some Visual Basic API examples and I came across some constants for it, namely:

CDS_UPDATEREGISTRY = &H1
CDS_TEST = &H2

DM_BITSPERPEL = &H40000
DM_PELSWIDTH = &H80000
DM_PELSHEIGHT = &H100000

Obviously, PureBasic doesn't like the &Hxxxxx bit. How would I convert these numbers into a form which PureBasic would accept?

Thanks in advance.

Regards,
Darryl.
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 FAKEFACTORY.

Change "&H" to "$". This should work:

CDS_UPDATEREGISTRY = $1
CDS_TEST = $2

DM_BITSPERPEL = $40000
DM_PELSWIDTH = $80000
DM_PELSHEIGHT = $100000


Registered PureBasic Coder
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 darryl_bartlett.

Thanks for you quick reply. It worked like a charm. Thank you for you help.
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 PB.

Don't forget that when converting Visual Basic apps to PureBasic, you don't
normally need to declare constants. For example, you can usually just throw
a hash (#) in front of the constant like so:

Visual Basic:
Public Const GW_CHILD=&H2
r=GetWindow_(GetDesktopWindow_(),GW_CHILD)

PureBasic:
; No need to declare API constants in PureBasic!
r=GetWindow_(GetDesktopWindow_(),#GW_CHILD)

As you can see, this is one of PureBasic's major advantages over Visual Basic.
Therefore, Darryl, you can most likely just use the following in your example,
without having to declare any constants in your PureBasic code:

#CDS_UPDATEREGISTRY, #CDS_TEST, #DM_BITSPERPEL, #DM_PELSWIDTH, #DM_PELSHEIGHT


PB - Registered PureBasic Coder


Edited by - PB on 15 February 2002 10:58:16
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 fred.

BTW, there are constants, so you shoud convert it to :

#CDS_UPDATEREGISTRY = $1
#CDS_TEST = $2

#DM_BITSPERPEL = $40000
#DM_PELSWIDTH = $80000
#DM_PELSHEIGHT = $100000


Fred - AlphaSND
Post Reply