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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#using <System.Windows.Forms.dll>
using namespace System;
using namespace System::Windows::Forms;
//
// Class BUTTON 1
//
public ref class Button1 : public System::Windows::Forms::Button
{
public:
Button1();
private:
void Button1_MouseDown(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e);
};
// Implementation
Button1::Button1() {
this->MouseDown+= gcnew System::Windows::Forms::MouseEventHandler(this, &Button1::Button1_MouseDown);
}
void Button1::Button1_MouseDown(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e) {
cout << "Ici je voudrais renvoyer la valeur time de l'objet form1." << endl;
//cout << "time = " << form1->getTime << endl;
}
//
// Class Form 1
//
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1();
int getTime();
private:
int time;
Button1^ button1;
};
// Implementation
Form1::Form1() {
button1 = gcnew Button1();
this->Controls->Add (button1);
time = 10;
}
int Form1::getTime() {
return time;
}
//
// Main
//
int main()
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Form1^ form1 ;
form1 = gcnew Form1();
// Create the main window and run it
Application::Run(form1);
return 0;
} |
Partager