Ich habe jetzt
hier die Prozedur SendBroadcastMessage gefunden, allerdings für Kylix.
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26:
| type TPrivateMessage = record ID: cardinal; Handled: boolean; pData: pointer; end; function SendBroadcastMessage(Target: TObject; MsgID: cardinal; pData: pointer = nil): boolean;
implementation
function SendBroadcastMessage(Target: TObject; MsgID: cardinal; pData: pointer = nil): boolean; var Msg: TPrivateMessage; begin Result := FALSE; if Target = nil then EXIT; Msg.ID := MsgID; Msg.Handled := FALSE; Msg.pData := pData; Target.Dispatch(Msg); if not Msg.Handled then if Target is TWidgetControl then TWidgetControl(Target).Broadcast(Msg); Result := Msg.Handled; end; |
Diese habe ich jetzt an Windows angepasst:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55:
| program Project1;
uses Forms, Windows, Controls, Unit1 in 'Unit1.pas' , Fortschritt_Unit in 'Fortschritt_Unit.pas' , Einstellungen_Unit in 'Einstellungen_Unit.pas' ;
{$R *.res}
var mHandle: THandle;
function SendBroadcastMessage(Target: TObject; MsgID: cardinal; pData: pointer = nil): boolean; type TPrivateMessage = record ID: cardinal; Handled: boolean; pData: pointer; end; var Msg: TPrivateMessage; begin Result := FALSE; if Target = nil then EXIT; Msg.ID := MsgID; Msg.Handled := FALSE; Msg.pData := pData; Target.Dispatch(Msg); if not Msg.Handled then if Target is TWinControl then TWinControl(Target).Broadcast(Msg); Result := Msg.Handled; end;
begin mHandle:=CreateMutex(nil, True, PChar('MP3-Tag-Editor')); if GetLastError=ERROR_ALREADY_EXISTS then begin SendBroadcastMessage(Application, 2763); Halt end else begin Application.Initialize; Application.Title:='MP3-Tag-Editor'; Application.CreateForm(TForm1, Form1); Application.CreateForm(TForm2, Form2); Application.CreateForm(TForm3, Form3); Application.Run end; if mHandle<>0 then begin CloseHandle(mHandle); end; end. |
Allerdings schickt er die nicht ab, da Application nicht vom Typ TWinControl zu sein scheint. Was muss ich an dessen stelle an die Funktion übergeben?