cyclonebri
08-18-2001, 06:45 PM
Is it possible to unload a picturebox at runtime? I have a gameboard with pictures on it of cards, that are preloaded, and when a player selects their card (from their hand), I want to highlight the matching picture boxes (I have pictures of the cards highlighted that I want to replace the old picture with) and then when they select it I want to put a token on top of the picture (yet another pre-made picture to replace) Is this possible? If not, what would be a good way to go about doing this?
Thinker
08-18-2001, 06:58 PM
Do they really need to be unloaded or could you just set the visible
property to false. Will you be using the boxes again as the game goes
on? Even with a control array, you can't unload controls placed at
design-time (at least by the Unload method.)
I think therefore I am... sometimes right. images/icons/wink.gif
cyclonebri
08-18-2001, 07:07 PM
Yeah, It is an array, and the pictures need to be visible throughout the game, but I need to be able to change them. I made a game one time and I thought I just reloaded a new picture over the old one, but that doesn't seem to be working this time. Basically, it is a board with pictures of cards on them, and when the player selects one from his hand he has 2 options where he can put his token, and I want to highlight those (by loading the highlighted picture) then I want to load in a new picture with the token on it after he selects one of the two that are available. btw...its the game sequence in case you are wondering
Thinker
08-18-2001, 07:13 PM
What method have you tried to change the picture. I was under the
impression this could be done dynamically. Something like
Set Picture1.Picture = LoadPicture("fullpathgraphic.bmp")
I think therefore I am... sometimes right. images/icons/wink.gif
cyclonebri
08-18-2001, 07:22 PM
Ok, here is what happens. When the person clicks a card in their hand, it finds the matching two cards on the board, like say the k of spades...both have a datafield value of 0 then it calls the function to highlight the cards based on the datafield and then it has lines similar to this:
Case 0:
Set GameBoard.Picture1(6).Picture = LoadPicture(App.path & "HighlightedCards\KSpades.bmp")
Set GameBoard.Picture1(86).Picture = LoadPicture(App.path & "HighlightedCards\KSpades.bmp")
etc...
but it doesn't seem to overload the picture over the original K of Spades...any thoughts?
Thinker
08-18-2001, 07:29 PM
The only thing I can see in this code which wouldn't work is not having
an extra \ between App.Path and "HighlightedCards\KSpades.bmp"
I tried a very quick test with just a single picturebox on a form. I set
a picture at design-time and when I clicked a button, I changed the
picture. Worked great.
I think therefore I am... sometimes right. images/icons/wink.gif
cyclonebri
08-18-2001, 07:39 PM
Thank you very much. I added in the "\" and it works like it should. Thank you for your help!
Brian