Panel użytkownika
Nazwa użytkownika:
Hasło:
Nie masz jeszcze konta?

[Visual C++] Problem z wywoływaniem kontrolek

Ostatnio zmodyfikowano 2012-05-29 18:07
Autor Wiadomość
pawajoro
Temat założony przez niniejszego użytkownika
[Visual C++] Problem z wywoływaniem kontrolek
» 2012-05-29 18:03:24
Kod:
C/C++
// SPWN.cpp : main project file.

#include "stdafx.h"
#include "Form1.h"

using namespace SPWN;
using namespace std;


void setquestions( string * questions, string * answers )
{
    answers[ 0 ] = "Odpowiedz 0";
    answers[ 1 ] = "Odpowiedz 1";
    answers[ 2 ] = "Odpowiedz 2";
    ...
}

bool czyBylaWylosowana( int iLiczba, int tab[], int ile )
{
    if( ile <= 0 )
         return false;
   
    int i = 0;
    do
    {
        if( tab[ i ] == iLiczba )
             return true;
       
        i++;
    } while( i < ile );
   
    return false;
}

int wylosuj( int ile )
{
    srand( time( 0 ) );
    return( rand() % ile );
}

int losuj( int ile, int wylosowane[], int & wylosowanych )
{
    srand( time( 0 ) );
    do
    {
        int liczba = wylosuj( ile );
        if( czyBylaWylosowana( liczba, wylosowane, wylosowanych ) == false )
        {
            wylosowanych++;
            return liczba;
        } //if
    } while( true );
   
    /*
        wylosowanych = 0;
        do
        {
            std::cout << wylosowane[ wylosowanych ] << std::endl;
            wylosowanych++;
        } while( wylosowanych < 5 );
        */
}

void ask( string * questions, string * answers )
{
    int waa[ 253 ];
    int nonac;
    int goods = 0;
    float PB = 0;
    int c = 0;
    do
    {
        int index = losuj( 252, waa, nonac );
        textBox5->Text = questions[ index ];
        int good = wylosuj( 3 );
        switch( good )
        {
        case 0:
            {
                textBox2->Text = answers[ index ];
                textBox3->Text = answers[ wylosuj( 3 ) ];
                textBox1->Text = answers[ wylosuj( 3 ) ];
                textBox4->Text = answers[ wylosuj( 3 ) ];
                break;
            }
        case 1:
            {
                textBox2->Text = answers[ wylosuj( 3 ) ];
                textBox3->Text = answers[ index ];
                textBox1->Text = answers[ wylosuj( 3 ) ];
                textBox4->Text = answers[ wylosuj( 3 ) ];
                break;
            }
        case 2:
            {
                textBox2->Text = answers[ wylosuj( 3 ) ];
                textBox3->Text = answers[ wylosuj( 3 ) ];
                textBox1->Text = answers[ index ];
                textBox4->Text = answers[ wylosuj( 3 ) ];
                break;
            }
        case 3:
            {
                textBox2->Text = answers[ wylosuj( 3 ) ];
                textBox3->Text = answers[ wylosuj( 3 ) ];
                textBox1->Text = answers[ wylosuj( 3 ) ];
                textBox4->Text = answers[ index ];
                break;
            }
        }
        int choise;
        while( true )
        {
            if( button1_Click() )
                 choise = 0;
           
            break;
            if( button3_Click() )
                 choise = 1;
           
            break;
            if( button4_Click() )
                 choise = 2;
           
            break;
            if( button2_Click() )
                 choise = 3;
           
            break;
        }
        if( choise = good )
             goods++;
       
        PB +=( 253 / 100 );
        progressBar1->Value = PB;
        c++;
    } while( c < 253 );
   
    string et;
    et = "Zdobyłeś ";
    ostringstream ss;
    ss << goods;
    et.append( ss.str() );
    et.append( " punktów na 253 możliwych" );
}

