Change example for Delphi

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.

var
   MyRaster: LEADRaster;

procedure TForm1.Button2Click(Sender: TObject);
begin
   //Create the object
   MyRaster:= CreateComObject (CLASS_LEADRaster) as LEADRaster;
   LEADEventSink1.Connect (MyRaster, _LEADRasterEvents);
   //create a new bitmap
   MyRaster.ScaleMode:= 3;
   MyRaster.CreateBitmap (100, 100, 24); //this will fire the Change event
end;


procedure TForm1. LEADEventSink1Invoke(Sender: TObject; DispID: Integer;
  const IID: TGUID; LocaleID: Integer; Flags: Word; Params: tagDISPPARAMS;
  varResult, ExcepInfo, ArgErr: Pointer);
var
   nChange: Longint;
begin
   case (DispID) of
      LEADRASTEREVENTS_CHANGE:
      begin
         nChange:= OleVariant(Params.rgvarg^[2]);
          ShowMessage ('Image data changed: ' + IntToStr(nChange));
      end;
   end;
end;