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

Remove from collection
Goto page 1, 2  Next
 
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion
View previous topic :: View next topic  
Author Message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Fri Dec 16, 2005 2:29 am    Post subject: Remove from collection Reply with quote

Ok I am using the command
$PanelA.Controls.Remove($PictureboxA)
First time I use the command it works just fine however the second time and everyt time thereafter, it does not work.

It is used in a loop to move the picturebox from one panel to another.
The picturebox does go to the new panel with no problem, it just does not remove it from the the specifed panel. I have run the debug and see that it is executing the command as expected.

Is it possible that I need to refresh the entire form everytime?

For those that want to see the code I have it available, but wish to warn you that it is adult in nature and will not be held responsible for any that request it.

Due to that fact I will also not post it on a public board, as I don't want to get the owners of this site in any kind of trouble.

Thanks

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Fri Dec 16, 2005 3:19 am    Post subject: Reply with quote

maybe not form.
do $panelA.update()

or is it $panelA.refresh()

I don't really get this invalidate business...
invalidate method sends a paint message and then there is update which does cause the invalidated sections to be repainted...
eh?
and then there is refresh which invalidates everything and thus making a paint message and updating whole control.

does that mean that paint message is just a message somewhere in the binary guts of the system and it does not really do anything?

so, I think safest is to use the good old reFresh() method.

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Fri Dec 16, 2005 3:35 am    Post subject: Reply with quote

Okay I did try .Refresh() and .Update(), and they had no effect. Do I need to supply parameters within ()?

Something like $system.controls?

Not really sure here.

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Fri Dec 16, 2005 3:42 am    Post subject: Reply with quote

Here is the function that I am using right now, hopefully I just have screwed up my syntax some more....

Trust me when I say that all the variables that are involved resolve correctly.

Code:

For $ = 1 to 100
   $d = Rnd(5)
   $d = $d + 1
   Execute("$PictureBox1.Image = $System.Bitmap('.\images\d"+$D+".bmp')")
Next
Execute("$Panel"+$Location[$PLayerUp]+".Controls.Remove($Player"+$PlayerUP+")");This is the problem line

Execute("$Panel"+$Location[$Playerup]+".Update()")
$Location[$PlayerUP] = $Location[$PlayerUp] + $d
Locate($PLayerUP)

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Fri Dec 16, 2005 3:53 am    Post subject: Reply with quote

k, translate that snippet to:
Code:
For $ = 1 to 100
   $d = Rnd(5)
   $d = $d + 1
   Execute("$PictureBox1.Image = $System.Bitmap('.\images\d"+$D+".bmp')")
Next
'executing --> "$Panel"+$Location[$PLayerUp]+".Controls.Remove($Player"+$PlayerUP+")")' ?
Execute("$Panel"+$Location[$PLayerUp]+".Controls.Remove($Player"+$PlayerUP+")");This is the problem line

'executing --> "$Panel"+$Location[$Playerup]+".Update()")' ?
Execute("$Panel"+$Location[$Playerup]+".Update()")
$Location[$PlayerUP] = $Location[$PlayerUp] + $d
Locate($PLayerUP)


I know, not that bursted with higher logic but this clears any doubts for good that there is a booboo in there.

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Fri Dec 16, 2005 4:05 am    Post subject: Reply with quote

Here is the output....
Code:

executing --> "$Panel"+$Location[$PLayerUp]+".Controls.Remove($Player"+$PlayerUP+")")
0executing --> "$Panel"+$Location[$Playerup]+".Update()")
0executing --> "$Panel"+$Location[$PLayerUp]+".Controls.Remove($Player"+$PlayerUP+")")
0executing --> "$Panel"+$Location[$Playerup]+".Update()")
0executing --> "$Panel"+$Location[$PLayerUp]+".Controls.Remove($Player"+$PlayerUP+")")
0executing --> "$Panel"+$Location[$Playerup]+".Update()")
0executing --> "$Panel"+$Location[$PLayerUp]+".Controls.Remove($Player"+$PlayerUP+")")
0executing --> "$Panel"+$Location[$Playerup]+".Update()")
0executing --> "$Panel"+$Location[$PLayerUp]+".Controls.Remove($Player"+$PlayerUP+")")
0executing --> "$Panel"+$Location[$Playerup]+".Update()")
0executing --> "$Panel"+$Location[$PLayerUp]+".Controls.Remove($Player"+$PlayerUP+")")
0executing --> "$Panel"+$Location[$Playerup]+".Update()")
0executing --> "$Panel"+$Location[$PLayerUp]+".Controls.Remove($Player"+$PlayerUP+")")
0executing --> "$Panel"+$Location[$Playerup]+".Update()")
0executing --> "$Panel"+$Location[$PLayerUp]+".Controls.Remove($Player"+$PlayerUP+")")
0executing --> "$Panel"+$Location[$Playerup]+".Update()")
0


