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

Preventing users from closing Visible Form

 
Post new topic   Reply to topic    KiXforms Forum Index -> Starters Code Clinic
View previous topic :: View next topic  
Author Message
VTC
KiXforms Dabbler
KiXforms Dabbler


Joined: 08 May 2008
Posts: 10

PostPosted: Tue Jul 21, 2009 1:27 pm    Post subject: Preventing users from closing Visible Form Reply with quote

If all possible Id like to prevent users from closing a form that displays a message, however, i realize that it may be a hard task so Ill settle for the next best thing. The Break Command.

However, the break command does not seem to playing very well, it does not auto logoff the user when they close the form. So it kind of defeats my warning that if they do, it will log them off.

I have tried Break On, Break Off, and then commented out break. Now i tested this in simple kixtart scripting without kixforms, and the commented out break command (no break command) works.

Any suggestions.

SetConsole("Hide")
$System = CreateObject("Kixtart.System")

;Break On

;KD START

$Form = $System.Form()
$Form.BackColor = 212,208,200
$Form.Height = 401
$Form.Left = 386
$Form.Text = "KiXforms Designer Template"
$Form.Top = 189
$Form.Width = 382
$Form.ControlBox = "False"
$Form.TopMost = "True"
$Label1 = $Form.Controls.Label()
$Label1.BackColor = 212,208,200
$Label1.FontSize = 15
$Label1.ForeColor = 255,0,0
$Label1.Height = 96
$Label1.Left = 15
$Label1.Text = "WARNING: Do not attempt to close this dialog box. Doing so will result in an immediate logoff, and potential loss of any unsaved data."
$Label1.Top = 30
$Label1.Width = 355
$Label2 = $Form.Controls.Label()
$Label2.BackColor = 212,208,200
$Label2.Height = 95
$Label2.Left = 15
$Label2.Text = "This message is to inform you that your machine has been successfully updated and requires an immediate restart for those updates to take effect. Please save any unsaved documents, and click ok to acknoledge this message. Upon clicking ok a forced restart will be applied and you will have 1 hour to save any documents. We encourage you to restart the machine prior to the expiration of this timer."
$Label2.Top = 135
$Label2.Width = 356
$Label3 = $Form.Controls.Label()
$Label3.BackColor = 212,208,200
$Label3.Height = 32
$Label3.Left = 15
$Label3.Text = "Please press ok to acknoledge this message. Save any unsaved documents and restart."
$Label3.Top = 240
$Label3.Width = 353
$Button1 = $Form.Controls.Button()
$Button1.Height = 23
$Button1.Left = 150
$Button1.Text = "Ok"
$Button1.Top = 315
$Button1.Width = 75
$Button1.OnClick = "Button1_Click()"

;KD END

$Form.Show
$Form.Visible = True
While $Form.Visible
$=Execute($Form.DoEvents())
Loop
Exit 1

Function Button1_Click()
;rc=Shutdown("","Windows Update Complete, please save all of your active work and restart this machine prior till this timers expiration.","3600","0","1")
Run 'shutdown -r -f -t 3600 -c "Windows Update Complete, please save all of your active work and restart this machine prior till this timers expiration."'
$Form.Visible = False
EndFunction
Back to top
View user's profile Send private message
eriqjaffe
KiXforms Follower
KiXforms Follower


Joined: 16 Aug 2004
Posts: 19
Location: Arlington Heights, IL, USA

PostPosted: Wed Jul 22, 2009 4:43 pm    Post subject: Reply with quote

It's a bit hacky, but you could always add a call to your Button1_Click() function after the While $Form.Visible loop:

Code:
$Form.Show
$Form.Visible = True
While $Form.Visible
$=Execute($Form.DoEvents())
Loop

Button1_Click()

Exit 1


Then, when the form is closed (regardless of how it's closed), it will start the logoff process. Granted, the shutdown can still be canceled by opening up a command prompt and entering "shutdown -a". Most users don't know about that, but it still leaves that door open. I'm not sure if KiXtart's built-in shutdown command is subject to that or not.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Starters Code Clinic 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