Hi All
Anybody with the idea of how to call GetCursorPos() WIN API in Xbase++ ?
Thanks
Joe
			
			
									
									
						GetCursorPos() WIN API
Re: GetCursorPos() WIN API
hi,
try this
			
			
									
									try this
Code: Select all
STATIC DLLFUNCTION GetCursorPos( @pPoint )                       ;
       USING STDCALL                                             ;
       FROM  USER32.DLL
FUNCTION MyCursorPos()
LOCAL sPoint := REPLICATE(CHR(0),8)
LOCAL nX     := 0
LOCAL nY     := 0
STATIC GetCursorPos
   IF GetCursorPos = NIL
      GetCursorPos := DllPrepareCall("user32.dll",;
     DLL_STDCALL,;
     "GetCursorPos")
   ENDIF
   DllExecuteCall(GetCursorPos,@sPoint)
   nX := BIN2L(SUBSTR(sPoint,1,4))
   nY := BIN2L(SUBSTR(sPoint,5,4))
   nY := (- 1 * nY)+APPDESKTOP():CURRENTSIZE()[2]       // Xbase++ 0,0 lower left
RETURN ({nX,nY})greetings by OHR
Jimmy
						Jimmy
Re: GetCursorPos() WIN API
Hi Jimmy
I got error: Function not declared. I thought the DLLFUNCTION .... declares the function ?
Thanks.
Joe
			
			
									
									
						I got error: Function not declared. I thought the DLLFUNCTION .... declares the function ?
Thanks.
Joe
Re: GetCursorPos() WIN API
unixkd wrote:I got error: Function not declared. I thought the DLLFUNCTION .... declares the function ?
Code: Select all
#include "DLL.CH"
STATIC DLLFUNCTION GetCursorPos( @pPoint )                       ;
       USING STDCALL                                             ;
       FROM  USER32.DLL
PROCEDURE MAIN
   ? MyCursorPos()
   WAIT
RETURN
FUNCTION MyCursorPos()
LOCAL sPoint := REPLICATE(CHR(0),8)
LOCAL nX     := 0
LOCAL nY     := 0
STATIC GetCursorPos
   IF GetCursorPos = NIL
      GetCursorPos := DllPrepareCall("user32.dll",;
     DLL_STDCALL,;
     "GetCursorPos")
   ENDIF
   DllExecuteCall(GetCursorPos,@sPoint)
   nX := BIN2L(SUBSTR(sPoint,1,4))
   nY := BIN2L(SUBSTR(sPoint,5,4))
   nY := (- 1 * nY)+APPDESKTOP():CURRENTSIZE()[2]       // Xbase++ 0,0 lower left
RETURN ({nX,nY})greetings by OHR
Jimmy
						Jimmy
Re: GetCursorPos() WIN API
Working now thanks.
Once more I need help on GetAsyncState() API
From the documentation it requires VK_..... values as parameter
I need to pass VK_RBUTTON defined
#define VK_RBUTTON 0x02
			
			
									
									
						Once more I need help on GetAsyncState() API
From the documentation it requires VK_..... values as parameter
I need to pass VK_RBUTTON defined
#define VK_RBUTTON 0x02
Re: GetCursorPos() WIN API
Code: Select all
#include "DLL.CH"
// https://docs.microsoft.com/de-de/windows/desktop/inputdev/virtual-key-codes
#define VK_LBUTTON 0x01
#define VK_RBUTTON 0x02
DLLFUNCTION GetAsyncKeyState( n ) USING STDCALL FROM USER32.DLL
PROCEDURE MAIN
CLS
? "Press right mouse button"
   DO WHILE GetAsyncKeyState( VK_RBUTTON ) = 0
      Sleep( 10 )
   ENDDO
? "seems to work ;)"
WAIT
RETURNgreetings by OHR
Jimmy
						Jimmy
Re: GetCursorPos() WIN API
Jimmy thanks.
Worked perfectly
Joe
			
			
									
									
						Worked perfectly
Joe

