hi, I'm writing a simple bridge(cards) application using Windows Forms C++ (VS2008)
Dealing hands, sorting within hands work fine. To display the images i'm using a dynamic array of PictureBox'es, but when im trying to display it it displays only ONCE (like the second, third display would have been "shadowed" by the first display...
Here are the main parts of my code...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
//function to display the shuffled deck
array<String^>^ cards = gcnew array<String^> {"2","3","4","5","6","7","8","9","D","J","Q","Y","Z",
//4x 2,3,4,...Y,Z to represent 2 of clubs, 3 of clubs....king of spade, ace of //spade
Random^ random = gcnew Random();
for(int i=0;i<player->Length;i++)
{
number = random->Next(0,52);
if(valid[number]==false) //bool'ean array to check if number was already picked
{
player[i]=cards[number];
gracz[i]=number; //this will help me later, to display images
valid[number]=true;
if(number<13)
tempClub[i]=player[i]; //temp arrays to display cards as strings
else if(number>=13 && number<26)
tempDiamond[i]=player[i];
else if(number>=26 && number<39)
tempHeart[i]=player[i];
else
tempSpade[i]=player[i];
}
else
{
do{
number = random->Next(0,52);
}while(valid[number]==true);
player[i]=cards[number];
gracz[i]=number;
valid[number]=true;
if(number<13)
tempClub[i]=player[i];
else if(number>=13 && number<26)
tempDiamond[i]=player[i];
else if(number>=26 && number<39)
tempHeart[i]=player[i];
else
tempSpade[i]=player[i];
}
}
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
//function:displaying cards(as strings) in labels
Array::Sort(temp);
Array::Reverse(temp);
for(int i=0;i<temp->Length;i++)
{
if(temp[i]=="Z")
temp[i]="A";
if(temp[i]=="Y")
temp[i]="K";
if(temp[i]=="D")
temp[i]="10";
label->Text = label->Text + temp[i] + " ";
}
//everything works fine till now...
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
//and now the problem with displaying the cards as images
//notice in the 1st code part -> gracz[i]=number (look above)
Array::Sort(gracz);
for(int i=0;i<gracz->Length;i++)
{
//im creating a dynamic array of PictureBox'es
//like array<PictureBox^>^ PB = gcnew etc
PB[i] = gcnew System::Windows::Forms::PictureBox();
PB[i]->Location = System::Drawing::Point(400-(i*15), 250)
PB[i]->Size = System::Drawing::Size(71, 96);
PB[i]->Tag = Convert::ToString(gracz[i]);
PB[i]->Image = (cli::safe_cast<System::Drawing::Image^ >(this->imageList->Images[gracz[i]] ));
this->Controls->Add(PB[i]);
}
|
So everything works fine except that 3rd part, hands are being generated
after button click, on first click cards (as strings in labels) are being
displayed + one hand is being displayed as images...
Then after next(and next) click only the strings are changing(new deal) but
the image representation doesnt change...
Note: the image representation is the same as string representation (so it seems to be working), only doesnt change during button click
I hope my msg wasnt really confusing,
thx for any remarks,
John Kravetzki
P.S.
if some1 felt confused with that what i wrote here i post a link with
exe file of my app:
http://www.dajeciala.strefa.pl/i/bridgeGenerator.exe
I hope posting links with exe's isnt bannable here? (i need to read the forum regulations:()