www.pudn.com > winamp_control.zip > Unit1.cpp


//--------------------------------------------------------------------------- 
#include  
#include  
#include  
 
#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; 
    } 
  } 
} 
//--------------------------------------------------------------------------- 
//--------------------------------------------------------------------------- 
bool __stdcall EnumProc(HWND hWnd,/*LPARAM*/long/*lp*/) 
{ 
   unsigned long *pPid;   //LPDWORD 
   unsigned long result;      //DWORD 
   void *hg;                  //HGLOBAL 
   unsigned long id; 
 
   if(hWnd==NULL) 
      return false; 
 
   hg = GlobalAlloc(GMEM_SHARE,sizeof(unsigned long)); 
   pPid = (unsigned long *)GlobalLock(hg); 
 
   result = GetWindowThreadProcessId(hWnd,pPid); 
 
   if(result){ 
      char title[255]; 
      char className[255]; 
      char totalStr[255]; 
      GetClassName(hWnd,className,95); 
      GetWindowText(hWnd,title,110); 
      id=*pPid; 
      ultoa(id,totalStr,10); 
      strcat(totalStr,":"); 
      if(title){ 
         strcat(totalStr,title); 
         strcat(totalStr,":"); 
      } 
      strcat(totalStr,className); 
      if (StrPos(totalStr, "Winamp v1.x")) 
      { 
        FormMain->Memo1->Lines->Add(totalStr); 
        waid=hWnd; 
        FormMain->Timer2->Enabled=true; 
      } 
   } 
   else{ 
      GlobalUnlock(hg); 
      GlobalFree(hg); 
      return false; 
   } 
   GlobalUnlock(hg); 
   GlobalFree(hg); 
   return true; 
} 
//--------------------------------------------------------------------------- 
//--------------------------------------------------------------------------- 
void __fastcall GetActive() 
{ 
  long lp=0; 
 
  FormMain->Memo1->Clear(); 
  EnumWindows((WNDENUMPROC)EnumProc, lp); 
  if (FormMain->Memo1->Lines->Count!=0) 
  { 
    waok=true; 
    //id: number.artist - title - "Winamp[...]:Winamp v1.x" 
    //id: number.title - "Winamp[...]:Winamp v1.x" 
    FormMain->Edit1->Text=FormMain->Memo1->Lines->Strings[0]; 
    FormMain->Edit1->SelStart=0; 
    FormMain->Edit1->SelLength=FormMain->Edit1->GetTextLen()-StrLen(StrPos(FormMain->Edit1->Text.c_str(), "."))+2; 
    FormMain->Edit1->SelText=""; 
    if (StrPos(FormMain->Edit1->Text.c_str(), " - ")) 
    { 
      FormMain->Edit1->SelLength=FormMain->Edit1->GetTextLen()-StrLen(StrPos(FormMain->Edit1->Text.c_str(), " - ")); 
      songartist=FormMain->Edit1->SelText; 
      FormMain->Edit1->SelLength=FormMain->Edit1->GetTextLen()-StrLen(StrPos(FormMain->Edit1->Text.c_str(), " - "))+3; 
      FormMain->Edit1->SelText=""; 
      if (StrPos(FormMain->Edit1->Text.c_str(), " - ")) 
      { 
        FormMain->Edit1->SelLength=FormMain->Edit1->GetTextLen()-StrLen(StrPos(FormMain->Edit1->Text.c_str(), " - ")); 
        songtitle=FormMain->Edit1->SelText; 
      } else 
      { 
        songtitle=""; 
      } 
      FormMain->Artist->Caption=songartist; 
      FormMain->Title->Caption=songtitle; 
      Form2->Label1->Caption=songartist+" - "+songtitle; 
      curname=FormMain->Memo1->Lines->Strings[0]; 
    } 
  } else 
  { 
    waok=false; 
  } 
} 
//--------------------------------------------------------------------------- 
//--------------------------------------------------------------------------- 
void __fastcall IsWinampYes() 
{ 
  GetActive(); 
  if (waok==true) 
  { 
    FormMain->Led->Visible=true; 
    FormMain->AdvanceButDown->Enabled=true; 
  } else 
  { 
    FormMain->Led->Visible=false; 
    FormMain->AdvanceButDown->Enabled=false; 
  } 
  lastyesno=yesno; 
  yesno=SendMessage(waid, WM_USER, 0, 104); 
  if (yesno!=lastyesno) 
  { 
    FormMain->IsPlay->Visible=false; 
    FormMain->IsPause->Visible=false; 
    FormMain->IsStop->Visible=false; 
    if (yesno==1) 
    { 
      FormMain->IsPlay->Visible=true; 
    } else if (yesno==3) 
    { 
      FormMain->IsPause->Visible=true; 
    } else 
    { 
      FormMain->IsStop->Visible=true; 
    } 
  } 
} 
//--------------------------------------------------------------------------- 
//--------------------------------------------------------------------------- 
__fastcall TFormMain::TFormMain(TComponent* Owner):TForm(Owner){} 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::Timer1Timer(TObject *Sender) 
{ 
  FormMain->Left=FormMain->Left+curx; 
  FormMain->Top=FormMain->Top+cury; 
  curx=0; 
  cury=0; 
} 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::Timer3Timer(TObject *Sender) 
{ 
  IsWinampYes(); 
} 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::BackgroundMouseDown(TObject *Sender, 
      TMouseButton Button, TShiftState Shift, int X, int Y) 
{ 
  overx=X; 
  overy=Y; 
  curx=0; 
  cury=0; 
  Timer1->Enabled=True; 
} 
//--------------------------------------------------------------------------- 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::BackgroundMouseMove(TObject *Sender, 
      TShiftState Shift, int X, int Y) 
{ 
  curx=X-overx; 
  cury=Y-overy; 
  ButRefresh(); 
} 
//--------------------------------------------------------------------------- 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::BackgroundMouseUp(TObject *Sender, 
      TMouseButton Button, TShiftState Shift, int X, int Y) 
{ 
  Timer1->Enabled=False; 
} 
//--------------------------------------------------------------------------- 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::Image3MouseMove(TObject *Sender, 
      TShiftState Shift, int X, int Y) 
{ 
  curx=X-overx; 
  cury=Y-overy; 
} 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::Image3MouseDown(TObject *Sender, 
      TMouseButton Button, TShiftState Shift, int X, int Y) 
{ 
  overx=X; 
  overy=Y; 
  curx=0; 
  cury=0; 
  Timer1->Enabled=True;         
} 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::Image3MouseUp(TObject *Sender, 
      TMouseButton Button, TShiftState Shift, int X, int Y) 
{ 
  Timer1->Enabled=False;         
} 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::RCornerMouseMove(TObject *Sender, 
      TShiftState Shift, int X, int Y) 
{ 
  curx=X-overx; 
} 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::RCornerMouseDown(TObject *Sender, 
      TMouseButton Button, TShiftState Shift, int X, int Y) 
{ 
  overx=X; 
  curx=0; 
  Timer4->Enabled=True; 
} 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::RCornerMouseUp(TObject *Sender, 
      TMouseButton Button, TShiftState Shift, int X, int Y) 
{ 
  Timer4->Enabled=False; 
} 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::Timer4Timer(TObject *Sender) 
{ 
  FormMain->ClientWidth=FormMain->ClientWidth+curx; 
  curx=0; 
} 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::SeekMouseMove(TObject *Sender, 
      TShiftState Shift, int X, int Y) 
{ 
  seekx=X-seekoverx; 
  moveseek=true; 
} 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::Timer5Timer(TObject *Sender) 
{ 
  bool seekcanmove=true; 
  int playpos, i; 
 
  if (moveseek==true) 
  { 
    moveseek=false; 
    if (Seek->Left+seekx<30) 
    { 
      Seek->Left=30; 
      seekcanmove=false; 
    } 
    if (Seek->Left+seekx>180) 
    { 
      Seek->Left=180; 
      seekcanmove=false; 
    } 
    if (seekcanmove==true) 
    { 
      Seek->Left=Seek->Left+seekx; 
      seekx=0; 
    } 
  } 
} 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::SeekMouseDown(TObject *Sender, 
      TMouseButton Button, TShiftState Shift, int X, int Y) 
{ 
  moveseek=false; 
  seekoverx=X; 
  isseekmove=true; 
  Timer5->Enabled=true; 
} 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::SeekMouseUp(TObject *Sender, 
      TMouseButton Button, TShiftState Shift, int X, int Y) 
{ 
  Timer5->Enabled=false; 
  isseekmove=false; 
  SendMessage(waid, WM_USER, (((Seek->Left-30)*songlength*1000/150)), 106); 
} 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::Timer2Timer(TObject *Sender) 
{ 
  PlayTime(); 
} 
//--------------------------------------------------------------------------- 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::N1Click(TObject *Sender) 
{ 
  Application->Terminate(); 
} 
//--------------------------------------------------------------------------- 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::FormPaint(TObject *Sender) 
{ 
  ShowWindow(Application->Handle,SW_HIDE); 
} 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::Label1MouseLeave(TObject *Sender) 
{ 
  StringOn->Visible=false; 
} 
//--------------------------------------------------------------------------- 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::Label1MouseEnter(TObject *Sender) 
{ 
  StringOn->Visible=true;         
} 
//--------------------------------------------------------------------------- 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::Label1Click(TObject *Sender) 
{ 
  if (ischeck) 
  { 
    Timer6->Enabled=false; 
    ischeck=false; 
    Check->Picture=Check_off->Picture; 
  } else 
  { 
    Check->Picture=Check_on->Picture; 
    ischeck=true; 
    shutdowns=5; 
    Timer6->Enabled=true; 
  } 
} 
//--------------------------------------------------------------------------- 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::TimeHUpMouseMove(TObject *Sender, 
      TShiftState Shift, int X, int Y) 
{ 
  needrefresh=true; 
  TimeHUp->Picture=TimeUp_on->Picture; 
} 
//--------------------------------------------------------------------------- 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::TimeMUpMouseMove(TObject *Sender, 
      TShiftState Shift, int X, int Y) 
{ 
  needrefresh=true; 
  TimeMUp->Picture=TimeUp_on->Picture;         
} 
//--------------------------------------------------------------------------- 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::TimeHDownMouseMove(TObject *Sender, 
      TShiftState Shift, int X, int Y) 
{ 
  needrefresh=true; 
  TimeHDown->Picture=TimeDown_on->Picture; 
} 
//--------------------------------------------------------------------------- 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::TimeMDownMouseMove(TObject *Sender, 
      TShiftState Shift, int X, int Y) 
{ 
  needrefresh=true; 
  TimeMDown->Picture=TimeDown_on->Picture; 
} 
//--------------------------------------------------------------------------- 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::TimeHMouseEnter(TObject *Sender) 
{ 
  needrefresh=true; 
  ButRefresh(); 
} 
//--------------------------------------------------------------------------- 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::TimeHUpMouseDown(TObject *Sender, 
      TMouseButton Button, TShiftState Shift, int X, int Y) 
{ 
  TimeHUp->Picture=TimeUp_click->Picture; 
    FullTime(1, 0); 
} 
//--------------------------------------------------------------------------- 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::TimeMUpMouseDown(TObject *Sender, 
      TMouseButton Button, TShiftState Shift, int X, int Y) 
{ 
  TimeMUp->Picture=TimeUp_click->Picture; 
  FullTime(0, 1); 
} 
//--------------------------------------------------------------------------- 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::TimeMUpMouseUp(TObject *Sender, 
      TMouseButton Button, TShiftState Shift, int X, int Y) 
{ 
  TimeMUp->Picture=TimeUp_on->Picture; 
} 
//--------------------------------------------------------------------------- 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::TimeHUpMouseUp(TObject *Sender, 
      TMouseButton Button, TShiftState Shift, int X, int Y) 
{ 
  TimeHUp->Picture=TimeUp_on->Picture; 
} 
//--------------------------------------------------------------------------- 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::TimeMDownMouseDown(TObject *Sender, 
      TMouseButton Button, TShiftState Shift, int X, int Y) 
{ 
  TimeMDown->Picture=TimeDown_click->Picture; 
  FullTime(0, -1); 
} 
//--------------------------------------------------------------------------- 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::TimeMDownMouseUp(TObject *Sender, 
      TMouseButton Button, TShiftState Shift, int X, int Y) 
{ 
  TimeMDown->Picture=TimeDown_on->Picture; 
} 
//--------------------------------------------------------------------------- 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::TimeHDownMouseDown(TObject *Sender, 
      TMouseButton Button, TShiftState Shift, int X, int Y) 
{ 
  TimeHDown->Picture=TimeDown_click->Picture; 
  FullTime(-1, 0); 
} 
//--------------------------------------------------------------------------- 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::TimeHDownMouseUp(TObject *Sender, 
      TMouseButton Button, TShiftState Shift, int X, int Y) 
{ 
  TimeHDown->Picture=TimeDown_on->Picture; 
} 
//--------------------------------------------------------------------------- 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::Timer6Timer(TObject *Sender) 
{ 
  LeftTime(); 
} 
//--------------------------------------------------------------------------- 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::FormCreate(TObject *Sender) 
{ 
  FormMain->ClientWidth=Background->Width; 
  IsWinampYes(); 
} 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::L_PrevMouseDown(TObject *Sender, 
      TMouseButton Button, TShiftState Shift, int X, int Y) 
{ 
  btclick=true; 
  switch (((TLabel*)Sender)->Tag) 
  { 
    case 1: PrevBut->Picture=PrevBut_click->Picture; 
            break; 
    case 2: PlayBut->Picture=PlayBut_click->Picture; 
            break; 
    case 3: PauseBut->Picture=PauseBut_click->Picture; 
            break; 
    case 4: StopBut->Picture=StopBut_click->Picture; 
            break; 
    case 5: NextBut->Picture=NextBut_click->Picture; 
            break; 
    case 6: AdvanceButUp->Picture=AdvanceButUp_click->Picture; 
            break; 
    case 7: AdvanceButDown->Picture=AdvanceButDown_click->Picture; 
            break; 
    case 8: OptionsButUp->Picture=AdvanceButUp_click->Picture; 
            break; 
    case 9: OptionsButDown->Picture=AdvanceButDown_click->Picture; 
            break; 
  } 
} 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::L_PrevMouseEnter(TObject *Sender) 
{ 
  if (!btclick) 
  { 
    switch (((TLabel*)Sender)->Tag) 
    { 
      case 1: PrevBut->Picture=PrevBut_on->Picture; 
              break; 
      case 2: PlayBut->Picture=PlayBut_on->Picture; 
              break; 
      case 3: PauseBut->Picture=PauseBut_on->Picture; 
              break; 
      case 4: StopBut->Picture=StopBut_on->Picture; 
              break; 
      case 5: NextBut->Picture=NextBut_on->Picture; 
              break; 
      case 6: AdvanceButUp->Picture=AdvanceButUp_on->Picture; 
              break; 
      case 7: AdvanceButDown->Picture=AdvanceButDown_on->Picture; 
              break; 
      case 8: OptionsButUp->Picture=AdvanceButUp_on->Picture; 
              break; 
      case 9: OptionsButDown->Picture=AdvanceButDown_on->Picture; 
              break; 
    } 
  } 
} 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::L_PrevMouseLeave(TObject *Sender) 
{ 
  if (!btclick) 
  { 
    switch (((TLabel*)Sender)->Tag) 
    { 
      case 1: PrevBut->Picture=PrevBut_off->Picture; 
              break; 
      case 2: PlayBut->Picture=PlayBut_off->Picture; 
              break; 
      case 3: PauseBut->Picture=PauseBut_off->Picture; 
              break; 
      case 4: StopBut->Picture=StopBut_off->Picture; 
              break; 
      case 5: NextBut->Picture=NextBut_off->Picture; 
              break; 
      case 6: AdvanceButUp->Picture=AdvanceButUp_off->Picture; 
              break; 
      case 7: AdvanceButDown->Picture=AdvanceButDown_off->Picture; 
              break; 
      case 8: OptionsButUp->Picture=AdvanceButUp_off->Picture; 
              break; 
      case 9: OptionsButDown->Picture=AdvanceButDown_off->Picture; 
              break; 
    } 
  } 
} 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::L_PrevMouseUp(TObject *Sender, 
      TMouseButton Button, TShiftState Shift, int X, int Y) 
{ 
  btclick=false; 
  switch (((TLabel*)Sender)->Tag) 
  { 
    case 1: PrevBut->Picture=PrevBut_off->Picture; 
            SendMessage(waid, WM_COMMAND, 40044, 0); 
            break; 
    case 2: PlayBut->Picture=PlayBut_off->Picture; 
            SendMessage(waid, WM_COMMAND, 40045, 0); 
            IsWinampYes(); 
            break; 
    case 3: PauseBut->Picture=PauseBut_off->Picture; 
            SendMessage(waid, WM_COMMAND, 40046, 0); 
            IsWinampYes(); 
            break; 
    case 4: StopBut->Picture=StopBut_off->Picture; 
            SendMessage(waid, WM_COMMAND, 40047, 0); 
            IsWinampYes(); 
            break; 
    case 5: NextBut->Picture=NextBut_off->Picture; 
            SendMessage(waid, WM_COMMAND, 40048, 0); 
            break; 
    case 6: AdvanceButUp->Picture=AdvanceButUp_off->Picture; 
            AdvanceHideShow(); 
            break; 
    case 7: AdvanceButDown->Picture=AdvanceButDown_off->Picture; 
            AdvanceHideShow(); 
            break; 
    case 8: OptionsButUp->Picture=AdvanceButUp_off->Picture; 
            OptionsHideShow(); 
            break; 
    case 9: OptionsButDown->Picture=AdvanceButDown_off->Picture; 
            OptionsHideShow(); 
            break; 
    case 10:FormMain->Hide(); 
            break; 
    case 11:Application->Terminate(); 
            break;             
  } 
} 
//--------------------------------------------------------------------------- 
void __fastcall TFormMain::InTrayClick(TObject *Sender) 
{ 
  FormMain->Show(); 
} 
//---------------------------------------------------------------------------