Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Screen Coord vrs Foxpro Forms coord
Message
 
To
All
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Title:
Screen Coord vrs Foxpro Forms coord
Miscellaneous
Thread ID:
00713318
Message ID:
00713318
Views:
105
I'm trying to use the GetCursorPos API function to get the coord of and specific ToolBar, but i found that the coord that this function gives me ain't the same that the VFP Forms' coord, why is So? and better, How can I convert the Coord that the API function gives me to VFP coord or Viceversa, convert the coord of VFP forms to getcursorpos coord?

see the example below to better understanding of my requirenment
oForm = CREATEOBJECT("desaparecer")
oForm.show
READ events

**************************************************
*-- Class: desaparecer (c:\temp\vfp7\api translator\desaparecer.vcx)
*-- ParentClass: form
*-- BaseClass: form
*-- Time Stamp: 10/18/02 03:42:00 PM
*
DEFINE CLASS desaparecer AS form
Top = 0
Left = 0
Height = 198
Width = 193
DoCreate = .T.
Caption = "Form1"
Name = "Form1"
FirstTime = .T.


ADD OBJECT timer1 AS timer WITH ;
Top = 12, ;
Left = 144, ;
Height = 23, ;
Width = 23, ;
Interval = 100, ;
Name = "Timer1"


ADD OBJECT txtpos AS textbox WITH ;
Height = 25, ;
Left = 24, ;
Top = 36, ;
Width = 145, ;
Name = "txtPos"


ADD OBJECT label1 AS label WITH ;
AutoSize = .T., ;
Caption = "Mouse Position", ;
Height = 17, ;
Left = 24, ;
Top = 12, ;
Width = 87, ;
Name = "Label1"

ADD OBJECT txtFormPos AS textbox WITH ;
Height = 25, ;
Left = 24, ;
Top = 96, ;
Width = 145, ;
Name = "txtFormPos"
Value = [0,0]


ADD OBJECT label2 AS label WITH ;
AutoSize = .T., ;
Caption = "Form Position", ;
Height = 17, ;
Left = 24, ;
Top = 76, ;
Width = 117, ;
Name = "Label2"

ADD OBJECT command1 AS commandbutton WITH ;
Top = 156, ;
Left = 60, ;
Height = 27, ;
Width = 84, ;
Caption = "Exit", ;
Name = "Command1"

PROCEDURE timer1.Timer
*:retrieving the absolute positionof the window
DECLARE SHORT GetWindowRect IN user32; 
INTEGER hwnd,; 
STRING @ lpRect 

lpRect = Repli(Chr(0), 16)

=GetWindowRect(Thisform.HWnd, @ lpRect)

cMember = SUBSTR(lpRect, 1,4)
cLeft= Asc(SUBSTR(cMember, 1,1)) + ;
Asc(SUBSTR(cMember, 2,1)) * 256 +;
Asc(SUBSTR(cMember, 3,1)) * 65536 +;
Asc(SUBSTR(cMember, 4,1)) * 16777216

cMember = SUBSTR(lpRect, 5,4)
cTop =Asc(SUBSTR(cMember, 1,1)) + ;
Asc(SUBSTR(cMember, 2,1)) * 256 +;
Asc(SUBSTR(cMember, 3,1)) * 65536 +;
Asc(SUBSTR(cMember, 4,1)) * 16777216

cMember = SUBSTR(lpRect, 9,4)
cRight=Asc(SUBSTR(cMember, 1,1)) + ;
Asc(SUBSTR(cMember, 2,1)) * 256 +;
Asc(SUBSTR(cMember, 3,1)) * 65536 +;
Asc(SUBSTR(cMember, 4,1)) * 16777216

cMember = SUBSTR(lpRect, 13,4)
cBottom=Asc(SUBSTR(cMember, 1,1)) + ;
Asc(SUBSTR(cMember, 2,1)) * 256 +;
Asc(SUBSTR(cMember, 3,1)) * 65536 +;
Asc(SUBSTR(cMember, 4,1)) * 16777216

*:locationg the mouse over the form for the first time to make it visible


IF Thisform.FirstTime Then
DECLARE SetCursorPos IN user32 ;
INTEGER x,;
INTEGER y 

=SetCursorPos(cLeft + 50 ,cTop + 50)
Thisform.FirstTime = .F.
ENDIF 
*:Function to get the mouse absolute position
DECLARE SHORT GetCursorPos IN user32 STRING @ lpPoint

cMember = ""
cPoint = Repli(Chr(0), 8)
=GetCursorPos(@cPoint)
cMember = SUBSTR(cPoint, 1,4)
cX = Asc(SUBSTR(cMember, 1,1)) + ;
Asc(SUBSTR(cMember, 2,1)) * 256 +;
Asc(SUBSTR(cMember, 3,1)) * 65536 +;
Asc(SUBSTR(cMember, 4,1)) * 16777216

cMember = SUBSTR(cPoint, 5,4)
cY = Asc(SUBSTR(cMember, 1,1)) + ;
Asc(SUBSTR(cMember, 2,1)) * 256 +;
Asc(SUBSTR(cMember, 3,1)) * 65536 +;
Asc(SUBSTR(cMember, 4,1)) * 16777216

xX = cX 
cX = alltrim(str(cX))
xY = cY
cY = alltrim(str(cY))

THISFORM.txtPos.Value = cX + ", " + cY
* Thisform.Visible = (BETWEEN(xX,cLeft, cRight) AND BETWEEN(xY,cTop, cBottom))
* IF thisform.Visible then
* thisform.txtPos.setfocus
* ENDIF 
ENDPROC


PROCEDURE command1.Click
thisform.Release
CLEAR EVENTS 
ENDPROC

   PROCEDURE queryunload 
      thisform.command1.click
   ENDPROC 
   PROCEDURE mousemove
      LPARAMETERS nButton, nShift, nXCoord, nYCoord
      Thisform.txtFormPos.Value = ALLTRIM(STR(nXCoord)) + [, ] + ALLTRIM(STR(nYCoord))
   ENDPROC 
ENDDEFINE
*
*-- EndDefine: desaparecer
**************************************************
please help me out
.......
DO WHILE .T.
      ME.Work()
ENDDO
Next
Reply
Map
View

Click here to load this message in the networking platform