ShaneEP
(MM club member)
2011-02-12 05:47 PM
KixForms Show() and Hide()

Im having a strange problem doing something I thought would be simple. Just trying to create a 2nd form from the primary one, and then go back. What am I doing wrong here?

 Code:
$System = CreateObject("Kixtart.System")

$Form1 = $System.Form()
$Form1.Width = 318
$Form1.Height = 350
$Form1.Icon = 81
$Form1.Resizable = 0
$Form1.MaximizeBox = 0
$Form1.Location = 200, 200
$Form1.Text = "MAIN"
$SettingsButton = $Form1.Controls.Add("ToolButton")
$SettingsButton.Text = "Settings"
$SettingsButton.Enabled = 1
$SettingsButton.Width = 75
$SettingsButton.Height = 25
$SettingsButton.Top = 20
$SettingsButton.Left = 20
$SettingsButton.OnClick = "SettingsForm()"
$Form1.Show()
While $Form1.Visible
   $null = Execute($Form1.DoEvents)
Loop
Exit 0

Function SettingsForm()
   $SettingsForm = $System.Form()
   $SettingsForm.Width = 318
   $SettingsForm.Height = 350
   $SettingsForm.Icon = 81
   $SettingsForm.Resizable = 0
   $SettingsForm.MaximizeBox = 0
   $SettingsForm.Location = 200, 200
   $SettingsForm.Text = "SETTINGS"
   $SettingsCloseButton = $SettingsForm.Controls.Add("ToolButton")
   $SettingsCloseButton.Text = "Close"
   $SettingsCloseButton.Enabled = 1
   $SettingsCloseButton.Width = 75
   $SettingsCloseButton.Height = 25
   $SettingsCloseButton.Top = 20
   $SettingsCloseButton.Left = 20
   $SettingsCloseButton.OnClick = "$$SettingsForm.Hide()"
   $SettingsForm.Show()
   $Form1.Hide()
   While $SettingsForm.Visible
      $null = Execute($SettingsForm.DoEvents)
   Loop
   $Form1.Show()
   Exit 0
EndFunction

btw...Using KixForms Classic 2.46


ShaneEP
(MM club member)
2011-02-12 06:11 PM
Re: KixForms Show() and Hide()

Nevermind...Must be one of those weird reserved words type of things. Whenever I change the name of the second form to anything but $SettingsForm, the error goes away. Change it back, and the error returns.

ChristopheM
(Hey THIS is FUN)
2011-02-15 05:01 PM
Re: KixForms Show() and Hide()

something strange in your code.
in the first part of initialization, SettingsForm appears !!!

may be should you declare all variables with dim or global and use SettingsForm only in the function


ShaneEP
(MM club member)
2011-02-15 09:38 PM
Re: KixForms Show() and Hide()

Guess I don't see what you're talking about? The SettingsForm IS only called in the SettingsForm function. But like I said...I change the name from $SettingsForm to $ChangeSettingsForm, and all is as expected. I think I've run into this problem before with a function named Quit(). I think there are just a few certain functions/names that are "undocumentably" reserved.

ChristopheM
(Hey THIS is FUN)
2011-02-16 06:22 PM
Re: KixForms Show() and Hide()

sorry.

i have made a confusion between $SettingsButton and $SettingsForm !!!

but with a very simple change (add "dim $settingsform" in the function), now it is working as wanted. Without this line, i had an error :
ERROR : IDispatch pointers not allowed in expressions!
Script: D:\toto.kix
Line : 1


ShaneEP
(MM club member)
2011-02-16 07:32 PM
Re: KixForms Show() and Hide()

Yep that's the same error I was getting. I suppose DIMing is a good practice anyways, but it's still weird. Not sure why that name has to be dimmed, but a different one doesn't. Especially in that small sample form where I know that variable isn't being used anywhere else.