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

Application Modal?

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


Joined: 27 Jan 2004
Posts: 332

PostPosted: Wed Jun 20, 2007 1:04 am    Post subject: Application Modal? Reply with quote

Hi, I'm trying to apply modal to a child form. I want to be able to restrict the user from accessing the parent form when working in the child form. I tried using the KF Classic code from my other programs, but I couldn't get it to work. Any ideas?

Code:

$frmParent = $System.Form()

$frmChild = $System.Form($frmParent)

$frmChild.ShowModal()
While $frmChild.Visible
  $ = Execute($frmChild.DoEvents())
Loop
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 Jun 20, 2007 1:17 am    Post subject: Reply with quote

Can you just disable the parent form while working in the child form ?
Back to top
View user's profile Send private message
benny69
KiXforms Advocate
KiXforms Advocate


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

PostPosted: Wed Jun 20, 2007 1:37 pm    Post subject: Reply with quote

Hi Pearly,

I think this is what Shawn is hinting at:
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

$frmParent = $System.Form()
$frmParent.Size = $System.Size(400,300)

$ParentButton = $System.Button()
$ParentButton.Click = "Parent_Click()"
$ParentButton.Text = "Show Child"
$nul = $frmParent.Controls.Add($ParentButton)
$ParentButton.Center

$frmChild = $System.Form()
$frmChild.Closing = "ChildFormClosing()"
$frmChild.Owner = $frmParent

$ChildButton = $System.Button()
$ChildButton.Click = "Child_Click()"
$ChildButton.Text = "Child"
$nul = $frmChild.Controls.Add($ChildButton)
$ChildButton.Center

$frmParent.Show()

While $frmParent.Visible
   If $frmChild.Visible
      If Not($frmParent.Enabled = 0)
         $frmParent.Enabled = 0
         $WinDir = %windir%
         $System.Sound.Play($WinDir+"\Media\ding.wav")
      EndIf
      $frmChild.Activate
   Else
      $frmParent.Enabled = -1
      $frmParent.Activate
   EndIf
   $nul = Execute($frmParent.DoEvents())
Loop

Function Parent_Click()
   $frmChild.Show()
EndFunction

Function Child_Click()
   ? "Child Click"
EndFunction

Function ChildFormClosing()
   $frmChild.ClosingEventArgs.Cancel = -1
   $frmChild.Hide
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
pearly
KiXforms Aficionado
KiXforms Aficionado


Joined: 27 Jan 2004
Posts: 332

PostPosted: Wed Jun 20, 2007 6:00 pm    Post subject: Reply with quote

Ahhh, this is something new that I haven't seen in KF Classic.

Code:

$frmChild.Owner = $frmParent


Also the use of the Activate method and Enabled property.

Thanks Benny, I got this working! Kudos Cool
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
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