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 Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion
View previous topic :: View next topic  
Author Message
Lonkero
KiXforms Devotee
KiXforms Devotee


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

PostPosted: Mon Jan 09, 2006 1:04 am    Post subject: Reply with quote

hmm...
you have the while loop there without any execute...
does the form remain minimizable and so on?
basically, it shouldn't.

also, you don't need to disable the buttons if you are checking the events value without execute.
on the other hand, as you have them disabled, you should be able to add execution of the stuff there too, thus enabling the form draw and so on.

_________________
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 Jan 09, 2006 12:15 pm    Post subject: Reply with quote

the DoEvents() is in another part of the script. You are most likely correct that I probably don't need to disable the other controls, but since the button appears in the same place as the other controls it does not hurt.

I have not tried minimizing the form or any other type of action while in the loop, may have to check that out.

_________________
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 Jan 09, 2006 9:28 pm    Post subject: Reply with quote

another part of the script, right.
remember my solution back there?
it did have the execute inside the block.

_________________
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: Tue Jan 10, 2006 12:54 am    Post subject: Reply with quote

Just looked back at the code I posted and their is a DoEvents() in the while loop.

So now I am just confused....

I am not "Executing" it, is that because I have another one in the script, or am I off in left field somewhere again?

_________________
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: Tue Jan 10, 2006 1:14 am    Post subject: Reply with quote

you skipped the execution but that's what makes kixforms do basically anything.
again, I'm not sure does missing it halt KF like it used to.

_________________
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: Tue Jan 10, 2006 6:08 pm    Post subject: Reply with quote

Hey Shawn I think that was a question for you. I know I can not answer it.
_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Tue Jan 10, 2006 6:28 pm    Post subject: Reply with quote

eh? what was the question again ?
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Tue Jan 10, 2006 6:46 pm    Post subject: Reply with quote

Quote:
I'm not sure does missing it halt KF like it used to.


Lonkero's last post....

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


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Tue Jan 10, 2006 7:03 pm    Post subject: Reply with quote

ummm, hmmmm ,,,, missing the DoEvents loop does not "halt" anything per se ... missing the Execute(tion) of the DoEvents certainly does halt any events that your trying to catch ... and dont forget, there are two versions of the DoEvents ...

$Form.DoEvents() will pause execution of the script until an event happens (any event) ...

$Form.DoEvents(1) will "check for" an event, and return the event if there is one, else it will return an empty string.

Not sure if this answered the question.


Last edited by Shawn on Tue Jan 10, 2006 7:12 pm; edited 1 time in total
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Tue Jan 10, 2006 7:10 pm    Post subject: Reply with quote

woops - are we talking kf classic or kf.net ? The asynchronous DoEvents(1) isn't in kf.net yet ...
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Tue Jan 10, 2006 10:37 pm    Post subject: Reply with quote

In my case I am using .Net.

Am I doing this the wrong way in the snippet as seen here...

In the script I have
While $Form.Visible
$= Execute($Form.DoEvents)
Loop


In one of the functions that runs as a result of an event I have the code that I posted above in particular

While Not InStr($Events, "Nul")
$Events = $form1.doevents()
Loop

My thinking was that when the event was captured in the original DoEvents, all I was doing was assigning that capture to $Events

Am I doing it the wrong way?

_________________
Parents were invented to make children happy by giving them something to ignore.
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 Jan 11, 2006 12:26 am    Post subject: Reply with quote

Based on my read I would say yeah, your doing it wrong. Just based on this statement here:

"My thinking was that when the event was captured in the original DoEvents, all I was doing was assigning that capture to $Events"

I assume that there was an "original event" that took you to this new bit code, once in this new bit you are running the different DoEvents. But don't expect that "orginal event" to still "be there", waiting to be re-assigned or anything - for all intents and purposes its "gone" forever. And, if there was no "new event" in the queue, then the DoEvents will indeed wait the script until a new event happened.

Having said that - you havent shown me any code that (from what I can see) "shouldn't or wouldn't work" - but what you are doing needs to be carefully thought-out and planned - so keep at it.
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: Wed Jan 11, 2006 6:42 am    Post subject: Reply with quote

k, checked.
the form is alive and well even though you don't execute no events.

again, that said, you don't need to disable the buttons anyways.
it might look clearer though if you do.

_________________
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: Wed Jan 11, 2006 2:09 pm    Post subject: Reply with quote

You say that I am not executing any events....

My script (to big to post the whole thing) is something like this...
Code:

;Build a form
$Form1 = $System.Form()
$Form1.StartPosition = 1  ;FormStartPosition_Center
$Form1.Size = $System.Size(1005,850) ;(Width,Height)
$Form1.Text = "Game Board"
$Form1.BackgroundImage = $System.Bitmap($DefaultPath+"\images\board.jpg")
$PanelB = $System.Panel()
$PanelB.BorderStyle = 1  ;FixedSingle
$PanelB.Top = 750
$PanelB.Width = 1000
$PanelB.BackColor = $System.Color.gray
$nul = $Form1.Controls.Add($PanelB)

$t = 750
$l = 0
For $a=1 to 100 step 20
$t = $t -75
$l = 0
   For $forward = $a to $a+10 step 1    
      $nul = Execute("$Panel"+$forward+" = $System.Panel()")
      $nul = Execute("$Panel"+$forward+".BorderStyle = 1")
      $nul = Execute("$Panel"+$forward+".Left = "+$l)
      $nul = Execute("$Panel"+$forward+".Top = "+$t)
      $nul = Execute("$Panel"+$forward+".Width = 100")
      $nul = Execute("$Panel"+$forward+".Height = 75")
      $nul = Execute("$Panel"+$forward+".BackColor = $System.Color.Transparent")
      $nul = Execute("$nul = $Form1.Controls.Add($Panel"+$forward+")")
      $l = $l + 100
   Next
