-
Notifications
You must be signed in to change notification settings - Fork 4
/
appwindowunit.pas
executable file
·90 lines (75 loc) · 1.73 KB
/
appwindowunit.pas
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
unit appwindowunit;
{$mode objfpc}{$H+}
interface
uses
Utility, Types, Exec, amigados, workbench, Video;
const
ID = 1;
type
TOnDropItem = procedure(Path: string; Name: string; DropPos: TPoint);
procedure MakeAppWindow;
procedure CheckForAppMsgs;
procedure DestroyAppWindow;
var
OnDropItem: TOnDropItem = nil;
implementation
var
AppWindow: PAppWindow;
AppMsgPort: PMsgPort;
procedure MakeAppWindow;
begin
AppMsgPort := CreateMsgPort();
if not Assigned(AppMsgPort) then
Exit;
AppWindow := AddAppWindowA(id, 0, VideoWindow, AppMsgPort, nil);
if not Assigned(AppWindow) then
exit;
end;
var
Buffer: array[0..256] of Char;
procedure CheckForAppMsgs;
var
AppMsg: PAppMessage;
x,y: LongInt;
ArgList: PWBArgList;
Path, Name: string;
begin
if not Assigned(AppWindow) or not Assigned(AppWindow) or not Assigned(OnDropItem) then
Exit;
AppMsg := PAppMessage(GetMsg(AppMsgPort));
if Assigned(AppMsg) then
begin
// get mouse position
x := 0;
y := 0;
TranslateToCharXY(AppMsg^.am_MouseX, AppMsg^.am_MouseY, x, y);
//
if AppMsg^.am_NumArgs >= 1 then
begin
ArgList := AppMsg^.am_ArgList;
FillChar(Buffer[0], Length(Buffer), 0);
if NameFromLock(ArgList^[1].wa_Lock, @Buffer[0], 255) then
begin
Path := Buffer;
Name := string(ArgList^[1].wa_Name);
OnDropItem(Path, Name, Point(x, y));
end;
end;
ReplyMsg(PMessage(AppMsg));
end;
end;
procedure DestroyAppWindow;
begin
if Assigned(AppWindow) then
begin
RemoveAppWindow(AppWindow);
AppWindow := nil;
end;
//
if Assigned(AppMsgPort) then
begin
DeleteMsgPort(AppMsgPort);
AppMsgPort := nil;
end;
end;
end.