// windowproc der plugin basisklasse
procedure TCustomPlugIn.WndProc(
var Msg: TMessage);
begin
if (Msg.Msg > WM_PLUGIN)
and (Msg.Msg <= CM_PLUGIN)
then
with Msg
do
begin
case Msg
of
PM_EXECUTE :
begin
run;
end;
PM_REGEVENT :
begin
with PPlugInEvent(lParam)^
do
RegisterNewEvent(
name,EventID,
Handle,lParam);
end;
PM_UNREGEVENT:
begin
with PUnRegisterEvent(lParam)^
do
UnRegisterEvent(
name,
handle);
end;
PM_QUERYSTATUS: result := OrdToInt(Status);
PM_RELEASE : PostMessage(PlugInManager,PM_RELEASE,MsgHandle,0);
PM_GETPLUGIN: result := LongInt(IPlugIn(self));
else
Result := DefWindowProc(MsgHandle,Msg,WParam,LParam);
end;
end
else
Msg.Result := DefWindowProc(MsgHandle,Msg.Msg,Msg.WParam,Msg.LParam);
end;
//windowproc der wrapperklasse für TControl
procedure TControlWrapper.WndProc(
var Msg: TMessage);
var Data: IControlData;
begin
if Msg.Msg > WM_PLUGIN
then
with Msg
do
case Msg
of
PM_GETDATA:
if Assigned(FControl)
then
begin
// FCriticalSection.Acquire;
try
GetControlData(Data);
IControlData(result) := Data;
finally
Data :=
nil;
// FCriticalSection.Release;
end;
end;
PM_SENDDATA:
begin
// FCriticalSection.Acquire;
try
Data := IControlData(lParam);
if Assigned(Data)
and supports(Data, IControlData)
then
SetControlData(Data);
finally
Data :=
nil;
// FcriticalSection.Release;
end;
end;
CM_CHANGELOCK: ControlLocked :=
not ControlLocked;
CM_GETLOCKSTATE:
if FControlLocked
then
result := 1
else
result := 0;
end
else
Msg.Result := DefWindowProc(MsgHandle,Msg.Msg,Msg.WParam,msg.LParam);
end;
// so hängt sich der wrapper bei dem zugehörigen TControl im Hauptkontext ein
FOldWindowProc := FControl.WindowProc;
FControl.WindowProc := ControlWndProc;
procedure TControlWrapper.ControlWndProc(
var Msg: TMessage);
begin
FOldWndProc(msg);
if (AllocatedPlugIn > 0)
then
begin
with Msg
do
SendMessage(AllocatedPlugIn,msg,wParam,lParam);
end;
end;