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

Form Questions

 
Post new topic   Reply to topic    KiXforms Forum Index -> Discussion
View previous topic :: View next topic  
Author Message
PFish
KiXforms Novice
KiXforms Novice


Joined: 02 Jun 2004
Posts: 3

PostPosted: Wed Jun 02, 2004 3:04 pm    Post subject: Form Questions Reply with quote

I have a couple of questions regarding the Form object. I apologise now if they have been asked before...

1) Is it possible to trap a user clicking the Close button [x] or pressing Alt+F4 to close the application? I can't see any obvious methods which get triggered in an 'OnClose' style.

2) In Windows XP (and I think 2000) if you double-click on a form titlebar the form will maximise even if the form is set to non-resizable. Is there any way to stop this happening?

Here's an example of the code I'm using...


Code:

Break on

$System = CreateObject("Kixtart.System")
If @ERROR
   Quit 0
EndIf

$frmMainForm = $System.Form()

$frmMainForm.Text = "End User Network Agreement"
$frmMainForm.FormBorderStyle = 1
$frmMainForm.Size = 480,480
$frmMainForm.ControlBox = 1
$frmMainForm.ShowInTaskBar = 1
$frmMainForm.Center

$lFormCWidth = $frmMainForm.ClientWidth
$lFormCHeight = $frmMainForm.ClientHeight

$txtEUNA = $frmMainForm.Controls.RichTextBox()
$txtEUNA.Location = 4, 4
$txtEUNA.Size = ($lFormCWidth - 8), ($lFormCHeight - 34)
$txtEUNA.ReadOnly = 1
$txtEUNA.WordWrap = 1
$txtEUNA.MultiLine = 1
$txtEUNA.ScrollBars = 2

$cmdAgree = $frmMainForm.Controls.Button()
$cmdAgree.Location = ($lFormCWidth - 88), ($lFormCHeight - 26)
$cmdAgree.Size = 80, 22
$cmdAgree.Text = "I Agree"
$cmdAgree.Enabled = 1
$cmdAgree.OnClick = "fnAgreeClick()"

$frmMainForm.Show

While $frmMainForm.Visible
   $ = Execute($System.Application.DoEvents())
Loop

Quit 0


Function fnAgreeClick()
   $frmMainForm.Hide
EndFunction


Thanks

Paul

PS I'm running 2.3.0.44 on KiXtart 4.2.2
Back to top
View user's profile Send private message Visit poster's website
Bonji
KiXforms Aficionado
KiXforms Aficionado


Joined: 10 Mar 2003
Posts: 393
Location: Virginia

PostPosted: Wed Jun 02, 2004 4:08 pm    Post subject: Reply with quote

To intercept the close event use .OnClosing.

You can remove the titlebar, but if that is not desirable then I'm not sure what you can do. I'll look into it real quick.

_________________
-Ben
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 Jun 02, 2004 4:10 pm    Post subject: Reply with quote

A quick thought... .OnResize will fire when the form is resized. That may be useful.
_________________
-Ben
Back to top
View user's profile Send private message
sptomey
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 18 Mar 2003
Posts: 158

PostPosted: Wed Jun 02, 2004 4:27 pm    Post subject: Reply with quote

Here an example of how to handle the 'clicking the x' problem...

Code:
Break on

$System = CreateObject("Kixtart.System")
If @ERROR
   Quit 0
EndIf

$frmMainForm = $System.Form()
$frmMainForm.OnClosing = "CloseWarning()"

$frmMainForm.Text = "End User Network Agreement"
$frmMainForm.FormBorderStyle = 1
$frmMainForm.Size = 480,480
$frmMainForm.ControlBox = 1
$frmMainForm.ShowInTaskBar = 1
$frmMainForm.Center

$lFormCWidth = $frmMainForm.ClientWidth
$lFormCHeight = $frmMainForm.ClientHeight

$txtEUNA = $frmMainForm.Controls.RichTextBox()
$txtEUNA.Location = 4, 4
$txtEUNA.Size = ($lFormCWidth - 8), ($lFormCHeight - 34)
$txtEUNA.ReadOnly = 1
$txtEUNA.WordWrap = 1
$txtEUNA.MultiLine = 1
$txtEUNA.ScrollBars = 2

$cmdAgree = $frmMainForm.Controls.Button()
$cmdAgree.Location = ($lFormCWidth - 88), ($lFormCHeight - 26)
$cmdAgree.Size = 80, 22
$cmdAgree.Text = "I Agree"
$cmdAgree.Enabled = 1
$cmdAgree.OnClick = "fnAgreeClick()"

$frmMainForm.Show
While $frmMainForm.Visible
   $ = Execute($System.Application.DoEvents())
Loop
Exit 1

