1 2 //--------------------------------------------------------------------------- 3 4 #include <vcl.h> 5 #pragma hdrstop 6 7 #include "Unit1.h" 8 //--------------------------------------------------------------------------- 9 #pragma package(smart_init) 10 #pragma resource "*.dfm" 11 TForm1 *Form1; 12 //--------------------------------------------------------------------------- 13 __fastcall TForm1::TForm1(TComponent* Owner) 14 : TForm(Owner) 15 { 16 } 17 // Here are two methods to have a button perform a click by code 18 19 //1st Method 20 void __fastcall TForm1::Button1Click(TObject *Sender) 21 { 22 Button2->Perform(WM_LBUTTONDOWN, 0, 0); 23 Button2->Perform(WM_LBUTTONUP, 0, 0); 24 } 25 //2nd method 26 27 void __fastcall TForm1::Button3Click(TObject *Sender) 28 { 29 Button2->Click(); 30 } 31 32 void __fastcall TForm1::Button2Click(TObject *Sender) 33 { 34 ShowMessage("Hello"); 35 } 36 //--------------------------------------------------------------------------- 37