And they are still not dissapearing.

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Fri Dec 16, 2005 4:35 am    Post subject: Reply with quote

lol.
sure, you have no vars in strings on Laughing

so my code should have been:
Code:

For $ = 1 to 100
   $d = Rnd(5)
   $d = $d + 1
   Execute("$PictureBox1.Image = $System.Bitmap('.\images\d"+$D+".bmp')")
Next
"executing --> $Panel"+$Location[$PLayerUp]+".Controls.Remove($Player"+$PlayerUP+")" ?
Execute("$Panel"+$Location[$PLayerUp]+".Controls.Remove($Player"+$PlayerUP+")");This is the problem line

"executing --> $Panel"+$Location[$Playerup]+".Update()" ?
Execute("$Panel"+$Location[$Playerup]+".ReFresh()")
$Location[$PlayerUP] = $Location[$PlayerUp] + $d
Locate($PLayerUP)


and, I also renamed the update to refresh in above. just in case

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Fri Dec 16, 2005 4:45 am    Post subject: Reply with quote

Okay I see what you were going for, and as you see below it is sending the correct command, but the remove / refresh / update is not doing the trick.

Code:

executing --> $Panel1.Controls.Remove($Player1) ;Works
0executing --> $Panel1.Update()
0executing --> $Panel1.Controls.Remove($Player2) ;Works
0executing --> $Panel1.Update()
0executing --> $Panel1.Controls.Remove($Player3) ;Works
0executing --> $Panel1.Update()
0executing --> $Panel1.Controls.Remove($Player4) ;Works
0executing --> $Panel1.Update()
0executing --> $Panel23.Controls.Remove($Player1) ; Not Working from here on
0executing --> $Panel23.Update()
0executing --> $Panel4.Controls.Remove($Player2)
0executing --> $Panel4.Update()
0executing --> $Panel3.Controls.Remove($Player3)
0executing --> $Panel3.Update()
0executing --> $Panel23.Controls.Remove($Player4)
0executing --> $Panel23.Update()
0executing --> $Panel28.Controls.Remove($Player1)
0executing --> $Panel28.Update()
0executing --> $Panel23.Controls.Remove($Player2)
0executing --> $Panel23.Update()
0executing --> $Panel8.Controls.Remove($Player3)
0executing --> $Panel8.Update()
0executing --> $Panel26.Controls.Remove($Player4)
0executing --> $Panel26.Update()
0


And I doublechecked, and NoVarsInStrings is set to ON

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Fri Dec 16, 2005 12:34 pm    Post subject: Reply with quote

Im going to test this Panel.Remove / Panel.Add stuff using a little mini-test-script ... will advise.
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Fri Dec 16, 2005 12:36 pm    Post subject: Reply with quote

Quote:
will advise

That is all one can ask...

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Fri Dec 16, 2005 2:04 pm    Post subject: Reply with quote

well, i used this script here (check-out the ButtonClick function) and cant seem to repo - of course, I am not doing the Remove then Add, and am simply adding from one container to another (which you can do) ... the control will automatically be removed from the old container by default.

what might be happening is that when you first remove a control, because you dont have a real or proper handle to it ($var assigned), the control is being "disposed of" or destroyed ... idk ... haven't looked too deeply at the code you posted (yet), here is the script - click the button on the bottom to swap the pix arouind ...

Code:

break on

$System = CreateObject("Kixforms.System")

$Form = $System.Form()

$Panel1 = $Form.Controls.Add($System.Panel())
$Panel1.Dock = $System.DockStyle_Fill
$Panel1.BackColor = $System.Color.PaleGreen

