📄 main.~pas
字号:
function HavMultResu:boolean;
procedure setListBmp;
// PROCEDURE CMEraseBkgnd(var Message:TWMEraseBkgnd);Message WM_ERASEBKGND;
function MyOpen:boolean;
function MyPlay:boolean;
procedure MyPause;
procedure MyResume;
procedure MyStop;
procedure MyClose;
procedure MyShowDisplayer;
procedure MySetAudio(value:byte);
procedure SetGridCell(strType,value:string;vRow:integer);
function GetGridCell(strType:string;vRow:integer):string;
end;
var
MainFrm: TMainFrm;
PNotify:PNotifyIconDataA; //托盘图标结构
function Registok(zc_code,sq_code:string):boolean;
Function FormatStr(S:string;pLen:integer;posLeft,useSpace:boolean):string; //将字符串射为指定长度,不够用空格(' ')替代
procedure showInformation(vstr:string);
implementation
uses selDir,MoveItem,ConfirmDelete,about, displayScr,LyricEditor, lyricBar,selSameItem
,regist,U_crypt;
{$R *.dfm}
procedure showInformation(vstr:string);
begin
application.MessageBox(pchar(vstr),pchar(application.title),mb_ok+mb_iconInformation) ;
end;
procedure showWarning(vstr:string);
begin
application.MessageBox(pchar(vstr),pchar(application.title),mb_ok+mb_iconWarning) ;
end;
procedure TMainFrm.MediaPlayer1Notify(Sender: TObject);
begin
{ with MediaPlayer1 do
begin
ModeSign.Caption :=ModeStr[mode];
ErrLb.Caption :=inttostr(error)+':'+ mediaplayer1.ErrorMessage;
notify:=true;
end;
}
end;
procedure TMainFrm.FormCreate(Sender: TObject);
begin
Application.Title := APP_TITLE;
TitleSign.Caption := Application.Title;
GenreNameList := TStringList.Create;
GenreNameList.CommaText :='"Blues","Classic Rock","Country",' +
'"Dance","Disco","Funk","Grunge","Hip-Hop","Jazz","Metal",' +
'"New Age","Oldies","Other","Pop","R&B","Rap","Reggae","Rock",' +
'"Techno","Industrial","Alternative","Ska","Death Metal",' +
'"Pranks","Soundtrack","Euro-Techno","Ambient","Trip-Hop","Vocal"' +
',"Jazz+Funk","Fusion","Trance","Classical","Instrumental","Acid"' +
',"House","Game","Sound Clip","Gospel","Noise","AlternRock",' +
'"Bass","Soul","Punk","Space","Meditative","Instrumental Pop",' +
'"Instrumental Rock","Ethnic","Gothic","Darkwave",' +
'"Techno-Industrial","Electronic","Pop-Folk","Eurodance","Dream",' +
'"Southern Rock","Comedy","Cult","Gangsta","Top 40",' +
'Christian Rap","Pop/Funk","Jungle","Native American","Cabaret",' +
'"New Wave","Psychedelic","Rave","Showtunes","Trailer","Lo-Fi",' +
'"Tribal","Acid Punk","Acid Jazz","Polka","Retro","Musical",' +
'"Rock & Roll","Hard Rock","Folk","Folk/Rock","National Folk",' +
'"Swing","Bebob","Latin","Revival","Celtic","Bluegrass",' +
'"Avantgarde","Gothic Rock","Progressive Rock",' +
'"Psychedelic Rock","Symphonic Rock","Slow Rock","Big Band",' +
'"Chorus","Easy Listening","Acoustic","Humour","Speech",' +
'"Chanson","Opera","Chamber Music","Sonata","Symphony",' +
'"Booty Bass","Primus","Porn Groove","Satire","Slow Jam","Club",' +
'"Tango","Samba","Folklore"';
GenreCmbBox.Items :=GenreNameList;
//创建歌词变量
Lyric:=TStringlist.create;
HaveLyric:=false;
LyricIndex:=-1;
MoveTitle.Width :=self.Width -170;
if regisyslb.Visible then
begin
MoveTitle.Width :=MoveTitle.Width- regisyslb.width;
MoveTitle.Left :=regisyslb.width+regisyslb.left+10;
end
else
MoveTitle.Left :=TitleSign.width+TitleSign.left+10;
image3.Picture.Icon :=self.Icon;
//建立“托盘”图标
New(PNotify);
PNotify^.Wnd:=self.Handle;
PNotify^.uID:=0;
PNotify^.uFlags:=NIF_ICON+NIF_MESSAGE+NIF_TIP;
PNotify^.hIcon:=self.Icon.Handle;
PNotify^.uCallbackMessage:=MyIcoMes;
PNotify^.szTip:=APP_TITLE;
Shell_NotifyIcon(NIM_ADD,PNotify);
//能够接受拖放文件
DragAcceptFiles(self.Handle ,True); //能够接受拖放文件
// counter:=0; //全屏时 ,隐藏鼠标指针 计时器
listChged:=false;
filenamechg:=false;
DeviceId := -1;
IniVolume; //读取系统声音
PressDot := false;
openCdDoor:=True;
playerState:=psClosed;
sglist.DefaultRowHeight :=16;
sglist.RowCount :=2 ;
sglist.FixedCols :=1;
sglist.Fixedrows:=1;
// sglist.RowHeights[0]:=14;
self.Constraints.minHeight :=138;
self.Constraints.MinWidth :=402;
//读取注册表中系统信息
readSysInfo;
//
playItem:=-1;
// 载入默认清单
// LoadSBtnClick(nil);
if sglist.rowcount>0 then
if self.Height =self.Constraints.MinHeight then
selitem.Caption :='-> '+GetGridCell('全名',listbox1.itemindex+1);
ListBmp:=TBitmap.Create;
if not mnuListBack.Checked then
begin
MainFrm.Brush.Bitmap:=nil;
mainfrm.Brush.Color :=mainfrm.color;
end
else
begin
//处理界面背景图象
if fileexists('backFace.bmp') then
begin
try
backimg.Picture.LoadFromFile('backFace.bmp');
self.Brush.Bitmap := backimg.Picture.Bitmap ;
setListBmp;
except
Messagedlg('背景图片载入失败',mtwarning,[mbok],0);
end;
end
else
begin
mnulistBack.Checked :=false;
Application.MessageBox('背景图像未找到,请重新设置',pchar(application.title),mb_ok+mb_iconinformation) ;
end;
end;
//-----------------------------
showMode;
//-----------------------------
end;
procedure TMainFrm.readSysInfo;
var
registerTemp : TRegistry;
regWinHeight,i,j,Num:integer; //
procedure readColWidth(str1:string);
begin
with registerTemp do
begin
i:=GetColIndex(Mainfrm.sglist,str1);
if i>=0 then
begin
if valueExists('W_'+str1) then
sglist.ColWidths[i]:=ReadInteger('W_'+str1)
else
begin
sglist.ColWidths[i]:=30;
WriteInteger('W_'+str1,30);
end;
end
else
begin
i:=GetColIndex(HideColGrid,str1);
if valueExists('W_'+str1) then
HideColGrid.ColWidths[i]:=ReadInteger('W_'+str1)
else
begin
HideColGrid.ColWidths[i]:=40;
WriteInteger('W_'+str1,40 );
end;
end;
end;
end;
begin
registerTemp := TRegistry.Create; //准备使用注册表
with registerTemp do
try
RootKey:=HKEY_LOCAL_MACHINE; //存放在此根下
OpenKey('Software\'+APP_TITLE,True);
Num:=0;
for i:=0 to 10 do
begin
if valueExists('v'+formatfloat('00',i)) then
if readbool('v'+formatfloat('00',i)) then
begin
inc(num);
end;
end;
if Num=0 then //表示第一次登陆
begin
Num:=11;
sglist.ColCount :=Num;
sglist.cells[0,0]:='No.';
sglist.Cells[1,0]:='名称';
sglist.Cells[2,0]:='类型';
sglist.Cells[3,0]:='时间';
sglist.Cells[4,0]:='标题';
sglist.Cells[5,0]:='艺术家';
sglist.Cells[6,0]:='专辑';
sglist.Cells[7,0]:='出版年';
sglist.Cells[8,0]:='评论';
sglist.Cells[9,0]:='流派';
sglist.Cells[10,0]:='全名';
sglist.ColCount :=11;
sglist.ColWidths[0]:=40;
sglist.ColWidths[1]:=200;
sglist.ColWidths[2]:=30;
sglist.ColWidths[3]:=50;
sglist.ColWidths[4]:=100;
sglist.ColWidths[5]:=60;
sglist.ColWidths[6]:=80;
sglist.ColWidths[7]:=40;
sglist.ColWidths[8]:=160;
sglist.ColWidths[9]:=60;
sglist.ColWidths[10]:=300;
end
else
begin
sglist.ColCount :=Num;
j:=0;
for i:=0 to 10 do
begin
if valueExists('P'+formatfloat('00',i)) then
begin
TmenuItem(findcomponent('menu'+inttostr(1+i))).Hint := Readstring('P'+formatfloat('00',i));
TmenuItem(findcomponent('menu'+inttostr(1+i))).caption := '['+Readstring('P'+formatfloat('00',i))+']';
if ReadBool('v'+formatfloat('00',i)) then
begin
sglist.Cells[j,0]:=Readstring('P'+formatfloat('00',i)) ;
TmenuItem(findcomponent('menu'+inttostr(1+i))).checked :=true;
inc(j);
end
else
begin
TmenuItem(findcomponent('menu'+inttostr(1+i))).checked :=false;
if (HideColGrid.Cells[0,0]='') and (HideColGrid.ColCount =1) then
HideColGrid.Cells[HideColGrid.ColCount-1,0]:=Readstring('P'+formatfloat('00',i))
else
begin
HideColGrid.ColCount :=HideColGrid.ColCount+1;
HideColGrid.Cells[HideColGrid.ColCount-1,0]:=Readstring('P'+formatfloat('00',i));
end;
end;
end
else
WriteString('P'+formatfloat('00',i),sglist.Cells[i,0] );
end;
readColWidth('No.');
readColWidth('类型');
readColWidth('名称');
readColWidth('时间');
readColWidth('标题');
readColWidth('艺术家');
readColWidth('专辑');
readColWidth('出版年');
readColWidth('评论');
readColWidth('流派');
readColWidth('全名');
end;
if valueExists('ImgFace') then
mnulistBack.checked :=readbool('ImgFace')
else
writeBool('ImgFace',True);
if valueExists('Volume') then
begin
VolLbl.Width :=ReadInteger('Volume');
VolLbl.Left :=VolImg.Left+(VolImg.Width-VolLbl.width) ;
end
else
WriteInteger('Volume',VolLbl.Width );
RegWinHeight:=290; //默认
if ValueExists('WinHeight') then
RegWinHeight:=ReadInteger('WinHeight')
else
WriteInteger('WinHeight',290 );
//是否显示曲目清单
self.OnResize :=nil;
if ValueExists('WinWidth') then
self.width :=ReadInteger('WinWidth')
else
begin
WriteInteger('WinWidth',402 );
self.width :=402;
end;
self.Left :=(screen.width-self.width) div 2;
if valueExists('WinTop') then
self.Top :=readInteger('WinTop')
else
begin
self.Top :=(screen.Height-RegWinHeight) div 2;
writeInteger('WinTop',self.top);
end;
if ValueExists('ShowList') then
begin
if ReadBool('ShowList') then
self.Height :=RegWinHeight
else
self.Height :=self.Constraints.minHeight;
end
else
writeBool('ShowList',true);
self.OnResize :=FormResize;
self.FormResize(nil);
finally
CloseKey;
Free;
end;
end;
procedure TMainFrm.SaveSysInfo;
var
registerTemp : TRegistry;
i:integer;
procedure WriteColWidth(str1:string);
begin
with registerTemp do
begin
i:= GetColindex(Mainfrm.sglist,str1);
if i>=0 then
WriteInteger('W_'+str1,sglist.ColWidths[i])
else
begin
i:=GetColindex(HideColGrid,str1);
WriteInteger('W_'+str1,HideColGrid.ColWidths[i]);
end;
end;
end;
begin
registerTemp := TRegistry.Create; //准备使用注册表
with registerTemp do
try
RootKey:=HKEY_LOCAL_MACHINE; //存放在此根下
OpenKey('Software\'+APP_TITLE,True);
writeBool('ImgFace',mnulistBack.Checked );
WriteInteger('Volume',VolLbl.Width );
writeBool('ShowList',(self.Height<>self.Constraints.MinHeight));
writeInteger('WinHeight',self.Height);
writeInteger('WinWidth',self.Width);
writeInteger('WinTop',self.top);
WriteColWidth('名称');
WriteColWidth('类型');
WriteColWidth('时间');
WriteColWidth('标题');
WriteColWidth('艺术家');
WriteColWidth('专辑');
WriteColWidth('出版年');
WriteColWidth('评论');
WriteColWidth('流派');
WriteColWidth('全名');
WriteColWidth('No.');
for i:=0 to 10 do
begin
WriteString('P'+formatfloat('00',i),TmenuItem(findcomponent('menu'+inttostr(1+i))).hint );
WriteBool('v'+formatfloat('00',i),TmenuItem(findcomponent('menu'+inttostr(1+i))).checked );
end;
finally
CloseKey;
Free;
end;
end;
procedure TMainFrm.setListBmp;
var x1,y1:integer;
rect1,rect2:Trect;
begin
sglist.Brush.Bitmap:=nil;
ListBmp.Width :=backimg.Picture.Bitmap.Width;
ListBmp.height :=backimg.Picture.Bitmap.height;
x1:=(notebook1.Left+2) mod backimg.Picture.Bitmap.Width;
y1:=(notebook1.Top+2) mod backimg.Picture.Bitmap.Height;
//1
with rect1 do
begin
left:=0;
if y1=0 then
top:=0
else
top:=listbmp.Height -y1;
right:=listbmp.Width-x1;
bottom:=listbmp.Height ;
end;
with rect2 do
begin
left:=x1;top:=0;
right:=listbmp.Width;
if y1=0 then
bottom:=listBmp.Height
else
bottom:=y1;
end;
ListBmp.Canvas.CopyRect(rect1,backimg.Picture.Bitmap.canvas,rect2);
//2
with rect1 do
begin
left:=0;top:=0;
right:=listbmp.Width-x1;
bottom:=listbmp.Height-y1;
end;
with rect2 do
begin
left:=x1;
top:=y1;
right:=listbmp.Width;
bottom:=listbmp.Height;
end;
ListBmp.Canvas.CopyRect(rect1,backimg.Picture.Bitmap.canvas,rect2);
//3
if (y1<>0) then
begin
with rect1 do
begin
left:=listbmp.Width-x1;
top:=listbmp.Height-y1;
right:=listbmp.Width;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -