Page 1 of 1 1
Topic Options
#202675 - 2011-07-15 06:52 PM Modal Form in Kix
stlaurentm Offline
Fresh Scripter

Registered: 2011-02-07
Posts: 16
Loc: NY
I have tried to use the $form.ShowModal() that I see others mentioned in the forums but it is not working. I am trying to prevent users from clicking anywhere and stay on the kix form until they click on yes or no

I have tried the OnLostFocus, although it is calling the function I created but users are still able to do otherthing unless I force a shutdown which MGMT does not like..

what am I doing wrong .. I would love to use the "ShowModal" if it exist just like in VB

Any help is appreciated

Thanks

Top
#202687 - 2011-07-15 11:53 PM Re: Modal Form in Kix [Re: stlaurentm]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
What was wrong with using .OnDeactivate like in the example I posted here...

http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=202548

Top
#202690 - 2011-07-16 12:22 AM Re: Modal Form in Kix [Re: ShaneEP]
stlaurentm Offline
Fresh Scripter

Registered: 2011-02-07
Posts: 16
Loc: NY
nothing it worked well but instead of shutting down the computer mgmt. wants to keep the user on the form and prevent them from doing anything but answering yes or no
Top
#202702 - 2011-07-18 04:06 PM Re: Modal Form in Kix [Re: stlaurentm]
stlaurentm Offline
Fresh Scripter

Registered: 2011-02-07
Posts: 16
Loc: NY
I guess this is not possible .. I haven't had any feedback

does anyone out there knows if this is possible.. if so I can use your help


Thanks

Top
#202703 - 2011-07-18 04:18 PM Re: Modal Form in Kix [Re: stlaurentm]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4567
Loc: USA
You may have to wait until Shawn comes around for an answer. He is not as active as he used to be.
Top
#202705 - 2011-07-18 07:42 PM Re: Modal Form in Kix [Re: Allen]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Give this method a try...It uses the WindowState property to bring it back to the front if it gets clicked off of.

 Code:
Break Off

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

$form1 = $System.Form()
$Form1.FormBorderStyle = 1
$Form1.MaximizeBox = 0 ;False
$Form1.MinimizeBox = 0 ;False
$Form1.ControlBox = -1 ;True
$Form1.StartPosition = 1 ;FormStartPosition_CenterScreen
$Form1.Size = $System.Size(625,260) ;(Width,Height)
$Form1.Text = "MSL"

$button1 = $form1.Controls.ToolButton()
$button1.Text = "Yes"
$button1.OnClick = "ExitingToDeskTop()"
$button1.Location = $System.Point(100, 200)

$button2 = $form1.Controls.ToolButton()
$button2.Text = "No"
$button2.OnClick = "ExitingApp()"
$button2.Location = $System.Point(400, 200)

;$Label1 = $form1.Label()
$Label1 = $form1.Controls.Add("Label")
$Label1.BorderStyle = 0 ;FixedSingle
$Label1.Font = $System.Font("Microsoft Sans Serif",14.25,1) ;Bold
$Label1.Left = 10
$Label1.Text = "Test text 1"
;$Label1.Text = LoadIniPolicy()
$Label1.Top = 10
$Label1.Width = 600
$Label1.Height = 150

;$Label2 = $form1.Label()
$Label2 = $form1.Controls.Add("Label")
$Label2.BorderStyle = 0 ;FixedSingle
$Label2.Font = $System.Font("Microsoft Sans Serif",14.25,1) ;Bold
$Label2.ForeColor = $System.Color.FromName("Red")
$Label2.Left = 10
$Label2.Text = "Test text 2"
;$Label2.Text = $strmsg2
$Label2.Top = 150
$Label2.Width = 600
$Label2.Height = 50

$button1.default = true
$button2.cancel = true

$Form1.Show()
$Form1.SetFocus()
$Form1.OnDeactivate = "RegainFocus()"

While $Form1.Visible
   $Nul = Execute($Form1.DoEvents)
Loop

Exit 0

;*************************************** REGAINS FOCUS ON FORM IF CLICKED OFF **********************************
Function RegainFocus()
   $Form1.WindowState = 1
   $Form1.WindowState = 0
EndFunction
;*************************************************************************************************************************

;*************************************** QUIT APPLICATION AND SHUT DOWN PC **********************************
Function ExitingApp()
   $= $System.MessageBox.Show("shutting you down")
   $Form1.Hide()
Endfunction
;*************************************************************************************************************************

;*************************************** QUIT APPLICATION GIVE USER ACCESS **********************************
Function ExitingToDeskTop()
   $= $System.MessageBox.Show("Continue to Desktop ...")
   $Form1.Hide()
Endfunction 
;*************************************************************************************************************************

Top
#202709 - 2011-07-19 12:39 AM Re: Modal Form in Kix [Re: ShaneEP]
stlaurentm Offline
Fresh Scripter

Registered: 2011-02-07
Posts: 16
Loc: NY
Thank you

I will try it and let you know

Top
#202710 - 2011-07-19 01:05 AM Re: Modal Form in Kix [Re: stlaurentm]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
On a second look, I noticed this still allowed the upper-right X button to close the form with no consequence...

So change this function...
 Code:
Function RegainFocus()
   $Form1.WindowState = 1
   $Form1.WindowState = 0
EndFunction
To this...
 Code:
Function RegainFocus()
   If $Form1.Visible
      $Form1.WindowState = 1
      $Form1.WindowState = 0
   Else
      ExitingApp()
   Endif
EndFunction

Top
#202711 - 2011-07-19 01:34 AM Re: Modal Form in Kix [Re: stlaurentm]
stlaurentm Offline
Fresh Scripter

Registered: 2011-02-07
Posts: 16
Loc: NY
thanks a millions .. It works great.

Thanks all for the great support

Top
#202712 - 2011-07-19 05:28 AM Re: Modal Form in Kix [Re: stlaurentm]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4567
Loc: USA
With me being a kixform newb, would you mind explaining why you set the value to 1 and then 0?
Top
#202713 - 2011-07-19 06:36 PM Re: Modal Form in Kix [Re: Allen]
stlaurentm Offline
Fresh Scripter

Registered: 2011-02-07
Posts: 16
Loc: NY
Shane,

Would you know what I need to do to make the script run on a MAC beside giving them a PC or am I S.O.L witk these MAC users.

thanks

Top
#202714 - 2011-07-19 07:17 PM Re: Modal Form in Kix [Re: Allen]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Allen,

$Form.WindowState changes the display characteristics of a defined window. $Form defines the window earlier in the code. Setting the value to 1 minimizes it and setting it to 0 returns it to a "normal" window. A value of 2 would maximize the window. Setting it to 1 and then 0 has the effect of bringing the window to the foreground and making it active.

It happens so fast that the minimize/restore operation just looks like the window popped to the foreground.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#202715 - 2011-07-19 07:18 PM Re: Modal Form in Kix [Re: stlaurentm]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Allen...It is simply telling the form to minimize (1) and then restore to normal (0). This was the only way I could find that would refocus the form and bring it to the front.

stlaurentm...Honestly I have no idea about the availability of kixforms on Macs. I've never owned one, and probably never will lol. But I would guess No...
It looks like it may work in parallels though according to this old post...
http://www.kixforms.org/forum/viewtopic.php?t=1585

Top
#202716 - 2011-07-19 07:37 PM Re: Modal Form in Kix [Re: ShaneEP]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4567
Loc: USA
slick. Thanks for the explanations.
Top
#202717 - 2011-07-19 08:05 PM Re: Modal Form in Kix [Re: Allen]
stlaurentm Offline
Fresh Scripter

Registered: 2011-02-07
Posts: 16
Loc: NY
Thanks Shane, I will give it a try ortherwise .. oh Well .. mgmt needs to make a decision

Thanks again

Top
#202718 - 2011-07-20 02:45 AM Re: Modal Form in Kix [Re: stlaurentm]
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
We talking kixforms classic or kixforms.net ?
Top
#202719 - 2011-07-20 05:52 AM Re: Modal Form in Kix [Re: Shawn]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
The example I made for him earlier uses classic.
Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 764 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.071 seconds in which 0.027 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org