KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

How to determine if a button is clicked

 
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion
View previous topic :: View next topic  
Author Message
CluM09
KiXforms Follower
KiXforms Follower


Joined: 29 May 2007
Posts: 25

PostPosted: Tue Jan 27, 2009 10:57 pm    Post subject: How to determine if a button is clicked Reply with quote

Hello,

I would like to know how I can determine whether a button is clicked in Kixforms.NET

Any help will be greatly appreciated.

Thanks.
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Wed Jan 28, 2009 1:50 pm    Post subject: Reply with quote

Use the .Click method.

Code:


$BTN_Exit = $System.Button()
$BTN_Exit.FlatStyle = 1  ;Popup
$BTN_Exit.Left = 400
$BTN_Exit.Text = "Exit"
$BTN_Exit.Top = 430
$BTN_Exit.Click = "Over()"
$nul = $Form1.Controls.Add($BTN_Exit)


_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
CluM09
KiXforms Follower
KiXforms Follower


Joined: 29 May 2007
Posts: 25

PostPosted: Thu Jan 29, 2009 4:13 pm    Post subject: How to determine if a button is clicked Reply with quote

Thank you for the reply!

I would assume that the following line will return something:

$nul = $Form1.Controls.Add($BTN_Exit)

What would be the value of $nul when the button is clicked?
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Thu Jan 29, 2009 7:21 pm    Post subject: Reply with quote

I got this one ... Wink

This statement ...

$nul = Form1.Controls.Add($BTN_Exit)

returns a pointer to the control you just added. In your case, you already have a handle to the control ($BTN_Exit) but in some cases, you dont - and would need it returned to you, like if you create buttons on-the-fly, like this:

$BTN_Exit = $Form1.Controls.Add($System.Button())

Assigning it to $nul just "catches" the returned value and effectively discards it.
Back to top
View user's profile Send private message
CluM09
KiXforms Follower
KiXforms Follower


Joined: 29 May 2007
Posts: 25

PostPosted: Fri Jan 30, 2009 3:51 pm    Post subject: Reply with quote

Thank you for the response!

I am using VBScript in the ScriptForm Designer from AdminScriptEditor by iTripoli. I have a button that I want to cancel the operation of the program during execution.

How can I convert this code to VBScript?
Back to top
View user's profile Send private message
CluM09
KiXforms Follower
KiXforms Follower


Joined: 29 May 2007
Posts: 25

PostPosted: Wed Feb 04, 2009 2:51 pm    Post subject: Reply with quote

Basically, I have a For..Next loop within the VBscript code to run some task. I like to insert the Execute(Formname.DoEvent) within the loop so that when I click on the button, it will quit the VBScript and close the form.

However, when I insert the Execute(Formname.DoEvent) code within the For...Next Loop, the loop cannot proceed. The loop just hangs at the Execute(Formname.DoEvernt) line indefinitely.

How can I break the loop with a button click?

Thanks for any suggestion.
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Wed Feb 04, 2009 5:07 pm    Post subject: Reply with quote

The syntax of DoEvents looks like this:

Public Function DoEvents( _
Optional ByVal wait As Boolean = True _
) As String

Try setting the optional wait parameter to false (don't wait) like this:

$= $Form1.DoEvents(0)

Might want to put a tiny sleep 0.100 (msecs) in your loop now though. So that the script doesn't soak-up CPU time in a tight loop.
Back to top
View user's profile Send private message
CluM09
KiXforms Follower
KiXforms Follower


Joined: 29 May 2007
Posts: 25

PostPosted: Wed Feb 04, 2009 5:59 pm    Post subject: Reply with quote

Could you please let know me know how I can set the wait parameter to false?

Do you mean insert the following code within the For...Next loop like

Nul = Form1.DoEvents(0)

and try the button click to see if it will break the loop?

I am new to Kixforms, and need some help. I tried to translate Kixtart to VBscript.

Thanks.
Back to top
View user's profile Send private message
CluM09
KiXforms Follower
KiXforms Follower


Joined: 29 May 2007
Posts: 25

PostPosted: Wed Feb 04, 2009 9:56 pm    Post subject: Reply with quote

I tried your suggestion, and it appears to work but I have to keep clicking the button many times before it actually breaks the loop.

How I can break the loop immediately?

Thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group