Guidance
指路人
g.yi.org
Guidance Forums / Rapid-Q Basic / get info which Button was pressed for the following code

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

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. get info which Button was pressed for the following code
#1147
Posted by: qmark 2004-01-20 22:13:14
$INCLUDE "RAPIDQ.INC"
$TypeCheck ON
$Optimize ON
$APPTYPE GUI

DIM x as integer

Const Gwl_Hwndparent = (-8)
Const Hwnd_Desktop = 0
DECLARE FUNCTION SetWindowLong Lib "user32"Alias"SetWindowLongA"(hwnd As Long, nIndex As Long, dwNewLong As Long) As Long
DECLARE SUB Buttonclick
DECLARE SUB start

CREATE FORM AS QFORM
   left =274
   top =156
   width =583
   height =379
   Caption = "DEFAULT"
   OnShow = start

END CREATE

for x = 1 to 10
   DIM BUT(x) AS QBUTTON
   BUT(x).parent=Form
   BUT(x).top=10
   BUT(x).width=40
   BUT(x).left=5+x*42
   BUT(x).onclick=Buttonclick
next x

SetWindowLong(FORM.Handle, GWL_HWNDPARENT, HWND_Desktop)
SetWindowLong(Application.Handle, GWL_HWNDPARENT,FORM.Handle)

FORM.showmodal

  


SUB Buttonclick

    ??????

END SUB
Message2. Re: get info which Button was pressed for the following code
#1148
Posted by: 2004-01-21 00:16:11
In the loop, BUT(x).Tag = x

SUB Buttonclick(Sender AS QBUTTON)
   SHOWMESSAGE "Button " + STR$(Sender.Tag) + " clicked"
END SUB

The button's .Caption or .TabOrder can also be used in the same way.

Message3. Re: get info which Button was pressed for the following code
#1149
Posted by: 2004-01-24 05:34:08

...

DECLARE SUB Buttonclick (sender As QButton)

...

In the loop    BUT(x).Tag = x

...

SUB Buttonclick (sender As QButton)
    Select Case Sender.Tag
          Case 1

          Case 2
  
          ...



    End Select
END SUB


You can use   If Sender.Handle = But(x).Handle Then

Jacques
Message4. Re: get info which Button was pressed for the following code
#1151
Posted by: qmark 2004-01-31 00:11:30
thanx both for quick and usefull help


qmark
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sat 2024-10-5  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0