Change example for C++ Builder

Typically, you would use this event to flag changed image data and prompt the user to save the changes before closing a window or exiting an application. That use of the event cannot be tested properly without writing a complete application; so this example just shows you a simple test of the event.

This example is for an ILEADRaster Object created at run-time.

LEADRaster* pMyRaster;

void __fastcall TForm1::Button2Click(TObject *Sender)
{
   CoCreateInstance(CLSID_LEADRaster, NULL, CLSCTX_ALL, IID_ILEADRaster, (void**)&pMyRaster);
   LEADEventSink1->Connect (pMyRaster, DIID__LEADRasterEvents);
   //create a new bitmap
   pMyRaster->ScaleMode = (RasterScaleModeConstants)3;
   pMyRaster->CreateBitmap (100, 100, 24); //this will fire the Change event
   pMyRaster->Release();
}
void __fastcall TForm1:: LEADEventSink1Invoke(TObject *Sender, int DispID,
      const TGUID &IID, int LocaleID, WORD Flags, tagDISPPARAMS &Params,
      Pointer varResult, Pointer ExcepInfo, Pointer ArgErr)
{
   switch (DispID)
   {
        case LEADRASTEREVENTS_CHANGE:
      {
         int nChange = (OleVariant)(Params.rgvarg[2]);
          ShowMessage ("Image data changed: " + IntToStr(nChange));
        }
      break;
   }
}