Page 1 of 1
Posted: Wed Jun 19, 2002 11:25 am
by BackupUser
Restored from previous forum. Originally posted by skypa.
Hi,
in VisualBasic you can get the adress of a function with the AdressOf operator. Some API's need a function/procedure in the application to which they can pass some values. My question is now: Is there a similar operator/command in PureBasic, so I can pass variables for example from EnumWindows in my own PureBasic Procedures?
EnumWindows
Declare Function EnumWindows Lib "user32.dll" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
· lpEnumFunc
Points to an application-defined callback function. For more information, see the EnumWindowsProc callback function.
· lParam
Specifies a 32-bit, application-defined value to be passed to the callback function.
thanks (again) in advance

Posted: Wed Jun 19, 2002 12:12 pm
by BackupUser
Restored from previous forum. Originally posted by PB.
> in VisualBasic you can get the adress of a function with the AdressOf operator.
> Is there a similar operator/command in PureBasic, so I can pass variables for
> example from EnumWindows in my own PureBasic Procedures?
In PureBasic's help, check out the 'Pointers and Memory access' section... it may
be what you are looking for (I'm not 100% sure).
PB - Registered PureBasic Coder
Posted: Wed Jun 19, 2002 1:01 pm
by BackupUser
Restored from previous forum. Originally posted by skypa.
Addresses of procedures
Normally only advanced programmers need to find the address of procedures. Probably the most common reason for needing the address of a procedure is when dealing with the OS at a low-level. Some OSes allow you to specify callback or hook functions (for some operations) which get called by the OS and allows the programmer to extend the ability of the OS routine. The address of a procedure is found in a similar way to variables.
Example :
Procedure WindowCB(WindowID.l, Message.l, wParam.l, lParam.l)
; This is where the processing of your callback procedure would be performed
EndProcedure
; A special callback for the Windows OS allowing you to process window events
SetWindowCallback( @WindowCB() )
I think that's it, thanks PB.
Posted: Wed Jun 19, 2002 1:09 pm
by BackupUser
Restored from previous forum. Originally posted by skypa.
This is very low level and I'm not sure if i'm expirienced enough to solve my problem. So, if anyone has an idea how to realise the callback of EnumWindows in PureBasic I would be very thankful...
Posted: Wed Jun 19, 2002 2:19 pm
by BackupUser
Restored from previous forum. Originally posted by Paul.
Here is a little program I wrote that uses the EnumWindows command...
maybe it will help you ??
Code: Select all
Structure FindWindowData
hFW.l
sFW.s
EndStructure
NewList FindWindow.FindWindowData()
Procedure.l EnumWindowsProc(hFind,lParam)
WindowName.s=Space(255)
If GetWindowText_(hFind,@WindowName,255)
AddElement(FindWindow())
FindWindow()\hFW=hFind
FindWindow()\sFW=WindowName
EndIf
ProcedureReturn 1
EndProcedure
OpenConsole()
If EnumWindows_(@EnumWindowsProc(),0)
ResetList(FindWindow())
While NextElement(FindWindow())
PrintN(FindWindow()\sFW)
Wend
EndIf
Input()
CloseConsole()
End
Posted: Wed Jun 19, 2002 3:01 pm
by BackupUser
Restored from previous forum. Originally posted by tinman.
Code: Select all
NewList FindWindow.FindWindowData()
Don't you need to make that shared in your procedure, or make it global so that the callback can access it?
--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.20)
Posted: Wed Jun 19, 2002 3:05 pm
by BackupUser
Restored from previous forum. Originally posted by Paul.
Code: Select all
NewList FindWindow.FindWindowData()
Don't you need to make that shared in your procedure, or make it global so that the callback can access it?
No... LinkedLists are already Global.
Posted: Wed Jun 19, 2002 4:22 pm
by BackupUser
Restored from previous forum. Originally posted by skypa.
@ Paul
Big thanks, this is exactly what I was looking for

Posted: Wed Jun 19, 2002 4:29 pm
by BackupUser
Restored from previous forum. Originally posted by Franco.
Side note:
in VisualBasic you can get the adress of a function with the AdressOf operator.
in PureBasic too - with Win API:
AddressOf = GetProcAddress_(GetModuleHandle_("user32.dll"),"EnumWindows")
Or if you want to have a function like:
Address = AddressOf("user32.dll","EnumWindows")
make
Code: Select all
Procedure AddressOf(Module$,Proc$)
ProcedureReturn GetProcAddress_(GetModuleHandle_(Module$),Proc$)
EndProcedure
Have a nice day...
Franco
Sometimes you have to go a lonely way to accomplish genius things.
Edited by - franco on 19 June 2002 17:44:49