Contents - Index - Previous - Next


OnHandleMessage event

 

Applies to

TVCLUnZip component

 

Declaration

property OnHandleMessage: THandleMessageEvent = procedure(Sender: TObject; const MessageID: Integer; const Msg1: String; const Msg2: String; const flags: LongWord; var Return: Integer); of Object;

 

Description

 

VCLZip handles all interfacing with the GUI through an internal default OnHandleMessage event, unless you define your own OnHandleMessage event.  If you wish, for instance, to avoid writing to a GUI (say for instance you are running in a DLL), you can write event and consume them.

 

The internal default event looks like this:

 

function TVCLUnZip.DefaultHandleMessage(const MessageID: Integer; const Msg1: String; const Msg2: String; const flags: LongWord): Integer;

var

  m1, m2: PChar;

begin

     m1 := StrToPChar(Msg1);

     m2 := StrToPchar(Msg2);

     Result := MessageBox(0,m1,m2,flags);

     StrDispose(m1);

     StrDispose(m2);

end;

 

Here is an example of a call that VCLZip makes to this event to prompt for overwrite of a file.

 

    StrPCopy( MsgArray, LoadStr(IDS_REPLACEFILE) + Filename[Index] + '?' );

    tmpMStr := LoadStr(IDS_FILEXISTALERT);

    OverWriteIt := DoHandleMessage(IDS_FILEXISTALERT,MsgArray, StringAsPChar(tmpMStr), MB_YESNO) = IDYES;