$Panel2 = $Form.Controls.Add($System.Panel())
$Panel2.Dock = $System.DockStyle_Left
$Panel2.Width = $Form.ClientWidth / 2
$Panel2.BackColor = $System.Color.Lightblue

$PictureBox1 = $Panel2.Controls.Add($System.PictureBox())
$PictureBox1.BorderStyle = $System.BorderStyle_FixedSingle
$PictureBox1.Image = $System.Bitmap.FromBase64String(BitmapString())
$PictureBox1.Size = $PictureBox1.Image.Size
$PictureBox1.Center

$Button1 = $Form.Controls.Add($System.Button())
$Button1.Dock = $System.DockStyle_Bottom
$Button1.Text = "Swap"
$Button1.Click = "ButtonClick()"

$Form.Center
$Form.Show
While $Form.Visible
 $= Execute($Form.DoEvents)
Loop

Exit 0

Function ButtonClick()

 If $Panel2.Controls.Count
  $= $Panel1.Controls.Add($PictureBox1)
 Else
  $= $Panel2.Controls.Add($PictureBox1)
 Endif 

EndFunction

Function BitmapString()
$BitmapString = "
R0lGODlhZAAZAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwMDcwKbK8EAgAGAgAIAgAKAg
AMAgAOAgAABAACBAAEBAAGBAAIBAAKBAAMBAAOBAAABgACBgAEBgAGBgAIBgAKBgAMBgAOBg
AACAACCAAECAAGCAAICAAKCAAMCAAOCAAACgACCgAECgAGCgAICgAKCgAMCgAOCgAADAACDA
AEDAAGDAAIDAAKDAAMDAAODAAADgACDgAEDgAGDgAIDgAKDgAMDgAODgAAAAQCAAQEAAQGAA
QIAAQKAAQMAAQOAAQAAgQCAgQEAgQGAgQIAgQKAgQMAgQOAgQABAQCBAQEBAQGBAQIBAQKBA
QMBAQOBAQABgQCBgQEBgQGBgQIBgQKBgQMBgQOBgQACAQCCAQECAQGCAQICAQKCAQMCAQOCA
QACgQCCgQECgQGCgQICgQKCgQMCgQOCgQADAQCDAQEDAQGDAQIDAQKDAQMDAQODAQADgQCDg
QEDgQGDgQIDgQKDgQMDgQODgQAAAgCAAgEAAgGAAgIAAgKAAgMAAgOAAgAAggCAggEAggGAg
gIAggKAggMAggOAggABAgCBAgEBAgGBAgIBAgKBAgMBAgOBAgABggCBggEBggGBggIBggKBg
gMBggOBggACAgCCAgECAgGCAgICAgKCAgMCAgOCAgACggCCggECggGCggICggKCggMCggOCg
gADAgCDAgEDAgGDAgIDAgKDAgMDAgODAgADggCDggEDggGDggIDggKDggMDggODggAAAwCAA
wEAAwGAAwIAAwKAAwMAAwOAAwAAgwCAgwEAgwGAgwIAgwKAgwMAgwOAgwABAwCBAwEBAwGBA
wIBAwKBAwMBAwOBAwABgwCBgwEBgwGBgwIBgwKBgwMBgwOBgwACAwCCAwECAwGCAwICAwKCA
wMCAwOCAwACgwCCgwECgwGCgwICgwKCgwMCgwOCgwADAwCDAwEDAwGDAwIDAwKDAwP/78KCg
pICAgP8AAAD/AP//AAAA//8A/wD//////yH5BAEAAP8ALAAAAABkABkAAAj/AP8JHEiwoMGD
CBMqXMiwocOHECNKnEixosWLGBEgqMeuo8ePIEOKHEmypMmTKD2OI1dPY7tRMGPKnEmzps2b
OHPq3BlTk6ZR9drVO0C0qNGjSJMqXcq0qdOnRdtpisQOaNJ6Q41iPbq1aFetWcFCHUtWq6Yo
VcNuZDeu7b2hHceJG3XvAMdxdDmyHceOKIK440gdSIAVa9W6ZRM3rXc2bdEE43z6jCtZUyag
kS1rYidO8ih29TL7HKfRqNRRilMrZYzWKlGplceJkhwpSRRSoS1HkbJptmS5kjNpaoeg6L1N
mzS9bce849sDxYM2Zye0XUfr1kEXZksXOmHm1vHW/2XtmKjoypaTJOFdb13nTEm0jEJfOUoU
1EfvKUdaDyZ0r0X1BeCARZGDWnFcabLJW425dgB9wa2HG2M+wbdgO+eltx5oRt1DSjvGIUYU
KQIaR8pnpoEYlYgvheVhPR6OogWDrWXFDnqZCOdTJFGwcsCNO9422Dro1SYFiSWSkoQmxkmx
mXHkGLWJhGGRokmUROmH3wHHlXgAc6RIkcQWNJZ3XhRJRFJZJIKJFsUWg2UYJIlhaZHElqNs
EhaXJd5jG25GaaFnUcipeAApkpDDznNG+VSmVZxJhqYUUujo02eVScHcmlFUJpyX6235ZYcO
Tkmmi0ISxRiWRG2i3UsoEv9F6aNDnYfEbVZCuKMmZ6qnZmWCjRjfT4YWZeUmRtn3oaGjSJKk
FKzec19Sx61H6wGjZMKjemRiGwmP9oWLZhTf2qcepeSCa5skkoiJqyaSKIicFOHGC++kb82n
ibuS8euTmOv5hFxyaEpoV4NDsbIvpQu+Nh+lEEOshRYRb0GKhwtTSjG63d7zcMSbnLjwbsge
mvEWyUGMcsYhpxwxbyIinCUpNIs4c80e4kxzzSbufE/OF3e488UqAv1zzxfD6LPSPDPts82b
RCFbsapVbfXVUkVBjq5cd+3112CHLbZkya3XH7jipq322my37fbbcMfNthT3YGT33Xjnrffe
fPcF7fdDAQEAOw==
"
EndFunction
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Fri Dec 16, 2005 3:34 pm    Post subject: Reply with quote

