Guidance
指路人
g.yi.org
software / rapidq / Examples / Devices / mouse / Mouse Position.bas

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
'From:  billk2867 Sun Dec 15, 2002  2:07 am
' Tracking mouse X/Y

'If You Are Looking For Overall Coordinates Relative To
'The Form This Should Help.
'Normally Mousex And Mousey Is Used With Onmousemove
'And Coordinates Are Related To That Control.
'But Not All Controls Like Qedit And Qstatusbar Have
'This Property. So The Qtimer And Screen.Mousex/y
'Is A Good Way To Cover All Controls.
'You Then Have To Convert Coordinates To The Location
'And Size Of The Form.
'==================
     $TYPECHECK ON
     DEFINT MX, MY
     DECLARE SUB SHOWXY
     CREATE TIMEX AS QTIMER
      INTERVAL=10
      ONTIMER=SHOWXY
     END CREATE
     CREATE FORM AS QFORM
      CAPTION="FORM"
      CENTER
      CREATE PANEL AS QPANEL
       CAPTION="PANEL"
       ALIGN=1
       HEIGHT=40
      END CREATE 'PANEL
      CREATE EDIT AS QEDIT
       TEXT="TEXTBOX"
       TOP=50
       LEFT=20
       WIDTH=150
      END CREATE 'EDIT
      CREATE BTN AS QBUTTON
       TOP=100
       LEFT=50
       WIDTH=75
       CAPTION="BUTTON"
       ONMOUSEMOVE=SHOWXY
      END CREATE 'BTN
      CREATE STATUSBAR AS QSTATUSBAR
       ADDPANELS "" ,""
      END CREATE 'STATUSBAR
     END CREATE ' FORM
'
     SUB SHOWXY
      MX=SCREEN.MOUSEX-FORM.LEFT-((FORM.WIDTH-FORM.CLIENTWIDTH)/2)
      MY=SCREEN.MOUSEY-FORM.TOP-((FORM.HEIGHT-FORM.CLIENTHEIGHT))
' If You Want To Restrict Movement Within Form Boundries:
      IF MX=>0 AND MX<=FORM.CLIENTWIDTH AND _
       MY=>0 AND MY<=FORM.CLIENTHEIGHT THEN
       STATUSBAR.PANEL(0).CAPTION=STR$(MX) & " : " & STR$(MY)
      END IF
     END SUB
'
     FORM.SHOWMODAL
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sun 2024-10-6  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2002-12-15 14:39:15