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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
{}
type
pTrayRadioStation = ^tTrayRadioStation;
tTrayRadioStation = record
name:pWideChar;
handle:THANDLE;
end;
function MyStrSort(para1:pointer; para2:pointer):int; cdecl;
begin
result:=StrCmpW(pTrayRadioStation(para1).name,pTrayRadioStation(para2).name);
end;
function MakeStationsMenu:HMENU;
var
hContact:Cardinal;
sl:TSortedList;
p:pWideChar;
i:integer;
flag:integer;
tmp:pTrayRadioStation;
begin
result:=CreatePopupMenu;
if result<>0 then
begin
FillChar(sl,SizeOf(sl),0);
sl.increment:=16;
sl.sortFunc:=@MyStrSort;
hContact:=CallService(MS_DB_CONTACT_FINDFIRST,0,0);
while hContact<>0 do
begin
if StrCmp(PAnsiChar(CallService(MS_PROTO_GETCONTACTBASEPROTO,hContact,0)),cPluginName)=0 then
begin
p:=DBReadUnicode(hContact,strCList,'MyHandle',nil);
if p<>nil then
begin
mGetMem(tmp,SizeOf(tTrayRadioStation));
tmp.name:=p;
tmp.handle:=hContact;
List_InsertPtr(@sl,tmp);
end;
end;
hContact:=CallService(MS_DB_CONTACT_FINDNEXT,hContact,0);
end;
for i:=0 to sl.realCount-1 do
begin
if (i=0) or ((i mod 20)<>0) then
flag:=MF_STRING
else
flag:=MF_STRING or MF_MENUBARBREAK;
tmp:=sl.Items[i];
AppendMenuW(result,flag,tmp.handle,tmp.name);
mFreeMem(tmp.name);
mFreeMem(tmp);
end;
List_Destroy(@sl);
end;
end;
function CreateTrayMenu(wParam:WPARAM;lParam:LPARAM):int; cdecl;
const
startid = 100;
var
menu:HMENU;
flag,id:integer;
pt:TPOINT;
playstr:pWideChar;
begin
id:=0;
menu:=CreatePopupMenu;
if menu<>0 then
begin
if gVolume<0 then
flag:=MF_STRING+MF_CHECKED
else
flag:=MF_STRING+MF_UNCHECKED;
if CallService(MS_RADIO_COMMAND,MRC_STATUS,RD_STATUS_GET)<>RD_STATUS_PAUSED then
playstr:='Pause'
else
playstr:='Play';
AppendMenuW(menu,flag ,startid+1,TranslateW('Mute'));
AppendMenuW(menu,MF_STRING,startid+2,TranslateW(playstr));
AppendMenuW(menu,MF_STRING,startid+3,TranslateW('Stop'));
AppendMenuW(menu,MF_SEPARATOR,0,nil);
AppendMenuW(menu,MF_POPUP,MakeStationsMenu,TranslateW('Play Station'));
GetCursorPos(pt);
id:=integer(TrackPopupMenu(menu,TPM_RETURNCMD+TPM_NONOTIFY,pt.x,pt.y,0,hiddenwindow,nil));
case id of
0: ; // nothing
startid+1: begin // mute
Service_RadioMute(0,0);
end;
startid+2: begin // play/pause
CallService(MS_RADIO_COMMAND,MRC_PAUSE,0);
end;
startid+3: begin // stop
CallService(MS_RADIO_COMMAND,MRC_STOP,0);
end;
else // choose station
Service_RadioPlayStop(id,0);
end;
DestroyMenu(menu);
end;
result:=id;
end;
procedure CreateMIMTrayMenu;
var
mi:TCListMenuItem;
begin
if ServiceExists(MS_CLIST_ADDTRAYMENUITEM)<>0 then
// if hiddenwindow<>0 then
begin
FillChar(mi, sizeof(mi), 0);
mi.cbSize :=sizeof(mi);
mi.pszService:=MS_RADIO_TRAYMENU;
mi.szName.a :=cPluginName;
mi.hIcon :=CallService(MS_SKIN2_GETICON,0,lparam(IcoBtnSettings));
Menu_AddTrayMenuItem(@mi);
end;
end;
|