Will check it out tonight, I will also post some of the code that I am using to do this particular function.
_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Sat Dec 17, 2005 1:22 am    Post subject: Reply with quote

As promised here is most of the code that needs to be looked at....
This is the main form
Code:

Break On
$nul = Setoption("NoVarsInStrings", "ON")
$System = CreateObject("Kixforms.System")
If Not $System
   $nul= MessageBox("KiXforms.Net Not Initiated. This Script Will Now Close.","Error",16)
   Quit()
EndIf
$nul = $System.Application.EnableVisualStyles

$Form1 = $System.Form()
$Form1.Left = 0
$Form1.StartPosition = 0  ;FormStartPosition_Manual
$Form1.Size = $System.Size(1005,850) ;(Width,Height)
$Form1.Text = "Esexplorations Game Board"
$Form1.BackgroundImage = $System.Bitmap(".\images\board.bmp")
$Form1.Top = 0


$PanelB = $System.Panel()
$PanelB.BorderStyle = 1  ;FixedSingle
$PanelB.Top = 750
$PanelB.Width = 1000
$PanelB.BackColor = $System.Color.gray
$nul = $Form1.Controls.Add($PanelB)

$t = 750
$l = 0

for $a=1 to 100 step 20
$t = $t -75
$l = 0
   for $forward = $a to $a+10 step 1    
      Execute("$Panel"+$forward+" = $System.Panel()")
      Execute("$Panel"+$forward+".BorderStyle = 1")
      Execute("$Panel"+$forward+".Left = "+$l)
      Execute("$Panel"+$forward+".Top = "+$t)
      Execute("$Panel"+$forward+".Width = 100")
      Execute("$Panel"+$forward+".Height = 75")
      Execute("$Panel"+$forward+".BackColor = $System.Color.Transparent")
      $nul = Execute("$nul = $Form1.Controls.Add($Panel"+$forward+")")
      $l = $l + 100
   next
