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

KeyEventArgs & KeyPressEventArgs

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


Joined: 14 Mar 2003
Posts: 202
Location: Gothenburg, Sweden

PostPosted: Tue Mar 06, 2007 9:19 pm    Post subject: KeyEventArgs & KeyPressEventArgs Reply with quote

..feeling kinda lonely in here :p

Anyhow; trying to get a function to execute when Esc is pressed (ie, be able to close a form if it's pressed).

I really haven't figured out how the different .NET objects are built/called yet... we really need to get the Wiki going with some sample code Wink

Anyhow, anyone who can help me?
Back to top
View user's profile Send private message MSN Messenger
benny69
KiXforms Advocate
KiXforms Advocate


Joined: 30 Oct 2003
Posts: 567
Location: Lincoln, Ne

PostPosted: Wed Mar 07, 2007 12:56 pm    Post subject: Reply with quote

Click the Close Button or hit Esc on the keaboard.
Code:

Break On
$System = CreateObject("Kixforms.System")
If Not $System
   $nul= MessageBox("KiXforms.Net Not Initiated. This Script Will Now Close.","Error",16)
   Quit()
EndIf

$Form = $System.Form()
$Form.Left = 0
$Form.StartPosition = 0  ;FormStartPosition_Manual
$Form.Size = $System.Size(600,400) ;(Width,Height)
$Form.Text = "Form - Close Button"
$Form.Top = 0

$CloseBtn = $System.Button()
$CloseBtn.Click = 'CloseForm()'
$CloseBtn.DialogResult = 2  ;Cancel
$CloseBtn.Left = 450
$CloseBtn.Text = "Close"
$CloseBtn.Top = 300
$nul = $Form.Controls.Add($CloseBtn)

$Form.CancelButton = $CloseBtn
$Form.Show  ;Displays the Form

While $Form.Visible
   $Nul = Execute($Form.DoEvents())
Loop
Exit 0

Function CloseForm()
   Quit 0
EndFunction

_________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)
Back to top
View user's profile Send private message Send e-mail
masken
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 14 Mar 2003
Posts: 202
Location: Gothenburg, Sweden

PostPosted: Wed Mar 07, 2007 3:35 pm    Post subject: Reply with quote

Ah, there was a predefined function for this, nice! Smile

Worked a little too well hehe.. closed all my forms and not just the form I wanted hehe :p

I tested $MyForm.Close instead which seemed to work.

Thanks alot for the help again benny! The forms are indeed strong in you Nod
Back to top
View user's profile Send private message MSN Messenger
benny69
KiXforms Advocate
KiXforms Advocate


Joined: 30 Oct 2003
Posts: 567
Location: Lincoln, Ne

PostPosted: Wed Mar 07, 2007 7:11 pm    Post subject: Reply with quote

You can also set up the 'EnterKey' if you want, like this:
Code:

Break On
$System = CreateObject("Kixforms.System")
If Not $System
   $nul= MessageBox("KiXforms.Net Not Initiated. This Script Will Now Close.","Error",16)
   Quit()
EndIf

$Form = $System.Form()
$Form.Left = 0
$Form.StartPosition = 0  ;FormStartPosition_Manual
$Form.Size = $System.Size(600,400) ;(Width,Height)
$Form.Text = "Form - Close Button"
$Form.Top = 0

$CloseBtn = $System.Button()
$CloseBtn.Click = 'CloseForm()'
$CloseBtn.Left = 450
$CloseBtn.Text = "Close"
$CloseBtn.Top = 300
$nul = $Form.Controls.Add($CloseBtn)

$OKBtn = $System.Button()
$OKBtn.Click = 'StartSomething()'
$OKBtn.Left = 370
$OKBtn.Text = "OK"
$OKBtn.Top = 300
$nul = $Form.Controls.Add($OKBtn)

$Form.AcceptButton = $OKBtn
$Form.CancelButton = $CloseBtn
$Form.Show  ;Displays the Form
$OKBtn.Focus

While $Form.Visible
   $Nul = Execute($Form.DoEvents())
Loop
Exit 0

Function CloseForm()
  ;Quit 0
   $Form.Close
EndFunction

Function StartSomething()
   ? 'Start Something'
EndFunction

_________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)
Back to top
View user's profile Send private message Send e-mail
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