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
|
{}
const
MaxLangs = 11;
LangArray:array [0..MaxLangs-1] of record
code:array [0..1] of AnsiChar;
name:pWideChar;
end= (
(code:#0#0 ; name: 'no language';),
(code:'zh' ; name: 'Chinese' ;),
(code:'en' ; name: 'English' ;),
(code:'fr' ; name: 'French' ;),
(code:'de' ; name: 'German' ;),
(code:'hi' ; name: 'Hindi' ;),
(code:'it' ; name: 'Italian' ;),
(code:'ja' ; name: 'Japanese' ;),
(code:'pt' ; name: 'Portuguese' ;),
(code:'ru' ; name: 'Russian' ;),
(code:'es' ; name: 'Spanish' ;)
);
procedure ClearInfo(dlg:HWND);
begin
SetDlgItemTextW(dlg,IDC_DATA_ARTIST,'');
SetDlgItemTextW(dlg,IDC_DATA_ALBUM ,'');
SetDlgItemTextW(dlg,IDC_DATA_TRACK ,'');
SetDlgItemTextW(dlg,IDC_DATA_TAGS ,'');
SetDlgItemTextW(dlg,IDC_DATA_INFO ,'');
end;
procedure ClearData(var data:tLastFMInfo);
begin
mFreeMem(data.artist);
mFreeMem(data.album);
mFreeMem(data.title);
mFreeMem(data.tags);
mFreeMem(data.info);
mFreeMem(data.image);
end;
function DlgProcOptions(Dialog:HWND;hMessage:uint;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall;
var
tmp:longbool;
bmp,wnd:HWND;
lang:integer;
data:tLastFMInfo;
begin
result:=0;
case hMessage of
WM_INITDIALOG: begin
TranslateDialogDefault(Dialog);
SetDlgItemTextA(Dialog,IDC_LOGIN,lfm_login);
SetDlgItemTextA(Dialog,IDC_PASS ,lfm_password);
SetDlgItemInt (Dialog,IDC_TRIES,lfm_tries,false);
wnd:=GetDlgItem(Dialog,IDC_LANGUAGE);
for lang:=0 to MaxLangs-1 do
with LangArray[lang] do
CB_AddStrDataW(wnd,TranslateW(name),
ord(code[0])+(ord(code[1]) shl 8),lang);
CB_SelectData(wnd,lfm_lang);
end;
WM_COMMAND: begin
case wParam shr 16 of
BN_CLICKED: begin
ClearInfo(Dialog);
FillChar(data,SizeOf(data),0);
lfm_lang:=CB_GetData(GetDlgItem(Dialog,IDC_LANGUAGE));
if loword(wParam)=IDC_INFO_ARTIST then
begin
SetDlgItemTextW(Dialog,IDC_ALT,TranslateW('Similar artists'));
GetArtistInfo(data,lfm_lang);
SetDlgItemTextW(Dialog,IDC_DATA_ALBUM,data.similar);
end
else
begin
SetDlgItemTextW(Dialog,IDC_ALT,TranslateW('Album'));
if loword(wParam)=IDC_INFO_TRACK then
GetTrackInfo (data,lfm_lang)
else
GetAlbumInfo (data,lfm_lang);
SetDlgItemTextW(Dialog,IDC_DATA_ALBUM,data.album);
end;
SetDlgItemTextW(Dialog,IDC_DATA_ARTIST,data.artist);
SetDlgItemTextW(Dialog,IDC_DATA_TRACK ,data.title);
SetDlgItemTextW(Dialog,IDC_DATA_TAGS ,data.tags);
SetDlgItemTextW(Dialog,IDC_DATA_INFO ,data.info);
bmp:=LoadImageURL(data.image,64);
if bmp<>0 then
DeleteObject(SendDlgItemMessage(Dialog,IDC_DATA_PIC,STM_SETIMAGE,IMAGE_BITMAP,bmp));
ClearData(data);
end;
EN_CHANGE:
case loword(wParam) of
IDC_LOGIN,IDC_PASS,IDC_TRIES:
SendMessage(GetParent(Dialog),PSM_CHANGED,0,0);
end;
end;
end;
WM_NOTIFY: begin
if integer(PNMHdr(lParam)^.code)=PSN_APPLY then
begin
mFreeMem(lfm_login ); lfm_login :=GetDlgText(Dialog,IDC_LOGIN,true);
mFreeMem(lfm_password); lfm_password:=GetDlgText(Dialog,IDC_PASS ,true);
mFreeMem(session_id);
mFreeMem(np_url);
mFreeMem(sub_url);
lfm_tries:=GetDlgItemInt(Dialog,IDC_TRIES,tmp,false);
lfm_lang:=CB_GetData(GetDlgItem(Dialog,IDC_LANGUAGE));
SaveOpt;
end;
end;
else
{result:=}DefWindowProc(Dialog,hMessage,wParam,lParam);
end;
end;
|