




















































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





















































1 // Fig. 12.7: Form1.h 2 // Creating an event handler. 3 4 #pragma once 5 6 7 namespace SimpleEventTest 8 { 9 using namespace System; 10 using namespace System::ComponentModel; 11 using namespace System::Collections; 12 using namespace System::Windows::Forms; 13 using namespace System::Data; 14 using namespace System::Drawing; 15 16 ///
52 // display a MessageBox when the user clicks the form 53 private: System::Void Form1_Click(System::Object * sender, 54 System::EventArgs * e) 55 { 56 MessageBox::Show( S"Form was pressed" ); 57 } 58 59 }; 60 }
1 // Fig. 12.8: Form1.cpp 2 // Demonstrating an event handler. 3 4 #include "stdafx.h" 5 #include "Form1.h" 6 #include <windows.h> 7 8 using namespace SimpleEventTest; 9 10 int APIENTRY _tWinMain(HINSTANCE hInstance, 11 HINSTANCE hPrevInstance, 12 LPTSTR lpCmdLine, 13 int nCmdShow) 14 { 15 System::Threading::Thread::CurrentThread->ApartmentState = 16 System::Threading::ApartmentState::STA; 17 Application::Run(new Form1()); 18 return 0 ; 19 }