//---------------------------------------------------------------------------
#include <vcl.h>
#include <stdio.h>
#include <penwin.h>
#include "Unit1.h"
#include "Unit2.h"
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "trayicon"
#pragma resource "*.dfm"
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//陋擋隋粵徹 � 蜻瘢曉鼻 WInAmp
//柢頌痢� 囝閤錙順� �筧築獎曉�
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
TFormMain *FormMain;
int cury, curx, overx, overy;
bool btclick;
int seekx, seekoverx;
HWND waid;
bool moveseek, isseekmove;
long songlength, songposition;
AnsiString songtitle, songartist;
bool waok;
int yesno, lastyesno;
AnsiString curname="";
bool ischeck=false;
bool needrefresh;
int shutdownh=0, shutdownm=0, shutdowns=5;
int sllover=(-1);
const int sll=111;
//---------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall LeftTime()
{
HANDLE hToken;
TOKEN_PRIVILEGES tkp;
AnsiString buff;
shutdowns--;
if(shutdowns==-1){shutdowns=59;shutdownm--;}
if(shutdownm==-1){shutdownm=59;shutdownh--;}
if (shutdownm<10)
{
buff="0"+AnsiString(shutdownm);
FormMain->TimeM->Caption=buff;
} else
{
FormMain->TimeM->Caption=shutdownm;
}
if (shutdownh<10)
{
buff="0"+AnsiString(shutdownh);
FormMain->TimeH->Caption=buff;
} else
{
FormMain->TimeH->Caption=shutdownh;
}
if (shutdowns<10)
{
buff="0"+AnsiString(shutdowns);
FormMain->TimeS->Caption=buff;
} else
{
FormMain->TimeS->Caption=shutdowns;
}
if (shutdowns==0 && shutdownm==0 && shutdownh==0)
{
FormMain->Timer6->Enabled=false;
// Get a token for this process.
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken));
// Get the LUID for the shutdown privilege.
LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid);
tkp.PrivilegeCount = 1; // one privilege to set
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
// Get the shutdown privilege for this process.
AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
// Cannot test the return value of AdjustTokenPrivileges.
if (GetLastError() != ERROR_SUCCESS);
// Shut down the system and force all applications to close.
if (!ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCE, 0));
}
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void _fastcall FullTime(int hours, int minutes)
{
AnsiString buff;
shutdownm=shutdownm+minutes;
shutdownh=shutdownh+hours;
if(shutdownm==60){shutdownm=0;}
if(shutdownm==-1){shutdownm=59;}
if(shutdownh==24){shutdownh=0;}
if(shutdownh==-1){shutdownh=23;}
if (shutdownm<10)
{
buff="0"+AnsiString(shutdownm);
FormMain->TimeM->Caption=buff;
} else
{
FormMain->TimeM->Caption=shutdownm;
}
if (shutdownh<10)
{
buff="0"+AnsiString(shutdownh);
FormMain->TimeH->Caption=buff;
} else
{
FormMain->TimeH->Caption=shutdownh;
}
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall AdvanceHideShow()
{
btclick=0;
FormMain->Artist->Visible=!FormMain->Artist->Visible;
FormMain->AdvanceButUp->Visible=!FormMain->AdvanceButUp->Visible;
FormMain->AdvanceButDown->Visible=!FormMain->AdvanceButDown->Visible;
FormMain->Background_Advance->Visible=!FormMain->Background_Advance->Visible;
FormMain->Title->Visible=!FormMain->Title->Visible;
FormMain->Length->Visible=!FormMain->Length->Visible;
FormMain->Seek->Visible=!FormMain->Seek->Visible;
FormMain->Seek_Transp->Visible=!FormMain->Seek_Transp->Visible;
FormMain->SeekPos->Visible=!FormMain->SeekPos->Visible;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall OptionsHideShow()
{
btclick=0;
FormMain->Background_Options->Visible=!FormMain->Background_Options->Visible;
FormMain->OptionsButDown->Visible=!FormMain->OptionsButDown->Visible;
FormMain->OptionsButUp->Visible=!FormMain->OptionsButUp->Visible;
FormMain->Check->Visible=!FormMain->Check->Visible;
FormMain->Label1->Visible=!FormMain->Label1->Visible;
FormMain->TimeH->Visible=!FormMain->TimeH->Visible;
FormMain->TimeM->Visible=!FormMain->TimeM->Visible;
FormMain->TimeS->Visible=!FormMain->TimeS->Visible;
FormMain->TimeDiv->Visible=!FormMain->TimeDiv->Visible;
FormMain->TimeDiv2->Visible=!FormMain->TimeDiv2->Visible;
FormMain->TimeHDown->Visible=!FormMain->TimeHDown->Visible;
FormMain->TimeHUp->Visible=!FormMain->TimeHUp->Visible;
FormMain->TimeMDown->Visible=!FormMain->TimeMDown->Visible;
FormMain->TimeMUp->Visible=!FormMain->TimeMUp->Visible;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall ButRefresh()
{
if (FormMain->Timer1->Enabled==False && btclick!=1)
{
if (needrefresh)
{
FormMain->PrevBut->Picture=FormMain->PrevBut_off->Picture;
FormMain->PlayBut->Picture=FormMain->PlayBut_off->Picture;
FormMain->PauseBut->Picture=FormMain->PauseBut_off->Picture;
FormMain->StopBut->Picture=FormMain->StopBut_off->Picture;
FormMain->NextBut->Picture=FormMain->NextBut_off->Picture;
FormMain->AdvanceButDown->Picture=FormMain->AdvanceButDown_off->Picture;
FormMain->AdvanceButUp->Picture=FormMain->AdvanceButUp_off->Picture;
FormMain->OptionsButDown->Picture=FormMain->AdvanceButDown_off->Picture;
FormMain->OptionsButUp->Picture=FormMain->AdvanceButUp_off->Picture;
FormMain->TimeHUp->Picture=FormMain->TimeUp_off->Picture;
FormMain->TimeHDown->Picture=FormMain->TimeDown_off->Picture;
FormMain->TimeMUp->Picture=FormMain->TimeUp_off->Picture;
FormMain->TimeMDown->Picture=FormMain->TimeDown_off->Picture;
needrefresh=false;
}
}
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall GetSongTime()
{
songposition=SendMessage(waid, WM_USER, 0, 105)/1000;
songlength=SendMessage(waid, WM_USER, 1, 105);
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall PlayTime()
{
AnsiString buff;
long lm, ls, em, es;
AnsiString slm, sls, sem, ses;
GetSongTime();
if (songlength>0)
{
FormMain->Seek_Transp->Left=30+(150*(songposition*100/songlength))/100;
FormMain->SeekPos->Width=(150*(songposition*100/songlength))/100;
lm=(songposition/60);
ls=(songposition-songposition/60*60);
em=(songlength/60);
es=(songlength-songlength/60*60);
if(lm<10){slm="0"+AnsiString(lm);}else{slm=lm;}
if(ls<10){sls="0"+AnsiString(ls);}else{sls=ls;}
if(em<10){sem="0"+AnsiString(em);}else{sem=em;}
if(es<10){ses="0"+AnsiString(es);}else{ses=es;}
buff=slm+":"+sls+"/"+sem+":"+ses;
FormMain->Length->Caption=buff;
if (isseekmove==false)
{
FormMain->Seek->Left=FormMain->Seek_Transp->Left;
}
}