Salut à tous,
Je développe un mini projet en C++/CLI et j'aimerai récupérer la date sélectionner par l'utilisateur dans une variable.
J'ai une fenêtre qui contient un calendrier et un bouton OK. Lorsque l'utilisateur choisit sa date il clique ensuite sur OK et la variable est utilisée par une nouvelle fenêtre qui s'ouvre.
J'ai tenter d'utilisermais sans succès.
Code : Sélectionner tout - Visualiser dans une fenêtre à part SelectedDate
Voici le code complet :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88 #include <windows.h> #include <string> #using <System.dll> #using <System.Drawing.dll> #using <System.Windows.Forms.dll> using namespace System; using namespace System::Windows; using namespace System::Windows::Controls; ref class Fenetre2: Window { ... //accès à la date choisit (pas encore codé) ... }; ref class CalendarDlg : Window { protected: int i_Date; Canvas^ can_Canvas; Label^ l_Instruction; Calendar^ cal_Calendar; Button^ b_Ok; public: CalendarDlg(void) { // Initialise la fenêtre this->Title = "SCD 1.0.0"; this->Width = 235; this->Height = 280; l_Instruction = gcnew Label(); l_Instruction->Content = "Selectionner une date"; Canvas::SetTop(l_Instruction, 5); Canvas::SetLeft(l_Instruction, 15); cal_Calendar = gcnew Calendar(); cal_Calendar->Width = 200; cal_Calendar->Height = 200; Canvas::SetTop(cal_Calendar, 30); Canvas::SetLeft(cal_Calendar, 10); b_Ok = gcnew Button(); b_Ok->Width = 80; b_Ok->Height = 25; b_Ok->Content = "OK"; Canvas::SetTop(b_Ok, 205); Canvas::SetLeft(b_Ok, 70); can_Canvas = gcnew Canvas(); can_Canvas->Children->Add(l_Instruction); can_Canvas->Children->Add(cal_Calendar); can_Canvas->Children->Add(b_Ok); this->Content = can_Canvas; b_Ok->Click += gcnew RoutedEventHandler(this, &CalendarDlg::OnOkClick); } void OnOkClick (Object^ sender, RoutedEventArgs^ e) { i_Date = cal_Calendar->SelectedDate; Fenetre2^ fenetre2 = gcnew Fenetre2(); fenetre2-> Show (); } }; ref class CScd : Application { public: CScd(void){} protected: virtual void OnStartup (StartupEventArgs^ e) override { Application::OnStartup (e); CalendarDlg^ cd_CalendarDlg = gcnew CalendarDlg (); cd_CalendarDlg -> Show (); } }; [STAThread] int main (array<String^>^ args) { return (gcnew CScd ())->Run (); }
Partager