Не совсем новый ответ, но здесь приведено выше в C ++ с использованием объектов .NET Framework и т. Д.:
CRXViewerNetControl(void)
{
InitializeComponent();
// OK, go though the CRViewer and find the Print Button in the toolbar. When we find it,
// attach a "Click" event handler so that we can detect the operator clicking the button to
// print the report.
for (Int32 i = 0; i < CRXViewer->Controls->Count; i++)
{
if (dynamic_cast<System::Windows::Forms::ToolStrip^>(CRXViewer->Controls[i]))
{
System::Windows::Forms::ToolStrip^ ctlToolStrip = dynamic_cast<System::Windows::Forms::ToolStrip^>(CRXViewer->Controls[i]);
for (int j = 0; j < ctlToolStrip->Items->Count; j++)
{
if (dynamic_cast<System::Windows::Forms::ToolStripButton^>(ctlToolStrip->Items[j]))
{
System::Windows::Forms::ToolStripButton^ ctlToolStripButton = dynamic_cast<System::Windows::Forms::ToolStripButton^>(ctlToolStrip->Items[j]);
if (ctlToolStripButton->ToolTipText->ToLower()->Contains("print"))
{
//Adding a handler for our propose
ctlToolStripButton->Click += gcnew System::EventHandler(this, &CRXViewerNetControl::printButton_Click);
}
}
}
}
}
}
private: System::Void printButton_Click(System::Object^ sender, System::EventArgs^ e)
{
MessageBox::Show("Printed");
}