Warum TLogMessage als Object?
Delphi-Quellcode:
type
PLogMessage = ^TLogMessageMSG;
TLogMessageMSG = record
sLogText : String[255];
bIsDebug : boolean;
end;
var
LogMsg: PLogMessage;
const
PM_MsgFromThread = WM_USER +4;
procedure TComThread.SendMsgToMain(LogText: string; Debug: Boolean);
begin
New(LogMsg);
LogMsg^.sLogText:=LogText;
LogMsg^.bIsDebug:=Debug;
SendMessage(frm_Main.Handle, PM_MsgFromThread,0,LParam(LogMsg));
end;
Empfangen im Hauptthread:
Delphi-Quellcode:
procedure Tfrm_main.LogMsgFromThread(var msg: TMessage);
var
P: PLogMessage;
fdebug: Boolean;
fLogText: string;
begin
try
P := PLogMessage(MSG.LParam);
fdebug:=P.bIsDebug;
fLogText:=P.sLogText;
finally
Dispose(P);
end;
end;
Mavarik