Guidance
指路人
g.yi.org
software / RapidQ / Examples / Devices / mouse / select2dx.rq

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

  
'
'Menu Selection Under DXScreen Ver0.1
'Usage: Move mouse on item, Click to select.
'Witten by Nadesom@yahoo.com
'2002.1
'

     $INCLUDE "RAPIDQ.INC"

     DECLARE SUB DrawScreen

     DECLARE SUB XMouseMove(curX,curY)
     DECLARE SUB XClick

     DIM Form AS QFORM
     Form.ClientHeight = 480
     Form.ClientWidth = 640
     DIM ScreenX AS QDXSCREEN
     ScreenX.PARENT = Form
     ScreenX.Init(640, 480)
     ScreenX.Align = alClient

     DIM curItem
     DIM oldItem

     DIM Nitem
     DIM x(10)
     DIM y(10)
     DIM Mstr$(10)

     Nitem=3
     curItem=0
     oldItem=0
     DIM i
     FOR i=1 TO Nitem
      x(i)=100
      y(i)=100+(i-1)*40
     NEXT i
     Mstr$(1)="ON"
     Mstr$(2)="OFF"
     Mstr$(3)="Exit"

     Form.OnPaint=DrawScreen

     ScreenX.OnMouseMove=XMouseMove
     ScreenX.OnClick=XClick

     Form.SHOWMODAL

'------------------------------------------------------------------------------------------------------------

     SUB DrawScreen
      FOR i=1 TO Nitem
       ScreenX.TextOut(x(i),y(i),Mstr$(i),RGB(200,0,0),RGB(0,0,0))
      NEXT i
      ScreenX.Flip
     END SUB

     SUB XMouseMove(curX,curY)
      curItem=0
      FOR i=1 TO Nitem
       IF curX>x(i) AND curX<(x(i)+ScreenX.TextWidth(Mstr$(i))) AND curY>y(i) AND curY<(y(i)+ScreenX.TextHeight(Mstr$(i))) THEN
        curItem=i
        EXIT FOR
       END IF
      NEXT i
      IF oldItem>0 THEN ScreenX.TextOut(x(oldItem),y(oldItem),Mstr$(oldItem),RGB(200,0,0),RGB(0,0,0))
      IF curItem>0 THEN ScreenX.TextOut(x(curItem),y(curItem),Mstr$(curItem),RGB(0,200,0),RGB(0,0,0))
      oldItem=curItem
      ScreenX.Flip
     END SUB

     SUB XClick
      SELECT CASE curItem
      CASE 0:
       ScreenX.TextOut(x(1),y(Nitem)+40,"No selection.                  ",RGB(0,0,255),RGB(0,0,0))
      CASE 1:
       ScreenX.TextOut(x(1),y(Nitem)+40,"Your selection is ON.  ",RGB(0,0,255),RGB(0,0,0))
      CASE 2:
       ScreenX.TextOut(x(1),y(Nitem)+40,"Your selection is OFF.",RGB(0,0,255),RGB(0,0,0))
      CASE 3:
       END
      END SELECT
      ScreenX.Flip
     END SUB
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Thu 2024-10-3  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2013-06-19 07:45:12