Function fnAgreeClick()
   $frmMainForm.Hide
EndFunction

Function CloseWarning()
   $null = MessageBox("You must click the 'I Agree' button in order to proceed.","Error",4112)
EndFunction

_________________
-Shane
Back to top
View user's profile Send private message MSN Messenger
PFish
KiXforms Novice
KiXforms Novice


Joined: 02 Jun 2004
Posts: 3

PostPosted: Wed Jun 02, 2004 6:08 pm    Post subject: Reply with quote

Bonji wrote:
To intercept the close event use .OnClosing.

sptomey wrote:
Here an example of how to handle the 'clicking the x' problem...


Thanks, that works great. I did think about hooking into the OnResize, I was just hoping there was a way to lock out the resize completely Wink
Back to top
View user's profile Send private message Visit poster's website
Jochen
KiXforms Devotee
KiXforms Devotee


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

PostPosted: Wed Jun 02, 2004 6:28 pm    Post subject: Reply with quote

in reply to the titlebar doubleclick, I can at least say that in Windows 2000 the form remains the same.
You can also omit the setting of BorderStyle to 1 as this is the default Value Wink

Can't say for XP as I don't use that yet (knocking on wood)

_________________
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
sptomey
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 18 Mar 2003
Posts: 158

PostPosted: Wed Jun 02, 2004 6:46 pm    Post subject: Reply with quote

The form does indeed expand on my XP Pro machine.
_________________
-Shane
Back to top
View user's profile Send private message MSN Messenger
sptomey
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 18 Mar 2003
Posts: 158

PostPosted: Wed Jun 02, 2004 6:53 pm    Post subject: Reply with quote

Just remembered a tip that Shawn had given us a couple weeks ago with the .OnResize...

Try this out and see if it's good enough.

Code:
Break on

$System = CreateObject("Kixtart.System")
If @ERROR
   Quit 0
EndIf

$frmMainForm = $System.Form()
$frmMainForm.OnClosing = "CloseWarning()"
$frmMainForm.OnResize = "FormResized()"

$frmMainForm.Text = "End User Network Agreement"
$frmMainForm.FormBorderStyle = 1
$frmMainForm.Size = 480,480
$frmMainForm.ControlBox = 1
$frmMainForm.ShowInTaskBar = 1
$frmMainForm.Center

$lFormCWidth = $frmMainForm.ClientWidth
$lFormCHeight = $frmMainForm.ClientHeight

$txtEUNA = $frmMainForm.Controls.RichTextBox()
$txtEUNA.Location = 4, 4
$txtEUNA.Size = ($lFormCWidth - 8), ($lFormCHeight - 34)
$txtEUNA.ReadOnly = 1
$txtEUNA.WordWrap = 1
$txtEUNA.MultiLine = 1
$txtEUNA.ScrollBars = 2

$cmdAgree = $frmMainForm.Controls.Button()
$cmdAgree.Location = ($lFormCWidth - 88), ($lFormCHeight - 26)
$cmdAgree.Size = 80, 22
$cmdAgree.Text = "I Agree"
$cmdAgree.Enabled = 1
$cmdAgree.OnClick = "fnAgreeClick()"

$frmMainForm.Show
While $frmMainForm.Visible
   $ = Execute($System.Application.DoEvents())
Loop
Exit 1

Function fnAgreeClick()
   $frmMainForm.Hide
EndFunction

Function CloseWarning()
   $null = MessageBox("You must click the 'I Agree' button in order to proceed.","Error",4112)
EndFunction

FUNCTION FormResized()
   If $frmMainForm.WindowState = $System.FormWindowState.Maximized
      $frmMainForm.WindowState = $System.FormWindowState.Normal
   Endif
ENDFUNCTION

_________________
-Shane
Back to top
View user's profile Send private message MSN Messenger
PFish
KiXforms Novice
KiXforms Novice


Joined: 02 Jun 2004
Posts: 3

PostPosted: Thu Jun 03, 2004 12:08 pm    Post subject: Reply with quote

Seems to work great. Thanks a lot guys Huge Grin

sptomey wrote:
Just remembered a tip that Shawn had given us a couple weeks ago with the .OnResize...

Try this out and see if it's good enough.
Back to top
View user's profile Send private message Visit poster's website
kikieh
KiXforms Follower
KiXforms Follower


Joined: 05 Jun 2006
Posts: 21
Location: Brazil - Sao Paulo

PostPosted: Mon Jun 05, 2006 2:15 pm    Post subject: Re: Form Questions Reply with quote

PFish wrote:
2) In Windows XP (and I think 2000) if you double-click on a form titlebar the form will maximise even if the form is set to non-resizable. Is there any way to stop this happening?


$Form.SysMenu = 0
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> 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