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

Detect if form is closed with 'x'

 
Post new topic   Reply to topic    KiXforms Forum Index -> Advanced Scripting
View previous topic :: View next topic  
Author Message
Iskander
KiXforms Dabbler
KiXforms Dabbler


Joined: 05 Sep 2006
Posts: 5

PostPosted: Tue Sep 05, 2006 2:55 pm    Post subject: Detect if form is closed with 'x' Reply with quote

Hi,

Is there a way to detect if a form was closed with the 'x' in Windows (in upper-right corner) or Alt-F4??

I want to prevent some things from running when something like that happens...
Or is it possible to hide the 'x' and minimize and maximize buttons??
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: Tue Sep 05, 2006 3:12 pm    Post subject: Reply with quote

Yes, and Yes,

To set code in the event the form is closed, just place the code after the 'while form.visible do events'-loop Wink

to hide the things set .ControlBox property to false (this doesn't prevent the user form closing the form in another way)

_________________
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
benny69
KiXforms Advocate
KiXforms Advocate


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

PostPosted: Tue Sep 05, 2006 5:18 pm    Post subject: Reply with quote

Iskander,
Here is an example of what Jochen is talking about:
Code:

Break On

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

$ParentForm = $System.Form()
$ParentForm.Text = "Parent Form"

$ChildForm = $System.Form($ParentForm)
$ChildForm.Text = "Child Form"
$ChildForm.Size = $ParentForm.ClientSize
$Border = ($ParentForm.Width - $ParentForm.ClientWidth)/2
$ChildForm.Top = $ParentForm.Top + ($ParentForm.Height - $ParentForm.ClientHeight) - $Border
$ChildForm.Left = $ParentForm.Left + $Border

$ParentForm.Center()
$ParentForm.Show()

$ChildForm.Show()

While $ParentForm.Visible
   $= Execute($ParentForm.DoEvents())
   If Not($ChildForm.Visible)
      Do_Something_If_ChildForm_Is_Closed()
   EndIf
Loop
Exit 0

Function Do_Something_If_ChildForm_Is_Closed()
   $nul= MessageBox("Your In Trouble Now!.","Error",16)
   $ChildForm.Show()
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
Iskander
KiXforms Dabbler
KiXforms Dabbler


Joined: 05 Sep 2006
Posts: 5

PostPosted: Wed Sep 06, 2006 7:02 am    Post subject: Reply with quote

Great!! Thanx!!

The .ControlBox does the trick!
Back to top
View user's profile Send private message
Bonji
KiXforms Aficionado
KiXforms Aficionado


Joined: 10 Mar 2003
Posts: 393
Location: Virginia

PostPosted: Wed Oct 04, 2006 3:53 pm    Post subject: Reply with quote

If I want to control how the form is closed or if I need a process to run when a form is closed, I will use the OnClosing property.

Code:

$Form.OnClosing = "fnCloseForm()"

Function fnCloseForm()
   $ = MessageBox("You can't close me.","Hahahaha")
EndFunction


This prevents closing the form via any method. The only way to close the form now is to kill the kix32.exe process. You should always have a way out of the script if you were to implement something like this (i.e. Quit() function somewhere).

_________________
-Ben
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Advanced Scripting 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