Page 1 of 1 1
Topic Options
#201575 - 2011-02-12 05:47 PM KixForms Show() and Hide()
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
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

Top
#201576 - 2011-02-12 06:11 PM Re: KixForms Show() and Hide() [Re: ShaneEP]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
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.
Top
#201596 - 2011-02-15 05:01 PM Re: KixForms Show() and Hide() [Re: ShaneEP]
ChristopheM Offline
Hey THIS is FUN
*****

Registered: 2002-05-13
Posts: 309
Loc: STRASBOURG, France
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
_________________________
Christophe

Top
#201600 - 2011-02-15 09:38 PM Re: KixForms Show() and Hide() [Re: ChristopheM]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
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.
Top
#201612 - 2011-02-16 06:22 PM Re: KixForms Show() and Hide() [Re: ShaneEP]
ChristopheM Offline
Hey THIS is FUN
*****

Registered: 2002-05-13
Posts: 309
Loc: STRASBOURG, France
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
_________________________
Christophe

Top
#201613 - 2011-02-16 07:32 PM Re: KixForms Show() and Hide() [Re: ChristopheM]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
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.
Top
Page 1 of 1 1


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

Who's Online
0 registered and 259 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.055 seconds in which 0.024 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