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 wait for an event
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion
View previous topic :: View next topic  
Author Message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Sat Dec 17, 2005 8:39 pm    Post subject: How to wait for an event Reply with quote

In my code I have a button that is only enabled during specific times.

When the button is enabled I want everthing to stop till the button is clicked.

I tried using $Button.Value, but that does not appear to be a valid member of the Button class.

I tried setting a "Flag" variable and using the .click event inside of a Do While Loop.

I am unsure of how to use secondary doevents(1), or if this is even what I really want.

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


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Sat Dec 17, 2005 9:45 pm    Post subject: Reply with quote

Here is what I am trying to no avail...

Code:

Function Pause()

$Btn_Cont.Enable = "True"
$Btn_Cont.Visible = "True"
While $Flag <> 1
   $Nul = Execute($Form1.DoEvents(1))
Loop

$Btn_Cont.Enable = "False"
$Btn_Cont.Visible = "False"
$Flag = 0
EndFunction


And here is the code for the button itself...

Code:
$Btn_Cont = $System.Button()
$BTN_Cont.Left = 400
$BTN_Cont.Text = "Continue"
$BTN_Cont.Top = 30
$Btn_Cont.Backcolor = $System.Color.Gray
$BTN_Cont.Forecolor = $System.Color.Black
$BTN_Cont.Font = $System.Font ("Times New Roman",10,$System.FontStyle_Bold)
$BTN_Cont.Click = "$Flag = 1"
$Btn_Cont.Enable = "False"
$Btn_Cont.Visible = "False"
$nul = $LabelG.Controls.Add($BTN_Cont)


Is it possible it is because I made it part of the Label collection?

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


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Sat Dec 17, 2005 10:31 pm    Post subject: Reply with quote

you could go with something like:
Code:
$button.click="nothingReal"
;...
while not instr($events, "nothingReal")
$events = $form.doevents()
loop
"button clicked" ?

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Mon Dec 19, 2005 2:29 pm    Post subject: Reply with quote

That didn't do it.

I am looking to do something like what would happen if I popped up a messagebox, without the messagebox.

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


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Mon Dec 19, 2005 2:38 pm    Post subject: Reply with quote

Well, the easiest way would be to disable all other controls while the button is enabled and enable them back as soon the button gets clicked.

Still you won't be able to get the form in a modal state ... closing it would be still possible

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Mon Dec 19, 2005 3:35 pm    Post subject: Reply with quote

That is a good idea, but how do I get the script to stop processing till the button is clicked?

That is my real problem I think.

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


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Mon Dec 19, 2005 3:44 pm    Post subject: Reply with quote

Don't get it ... stop processing what ?
_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Mon Dec 19, 2005 3:56 pm    Post subject: Reply with quote

At the point that I want to invoke the button I also want the script to stop running and wait till the button is pushed before continuing on.

You can see what I am doing by looking at my other thread which has the script(s) attached.

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


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Mon Dec 19, 2005 4:14 pm    Post subject: Reply with quote

Ah ...

If you disable ALL other controls the Script WILL wait for the button being pusshed ... That's what the synchronous DoEvents is doing ... it sits around waiting for an event to happen Wink

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Mon Dec 19, 2005 4:18 pm    Post subject: Reply with quote

So when you say disable all other controls, is this only items like a checkbox, button etc, or would it basically be everything within the form except the one button?
_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Mon Dec 19, 2005 4:25 pm    Post subject: Reply with quote

Yeah ... have to refine my sentence:

Disable all other controls that may react to an Event Smile

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Mon Dec 19, 2005 4:27 pm    Post subject: Reply with quote

Thanks, I will begin working on that. Sounds simple enough...
_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Mon Dec 19, 2005 10:49 pm    Post subject: Reply with quote

now, that's a huge waste of code.

can I ask, why you say my code didn't do it?

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Mon Dec 19, 2005 10:55 pm    Post subject: Reply with quote

When I implemented your code it never captured the event. Didn't do a whole of debugging either.

So maybe not fair to your example, but I just could not concentrate well this last weekend. I would be willing to give it another go...

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


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Sun Jan 08, 2006 5:22 pm    Post subject: Reply with quote

Finally got back to this and this is the solution that I am using...

Here is the code

Code:


$Btn_Cont = $System.Button()
$BTN_Cont.Left = 400
$BTN_Cont.Text = "Continue"
$BTN_Cont.Top = 2
$Btn_Cont.Backcolor = $System.Color.Gray
$BTN_Cont.Forecolor = $System.Color.Black
$BTN_Cont.Font = $System.Font ("Times New Roman",10,$System.FontStyle_Bold)
$BTN_Cont.Click = "Nul"
$nul = $PanelB.Controls.Add($BTN_Cont)

Function Pause()


$BTN_Roll.Visible = "False"
$BTN_Roll.Enabled = "False"
$BTN_Exit.Visible = "False"
$BTN_Exit.Enabled = "False"
$BTN_Cont.Visible = "True"
$BTN_Cont.Enabled = "True"

$LabelG.Text = $LabelG.text + @CRLF + "Let me know when you are done"
While Not InStr($Events, "Nul")
   $Events = $form1.doevents()
Loop
$BTN_Roll.Visible = "True"
$BTN_Roll.Enabled = "True"
$BTN_Exit.Visible = "True"
$BTN_Exit.Enabled = "True"
$Events = "Reset"
EndFunction


To be honest, I started this post as how to fix what I was doing, but in typing it, realized exactly what it was that I had to do. Had to do with the $Events value.

I appreciate all of the help that you all offer here.

_________________
Parents were invented to make children happy by giving them something to ignore.
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
Goto page 1, 2, 3  Next
Page 1 of 3

 
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