$t = $t -75
$l = 0
   for $backward= $a+19 to $a+10 step -1
      Execute("$Panel"+$backward+" = $System.Panel()")
      Execute("$Panel"+$backward+".BorderStyle = 1")
      Execute("$Panel"+$backward+".Left = "+$l)
      Execute("$Panel"+$backward+".Top = "+$t)
      Execute("$Panel"+$backward+".Width = 100")
      Execute("$Panel"+$backward+".Height = 75")
      Execute("$Panel"+$backward+".BackColor = $System.Color.Transparent")
      $nul = Execute("$nul = $Form1.Controls.Add($Panel"+$backward+")")
      $l = $l + 100
   next
next


$PictureBox1 = $System.PictureBox()
$PictureBox1.BorderStyle = 1  ;FixedSingle
$PictureBox1.Left = 3
$PictureBox1.Top = 9
$PictureBox1.Width = 50
$PictureBox1.Height = 50
$nul = $PanelB.Controls.Add($PictureBox1)

$Label1 = $System.Label()
$Label1.BorderStyle = 1  ;FixedSingle
$Label1.Left = 56
$Label1.Text = "Label1"
$Label1.TextAlign = 16  ;MiddleLeft
$Label1.Top = 2
$Label1.Visible = "False"
$nul = $PanelB.Controls.Add($Label1)

$Label2 = $System.Label()
$Label2.BorderStyle = 1  ;FixedSingle
$Label2.Left = 172
$Label2.Text = "Label2"
$Label2.TextAlign = 16  ;MiddleLeft
$Label2.Top = 2
$Label2.Visible = "False"
$nul = $PanelB.Controls.Add($Label2)

$Label3 = $System.Label()
$Label3.BorderStyle = 1  ;FixedSingle
$Label3.Left = 289
$Label3.Text = "Label3"
$Label3.TextAlign = 16  ;MiddleLeft
$Label3.Top = 2
$Label3.Visible = "False"
$nul = $PanelB.Controls.Add($Label3)

$Label4 = $System.Label()
$Label4.BorderStyle = 1  ;FixedSingle
$Label4.Left = 56
$Label4.Text = "Label4"
$Label4.TextAlign = 16  ;MiddleLeft
$Label4.Top = 35
$Label4.Visible = "False"
$nul = $PanelB.Controls.Add($Label4)

$Label5 = $System.Label()
$Label5.BorderStyle = 1  ;FixedSingle
$Label5.Left = 174
$Label5.Text = "Label5"
$Label5.TextAlign = 16  ;MiddleLeft
$Label5.Top = 35
$Label5.Visible = "False"
$nul = $PanelB.Controls.Add($Label5)

$Label6 = $System.Label()
$Label6.BorderStyle = 1  ;FixedSingle
$Label6.Left = 288
$Label6.Text = "Label6"
$Label6.TextAlign = 16  ;MiddleLeft
$Label6.Top = 35
$Label6.Visible = "False"
$nul = $PanelB.Controls.Add($Label6)

$BTN_Roll = $System.Button()
$BTN_Roll.Left = 400
$BTN_Roll.Text = "Roll Die"
$BTN_Roll.Top = 2
$BTN_Roll.Forecolor = $System.Color.Black
$BTN_Roll.Font = $System.Font ("Times New Roman",10,$System.FontStyle_Bold)
$BTN_Roll.Click = "Roll()"
$nul = $PanelB.Controls.Add($BTN_Roll)

$LabelG = $System.Label()
$LabelG.BorderStyle = 1  ;FixedSingle
$LabelG.Left = 490
$LabelG.TextAlign = 16  ;MiddleLeft
$LabelG.Top = 2
$LabelG.Height = 65
$LabelG.Width = 500
$LabelG.BackColor = $system.Color.Black
$LabelG.ForeColor = $system.Color.White
$nul = $PanelB.Controls.Add($LabelG)


$BTN_Exit = $System.Button()
$BTN_Exit.Left = 400
$BTN_Exit.Text = "Exit"
$BTN_Exit.Top = 32
$BTN_Exit.Forecolor = $System.Color.Black
$BTN_Exit.Font = $System.Font ("Times New Roman",10,$System.FontStyle_Bold)
$BTN_Exit.Click = "Gover()"
$nul = $PanelB.Controls.Add($BTN_Exit)




In another script I call that script, and then run these functions....

Code:


Call "Board.kix"
   Obstacles()
   InitialStart()



;Time to actually play the game....
InfoPanel($PlayerUp,$Escape[$Playerup])
Locate($Playerup)