[ STAThreadAttribute ]
int main( array < System::String ^> ^ args )
{
    // Enabling Windows XP visual effects before any controls are created
    Application::EnableVisualStyles();
    Application::SetCompatibleTextRenderingDefault( false );
    string * questions;
    string * answers;
    setquestions( questions, answers );
    // Create the main window and run it
    Application::Run( gcnew Form1() );
    return 0;
}
A kompilator:
1>------ Build started: Project: SPWN, Configuration: Debug Win32 ------
1>  SPWN.cpp
1>SPWN.cpp(541): warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data
1>SPWN.cpp(547): warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data
1>SPWN.cpp(578): error C2065: 'textBox5' : undeclared identifier
1>SPWN.cpp(578): error C2227: left of '->Text' must point to class/struct/union/generic type
1>          type is ''unknown-type''
1>SPWN.cpp(584): error C2065: 'textBox2' : undeclared identifier
1>SPWN.cpp(584): error C2227: left of '->Text' must point to class/struct/union/generic type
1>          type is ''unknown-type''
1>SPWN.cpp(585): error C2065: 'textBox3' : undeclared identifier
1>SPWN.cpp(585): error C2227: left of '->Text' must point to class/struct/union/generic type
1>          type is ''unknown-type''
1>SPWN.cpp(586): error C2065: 'textBox1' : undeclared identifier
1>SPWN.cpp(586): error C2227: left of '->Text' must point to class/struct/union/generic type
1>          type is ''unknown-type''
1>SPWN.cpp(587): error C2065: 'textBox4' : undeclared identifier
1>SPWN.cpp(587): error C2227: left of '->Text' must point to class/struct/union/generic type
1>          type is ''unknown-type''
1>SPWN.cpp(592): error C2065: 'textBox2' : undeclared identifier
1>SPWN.cpp(592): error C2227: left of '->Text' must point to class/struct/union/generic type
1>          type is ''unknown-type''
1>SPWN.cpp(593): error C2065: 'textBox3' : undeclared identifier
1>SPWN.cpp(593): error C2227: left of '->Text' must point to class/struct/union/generic type
1>          type is ''unknown-type''
1>SPWN.cpp(594): error C2065: 'textBox1' : undeclared identifier
1>SPWN.cpp(594): error C2227: left of '->Text' must point to class/struct/union/generic type
1>          type is ''unknown-type''
1>SPWN.cpp(595): error C2065: 'textBox4' : undeclared identifier
1>SPWN.cpp(595): error C2227: left of '->Text' must point to class/struct/union/generic type
1>          type is ''unknown-type''
1>SPWN.cpp(600): error C2065: 'textBox2' : undeclared identifier
1>SPWN.cpp(600): error C2227: left of '->Text' must point to class/struct/union/generic type
1>          type is ''unknown-type''
1>SPWN.cpp(601): error C2065: 'textBox3' : undeclared identifier
1>SPWN.cpp(601): error C2227: left of '->Text' must point to class/struct/union/generic type
1>          type is ''unknown-type''
1>SPWN.cpp(602): error C2065: 'textBox1' : undeclared identifier
1>SPWN.cpp(602): error C2227: left of '->Text' must point to class/struct/union/generic type
1>          type is ''unknown-type''
1>SPWN.cpp(603): error C2065: 'textBox4' : undeclared identifier
1>SPWN.cpp(603): error C2227: left of '->Text' must point to class/struct/union/generic type
1>          type is ''unknown-type''
1>SPWN.cpp(608): error C2065: 'textBox2' : undeclared identifier
1>SPWN.cpp(608): error C2227: left of '->Text' must point to class/struct/union/generic type
1>          type is ''unknown-type''
1>SPWN.cpp(609): error C2065: 'textBox3' : undeclared identifier
1>SPWN.cpp(609): error C2227: left of '->Text' must point to class/struct/union/generic type
1>          type is ''unknown-type''
1>SPWN.cpp(610): error C2065: 'textBox1' : undeclared identifier
1>SPWN.cpp(610): error C2227: left of '->Text' must point to class/struct/union/generic type
1>          type is ''unknown-type''
1>SPWN.cpp(611): error C2065: 'textBox4' : undeclared identifier
1>SPWN.cpp(611): error C2227: left of '->Text' must point to class/struct/union/generic type
1>          type is ''unknown-type''
1>SPWN.cpp(618): error C3861: 'button1_Click': identifier not found
1>SPWN.cpp(621): error C3861: 'button3_Click': identifier not found
1>SPWN.cpp(624): error C3861: 'button4_Click': identifier not found
1>SPWN.cpp(627): error C3861: 'button2_Click': identifier not found
1>SPWN.cpp(634): error C2065: 'progressBar1' : undeclared identifier
1>SPWN.cpp(634): error C2227: left of '->Value' must point to class/struct/union/generic type
1>          type is ''unknown-type''
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Co robić? "Form1", gdzie znajdują się deklaracje kontrolek, jest załączony...
P-57455
DejaVu
» 2012-05-29 18:05:58
SPWN.cpp(578): error C2065: 'textBox5' : undeclared identifier

/edit:
C/C++
[ STAThreadAttribute ]
int main( array < System::String ^> ^ args )
To ponoć wygląda na C++ CLI więc myślę, że niekoniecznie wiesz co czynisz skoro nie wiesz jak rozwiązywać tak proste problemy, pchając się jednocześnie w CLI.
P-57456
akwes
» 2012-05-29 18:07:46
Początki z RAD?

Dobra, ale skąd funkcja ma wiedzieć o ich istnieniu? Albo dodaj funkcję do deklaracji klasy Form1, albo przesyłaj ich wskaźniki, wskaźnik na Forme... Cokolwiek :P Ale póki co to są to nazwy z kosmosu.

C/C++
class A
{
    int ZMIENNA;
};


void lol()
{
    ZMIENNA = 1;
}

Myślisz że taki program ma sens?
P-57457
« 1 »
  Strona 1 z 1