How to access the windows API?
-
BackupUser
- PureBasic Guru

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

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by WolfgangS.
Try this:
beep_(1000,1000)
And try to get a API viewer from here:
http://www.reelmediaproductions.com/pb/ and click the Editor Resources.
cu
WolfgangS
Try this:
beep_(1000,1000)
And try to get a API viewer from here:
http://www.reelmediaproductions.com/pb/ and click the Editor Resources.
cu
WolfgangS
-
BackupUser
- PureBasic Guru

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

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Franco.
Hi Justin,
'#' at the beginning of a name is for constants in general, not only API constants.
If you need selfmade constants in your app just write:
#MyOwnConstant=700
A constant can be every type you want (look under Variables and Types in the manual) even a string just use:
#MyOwnConstant.s="That's me"
or
#MyOwnConstant$="That's me"
BTW: Just looked at the manual and didn't find any sentence about '#' and 'constants'.
Fred can you add constants to the manual for 3.2
Maybe under 'Constants, Variables and Types'
Have a nice day...
Franco
Sometimes you have to go a lonely way to accomplish genius things.
Hi Justin,
'#' at the beginning of a name is for constants in general, not only API constants.
If you need selfmade constants in your app just write:
#MyOwnConstant=700
A constant can be every type you want (look under Variables and Types in the manual) even a string just use:
#MyOwnConstant.s="That's me"
or
#MyOwnConstant$="That's me"
BTW: Just looked at the manual and didn't find any sentence about '#' and 'constants'.
Fred can you add constants to the manual for 3.2
Maybe under 'Constants, Variables and Types'
Have a nice day...
Franco
Sometimes you have to go a lonely way to accomplish genius things.
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Pupil.
#Constant = "no .s or $" ; is perfectly legal
You don't really have to use '.s' or $ when dealing with constants it all works perfectly without them i.e:A constant can be every type you want (look under Variables and Types in the manual) even a string just use:
#MyOwnConstant.s="That's me"
or
#MyOwnConstant$="That's me"
#Constant = "no .s or $" ; is perfectly legal
You just didn't look at the right place, i've found one sentence (barelly) that tells about constants. It's located under 'General Syntax Rules' in the reference manual. But you're right this issue should have some more space in the manual.BTW: Just looked at the manual and didn't find any sentence about '#' and 'constants'.
-
BackupUser
- PureBasic Guru

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

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

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Franco.
You are right Pupil, I missed:
It's not much, but it's there
Have a nice day...
Franco
Sometimes you have to go a lonely way to accomplish genius things.
You just didn't look at the right place, i've found one sentence (barelly) that tells about constants. It's located under 'General Syntax Rules' in the reference manual.
You are right Pupil, I missed:
- All constants are preceded by #
Example :
#Hello = 10 is a constant.
Hello = 10 is a variable.
It's not much, but it's there
Have a nice day...
Franco
Sometimes you have to go a lonely way to accomplish genius things.
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by PB.
> i know how to program the windows api in other languages.
> How it is done in pb?
When using the API in PureBasic, you don't (normally) need to declare the API
routine and any constants used with it. All API calls must be followed by the
underscore character, and all constants must be prefixed with a hash character.
Here's a quick example of an API call in Visual Basic, and the same code in
PureBasic. This example closes the Windows calculator, if open, on an English
version of Windows.
PB - Registered PureBasic Coder
Edited by - PB on 05 June 2002 22:42:45
> i know how to program the windows api in other languages.
> How it is done in pb?
When using the API in PureBasic, you don't (normally) need to declare the API
routine and any constants used with it. All API calls must be followed by the
underscore character, and all constants must be prefixed with a hash character.
Here's a quick example of an API call in Visual Basic, and the same code in
PureBasic. This example closes the Windows calculator, if open, on an English
version of Windows.
Code: Select all
' [b]Visual Basic version.[/b]
'
Public Const WM_CLOSE = &H10
'
Public Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
'
Public Declare Function PostMessage Lib "user32" Alias _
"PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
'
r = FindWindow(0, "Calculator")
If r 0 Then
PostMessage r, WM_CLOSE, 0, 0
End If
Code: Select all
; [b]PureBasic version.[/b]
;
r=FindWindow_(0,"Calculator")
If r0
PostMessage_(r,#WM_CLOSE,0,0)
EndIf
PB - Registered PureBasic Coder
Edited by - PB on 05 June 2002 22:42:45
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Franco.
Have a nice day...
Franco
Sometimes you have to go a lonely way to accomplish genius things.
Ahh, live can be so easy...PB - Registered PureBasic CoderCode: Select all
; [b]PureBasic version.[/b] ; r=FindWindow_(0,"Calculator") If r0 PostMessage_(r,#WM_CLOSE,0,0) EndIf
Have a nice day...
Franco
Sometimes you have to go a lonely way to accomplish genius things.