$Form1.Show  ;Displays the Form

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


;Fill out the stuff on the game board
Function Obstacles()
;Define array of where the Ups and Downs are
Global $UD[100]
;How many are we going to create?
$ = RND(25)

If $ < 10 $ = $ * 2 EndIf
;Lets populate the form
For $C = 1 to $
   $B = RND(95) + 2 ;Where on the form will it be
   If $UD[$B] <> " "
      If Rnd(1) = 1 and $B < 90 ;Is it an up
         Execute("$PictureBox"+$C+"U = $System.PictureBox()")
         Execute("$PictureBox"+$C+"U.BorderStyle = 1  ;FixedSingle")
         Execute("$PictureBox"+$C+"U.Left = 80")
         Execute("$PictureBox"+$C+"U.Top = 0")
         Execute("$PictureBox"+$C+"U.Width = 20")
         Execute("$PictureBox"+$C+"U.Height = 20")
         Execute("$PictureBox"+$C+"U.Image = $System.Bitmap('.\images\Up.bmp')")
         $nul = Execute("$nul = $Panel"+$B+" .Controls.Add($PictureBox"+$C+"U)")
         $UD[$B] = "U"
      Else ; Or down
         Execute("$PictureBox"+$C+"D= $System.PictureBox()")
         Execute("$PictureBox"+$C+"D.BorderStyle = 1  ;FixedSingle")
         Execute("$PictureBox"+$C+"D.Left = 80")
         Execute("$PictureBox"+$C+"D.Top = 0")
         Execute("$PictureBox"+$C+"D.Width = 20")
         Execute("$PictureBox"+$C+"D.Height = 20")
         Execute("$PictureBox"+$C+"D.Image = $System.Bitmap('.\images\Down.bmp')")
         $nul = Execute("$nul = $Panel"+$B+" .Controls.Add($PictureBox"+$C+"D)")
         $UD[$B] = "D"

      EndIf
   EndIf
Next
;Define the array of where the transport points are
Global $Trans[100]
;How many are there going to be
$= Rnd(25)
If $ < 10 $ = $ * 2 EndIf
For $C = 1 to $
   $B = RND(95)   
   If $Trans[$b] <> " "
      Execute("$PictureBox"+$C+"T = $System.PictureBox()")
      Execute("$PictureBox"+$C+"T.BorderStyle = 1  ;FixedSingle")
      Execute("$PictureBox"+$C+"T.Left = 60")
      Execute("$PictureBox"+$C+"T.Top = 0")
      Execute("$PictureBox"+$C+"T.Width = 20")
      Execute("$PictureBox"+$C+"T.Height = 20")
      Execute("$PictureBox"+$C+"T.Image = $System.Bitmap('.\images\Trans.bmp')")
      $nul = Execute("$nul = $Panel"+$B+" .Controls.Add($PictureBox"+$C+"T)")
      $Trans[$B] = "T"
   EndIf
Next
;Ensure that there is a transport point at Panel 1

$PictureBoxT = $System.PictureBox()
$PictureBoxT.BorderStyle = 1  ;FixedSingle
$PictureBoxT.Left = 60
$PictureBoxT.Top = 0
$PictureBoxT.Width = 20
$PictureBoxT.Height = 20
$PictureBoxT.Image = $System.Bitmap('.\images\Trans.bmp')
$nul = $Panel1.Controls.Add($PictureBoxT)
$Trans[1] = "T"

;Define the array of Interactions
Global $Inter[100]
;How many are there going to be
$= Rnd(50)
If $ < 25 $ = $ * 2 EndIf
For $C = 1 to $
   $B = RND(100)   
   If $Inter[$b] <> " "
      Execute("$PictureBox"+$C+"I = $System.PictureBox()")
      Execute("$PictureBox"+$C+"I.BorderStyle = 1  ;FixedSingle")
      Execute("$PictureBox"+$C+"I.Left = 40")
      Execute("$PictureBox"+$C+"I.Top = 0")
      Execute("$PictureBox"+$C+"I.Width = 20")
      Execute("$PictureBox"+$C+"I.Height = 20")
      Execute("$PictureBox"+$C+"I.Image = $System.Bitmap('.\images\Inter.bmp')")
      $nul = Execute("$nul = $Panel"+$B+" .Controls.Add($PictureBox"+$C+"I)")
      $Inter[$B] = "I"
   EndIf