$t = $t -75
$l = 0
   For $backward = $a+19 to $a+10 step -1
      $nul = Execute("$Panel"+$backward+" = $System.Panel()")
      $nul = Execute("$Panel"+$backward+".BorderStyle = 1")
      $nul = Execute("$Panel"+$backward+".Left = "+$l)
      $nul = Execute("$Panel"+$backward+".Top = "+$t)
      $nul = Execute("$Panel"+$backward+".Width = 100")
      $nul = Execute("$Panel"+$backward+".Height = 75")
      $nul = Execute("$Panel"+$backward+".BackColor = $System.Color.Transparent")
      $nul = Execute("$nul = $Form1.Controls.Add($Panel"+$backward+")")
      $l = $l + 100
   Next
Next

$PictureBox1 = $System.PictureBox()
$PictureBox1.BorderStyle = 1  ;FixedSingle
$PictureBox1.Left = 3
$PictureBox1.Top = 9
$PictureBox1.Width = 50
$PictureBox1.Height = 50
$nul = $PanelB.Controls.Add($PictureBox1)

$Label1 = $System.Label()
$Label1.BorderStyle = 1  ;FixedSingle
$Label1.Left = 56
$Label1.Text = "Label1"
$Label1.TextAlign = 16  ;MiddleLeft
$Label1.Top = 2
$Label1.Visible = "False"
$nul = $PanelB.Controls.Add($Label1)

$Label2 = $System.Label()
$Label2.BorderStyle = 1  ;FixedSingle
$Label2.Left = 172
$Label2.Text = "Label2"
$Label2.TextAlign = 16  ;MiddleLeft
$Label2.Top = 2
$Label2.Visible = "False"
$nul = $PanelB.Controls.Add($Label2)

$Label3 = $System.Label()
$Label3.BorderStyle = 1  ;FixedSingle
$Label3.Left = 289
$Label3.Text = "Label3"
$Label3.TextAlign = 16  ;MiddleLeft
$Label3.Top = 2
$Label3.Visible = "False"
$nul = $PanelB.Controls.Add($Label3)

$Label4 = $System.Label()
$Label4.BorderStyle = 1  ;FixedSingle
$Label4.Left = 56
$Label4.Text = "Label4"
$Label4.TextAlign = 16  ;MiddleLeft
$Label4.Top = 35
$Label4.Visible = "False"
$nul = $PanelB.Controls.Add($Label4)

$Label5 = $System.Label()
$Label5.BorderStyle = 1  ;FixedSingle
$Label5.Left = 174
$Label5.Text = "Label5"
$Label5.TextAlign = 16  ;MiddleLeft
$Label5.Top = 35
$Label5.Visible = "False"
$nul = $PanelB.Controls.Add($Label5)

$Label6 = $System.Label()
$Label6.BorderStyle = 1  ;FixedSingle
$Label6.Left = 288
$Label6.Text = "Label6"
$Label6.TextAlign = 16  ;MiddleLeft
$Label6.Top = 35
$Label6.Visible = "False"
$nul = $PanelB.Controls.Add($Label6)

$BTN_Roll = $System.Button()
$BTN_Roll.Left = 400
$BTN_Roll.Text = "Roll Die"
$BTN_Roll.Top = 2
$BTN_Roll.Forecolor = $System.Color.Black
$BTN_Roll.Font = $System.Font ("Times New Roman",10,$System.FontStyle_Bold)
$BTN_Roll.Click = "Roll()"
$nul = $PanelB.Controls.Add($BTN_Roll)

$LabelG = $System.Label()
$LabelG.BorderStyle = 1  ;FixedSingle
$LabelG.Left = 490
$LabelG.TextAlign = 16  ;MiddleLeft
$LabelG.Top = 2
$LabelG.Height = 65
$LabelG.Width = 500
$LabelG.BackColor = $system.Color.Black
$LabelG.ForeColor = $system.Color.White
$nul = $PanelB.Controls.Add($LabelG)


$BTN_Exit = $System.Button()
$BTN_Exit.Left = 400
$BTN_Exit.Text = "Exit"
$BTN_Exit.Top = 32
$BTN_Exit.Forecolor = $System.Color.Black
$BTN_Exit.Font = $System.Font ("Times New Roman",10,$System.FontStyle_Bold)
$BTN_Exit.Click = "Gover()"
$nul = $PanelB.Controls.Add($BTN_Exit)

$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)

;Run the form

While $Form1.Visible
$= Execute($Form.DoEvents)
Loop

;A whole bunch of functions that do many different things upon events happening. (in particular the BTN_Roll.Click event)

;One of the functions that is running calls this function

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




So in my thinking (and hopefully conveyed correctly here)..
When I do the While Not Instr... loop I am not Executing the DoEvents, but the DoEvents is still happening because it is what is keeping everything running to begin with.
All I am really doing is capturing the .click event and looking to see what string is returned to it, correct?

_________________
Parents were invented to make children happy by giving them something to ignore.
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 Jan 11, 2006 8:51 pm    Post subject: Reply with quote

I would say "yes" - your last statement is absolutely correct. I would assume that you have some control "out there" visible that returns a string that has the word "Nul" in it, else you will be looping forever - plus, you did state that since your aware that your not "Execute(ing)" these events, that the events are not actually being executed - that your just "scanning" them.

Now - if you want to execute AND scan the events - that is a whole different story - and the code would look much different than what you got there.
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 Previous  1, 2, 3  Next
Page 2 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