Next
;Number the boxes
For $ = 1 to 100
   Execute("$LBL_N"+$+" = $System.Label()")
   Execute("$LBL_N"+$+".Left = 0")
   Execute("$LBL_N"+$+".Top = 0")
   Execute("$LBL_N"+$+".Text = "+$)
   Execute("$LBL_N"+$+".Height = 22")
   Execute("$LBL_N"+$+".Borderstyle = 0")
   Execute("$LBL_N"+$+".Forecolor = $System.Color.White")
   $nul = Execute("$nul = $Panel"+$+".Controls.Add($LBL_N"+$+")")
Next

;Input the players names onto the screen.
;Add their icon next to their name.
For $ = 1 to $Count
   Execute("$Label"+$+".Text = $Name[$,0]")
   Execute("$Label"+$+".Forecolor = $System.Color.Black")
   Execute("$Label"+$+".Visible = 'True'")
   $icon = $Name[$,6]
   Execute("$Picturebox_IC"+$+"=$System.PictureBox()")
   Execute("$Picturebox_IC"+$+".Left = 80")
   Execute("$Picturebox_IC"+$+".Top = 0")
   Execute("$Picturebox_IC"+$+".Image = $System.Bitmap('.\images\'+$icon+'.bmp')")
   Execute("$nul = $Label"+$+".Controls.Add($Picturebox_IC"+$+")")
   
Next
;Load the image of the die
$PictureBox1.Image = $System.Bitmap('.\images\d3.bmp')

EndFunction
;=========================================================================
Function Roll()
For $ = 1 to 100
   $d = Rnd(5)
   $d = $d + 1
   Execute("$PictureBox1.Image = $System.Bitmap('.\images\d"+$D+".bmp')")
Next
"executing --> $Panel"+$Location[$PLayerUp]+".Controls.Remove($Player"+$PlayerUP+")" ?
Execute("$Panel"+$Location[$PLayerUp]+".Controls.Remove($Player"+$PlayerUP+")");This is the problem line

"executing --> $Panel"+$Location[$Playerup]+".Update()" ?
Execute("$Panel"+$Location[$Playerup]+".ReFresh()")
$Location[$PlayerUP] = $Location[$PlayerUp] + $d
 
;For $ = 1 to 100
;   $d = Rnd(5)
;   $d = $d + 1
;   Execute("$PictureBox1.Image = $System.Bitmap('.\images\d"+$D+".bmp')")
;Next
;Execute("$Panel"+$Location[$PLayerUp]+".Controls.Remove($Player"+$PlayerUP+")")
;Execute("$Panel"+$Location[$Playerup]+".Update()")
;$Location[$PlayerUP] = $Location[$PlayerUp] + $d
Locate($PLayerUP)


ChangePlayer()
EndFunction
;=========================================================================
;Fill out the information panel
Function InfoPanel($PU,$Ch)
$LabelG.Text = ""
$LabelG.Text = $Name[$PU,0] + " It is your turn.  You have " + $CH + " escapes left." + @CRLF + "Click on 'RollDie' to continue"

EndFunction
;=========================================================================
Function Locate($Pu)
;Place Icons into box according to what was rolled

Execute("$Player"+$PU+"=$System.PictureBox()")
Execute("$Player"+$PU+".Left = ("+$PU+" * 20)-20")
Execute("$Player"+$PU+".Top = 53")
Execute("$Player"+$PU+".Image = $System.Bitmap('.\images\'+$Name[$PU,6]+'.bmp')")
Execute("$nul = $Panel"+$Location[$PU]+".Controls.Add($Player"+$PU+")")
Actions($PU)
EndFunction
;=========================================================================

Function Actions($PU)

;Look to see if there are any action icons in this panel
;Check for Interactions first
If $Inter[$Location[$pu]] = "I"
   $LabelG.Text = $LabelG.Text + @CRLF +"Lucky you, you have landed on an Action Space"
   ;Go find out what kind of action is to be perfomed
   Interaction()
EndIf
;Check to see if it a chance square

;Check if there is a transport
$ = 0
If $UD[$Location[$pu]] = "U"
   ;Select at random one of the transport points
   While $ = 0
   $1 = Rnd(20)
   If $1 > $Location[$pu]
      Execute("$nul = $Panel"+$Location[$PLayerUp]+".Controls.Remove($Player"+$PU+")")
      $2 = Ascan($Trans,"T",$1)
      $Location[$pu] = $2
      $LabelG.Text = $LabelG.Text + @CRLF +"You have been transported to " +$2
      Locate($PU)
      $ = 1
   EndIF
   Loop
EndIf   
$ = 0
If $UD[$Location[$pu]] = "D"
   ;Select at random one of the transport points
   While $ = 0
   $1 = Rnd(100)
   If $1 < $Location[$pu]
      Execute("$nul = $Panel"+$Location[$PLayerUp]+".Controls.Remove($Player"+$PU+")")
      $2 = Ascan($Trans,"T",$1)
      $Location[$pu] = $2
      $LabelG.Text = $LabelG.Text + @CRLF +"You have been transported to " +$2
      Locate($PU)
      $ = 1
   EndIF
   Loop
EndIf   

EndFunction
;=========================================================================
Function ChangePlayer()
$PlayerUp = $PlayerUp + 1
If $PlayerUp > $Count
   $PlayerUP = 1
EndIf
InfoPanel($PlayerUp,$Escape[$Playerup])
Locate($Playerup)
EndFunction
;=========================================================================
Function InitialStart()
;Define who turn it is
GLobal $PlayerUP
$PlayerUP = 1
;Build Array to track location of users
Global $Location[$count]
$Location[0] = "Location of players"
For $ = 1 to $Count
   $Location[$] = 1
Next
;Build Array to track the number of escapes, initial value will be 5

Global $Escape[$Count]
$Escape[0] = "Escape Array"
For $ = 1 to $Count
   $Escape[$] = 5
Next   
EndFunction

The Array $Name[x,x] Is used to hold some preferences and the players name. Names are at x,0

Hope this helps figure out what the heck I am doing wrong. And any suggestions on making my script better are acceptable as well.

Thanks

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Sat Dec 17, 2005 8:02 pm    Post subject: Reply with quote

Well through a change of the functions, it is now working.... I don't undestand why, but it is...

In the function Roll() there was a call to the function Locate(), well this seemed stupid to me, so I moved all of the stuff in Locate() to Roll() and it began working.

So here is what the Roll() function looks like now..
Code:
Function Roll()
   $d = Rnd(5) + 1
 
   Execute("$PictureBox1.Image = $System.Bitmap('.\images\d"+$D+".bmp')")
 
 
Execute("$Panel"+$Location[$PLayerUp]+".Controls.Remove($Player"+$PlayerUP+")")
$Location[$PlayerUP] = $Location[$PlayerUp] + $d

Execute("$Player"+$PlayerUp+"=$System.PictureBox()")
Execute("$Player"+$PlayerUp+".Left = ("+$PlayerUp+" * 20)-20")
Execute("$Player"+$PlayerUp+".Top = 53")
Execute("$Player"+$PlayerUp+".Image = $System.Bitmap('.\images\'+$Name[$PlayerUp,6]+'.bmp')")
Execute("$nul = $Panel"+$Location[$PLayerUp]+".Controls.Add($Player"+$PLayerUp+")")
$LabelG.text = "You have landed at " + $Location[$PlayerUp]

Actions($PLayerUp)

ChangePlayer()
EndFunction

_________________
Parents were invented to make children happy by giving them something to ignore.
Back to top
View user's profile Send private message
Gargoyle
KiXforms Aficionado
KiXforms Aficionado


Joined: 30 Dec 2003
Posts: 366
Location: Arizona

PostPosted: Mon Dec 19, 2005 2:31 pm    Post subject: Reply with quote

Well it looks like I spoke to soon. It is still doing the same thing, and I have also noticed that sometimes when I add a picturebox to a panel it does not display.

I will be cleaning up my script and will put all of it into a zip file for those that want it.

_________________
Parents were invented to make children happy by giving them something to ignore.
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
Goto page 1, 2  Next
Page 1 of 2

 
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