⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainfr.~pas

📁 可以定时开关机
💻 ~PAS
📖 第 1 页 / 共 2 页
字号:
  if not ISDefaultSetCK.Checked  then
  begin
   SetTime.wYear := strToInt(InYear.Text);
   SetTime.wMonth := StrToInt(InMonth.Text);
   SetTime.wDay := StrToint(InDay.Text);
  end;
  SetTime.wHour := IntPre;
  SetTime.wMinute := IntNext;
  if not ValidSetTime(CurrentTime,SetTime) then
  begin
    ShowMessage('设置时间已过,请重新设置!');
    exit;
  end;
   Mainform.N2.Enabled := true;


end;

procedure TMainform.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  CoolTrayIcon1.IconVisible := false;
  CoolTrayIcon1.Destroy;
  try
  pvfreeMp3;
  except
  ;
  end;
end;

function TMainform.CompTime(CurrTime, SetCompTime: Tsystemtime):Boolean;
begin
//比较当前时间与设置时间,只比到分,相等返回TRUE
if (CurrTime.wYear = SetCOmpTIme.wYear) and
   (Currtime.wMonth = SetCOmpTime.wMonth) and
      (Currtime.wDay = setCompTime.wDay) and
         (Currtime.wHour = SetCompTime.wHour) and
           (Currtime.wMinute = SetCompTime.wMinute) then
            begin
             Result := true;
             exit;
             end
else Result := false;

end;
function TMainform.validSetTime(Currtime, SetCompTime: TsystemTime):boolean;
begin
if   SetCOmpTIme.wYear > CurrTime.wYear then
   begin
     Result := true;
     exit;
   end
 else if  SetCOmpTIme.wYear = CurrTime.wYear then
   begin
        if SetCOmpTime.wMonth > Currtime.wMonth then
           begin
             Result := true;
             exit;
           end
        else if  SetCOmpTime.wMonth = Currtime.wMonth then
           begin
                if  setCompTime.wDay > Currtime.wDay then
                   begin
                    Result := true;
                    exit;
                   end  else
                if  setCompTime.wDay = Currtime.wDay then
                      begin
                         if  SetCompTime.wHour > Currtime.wHour then
                            begin
                              Result := true;
                              exit;
                            end else
                         if  SetCompTime.wHour = Currtime.wHour then
                            begin
                               if SetCompTime.wMinute >= Currtime.wMinute  then
                                begin
                                Result := true;
                                exit;
                                end
                            end
                      end
           end
   end;
   Result := false;

end;
procedure TMainform.N2Click(Sender: TObject);
begin
 Timer1.Enabled := true;
 IsReStar   := false;
 IsPowerOff := true;
 IsLogOff   := false;
 IsCannel   := false;
 CurrentSetLabtext.Caption :=  '当前设置为关机!    ';
end;

procedure TMainform.N3Click(Sender: TObject);
begin
Timer1.Enabled := false;
IsReStar   := false;
      IsPowerOff := false;
      IsLogOff   := false;
      IsCannel   := true;
      IsModify   := false;
      CurrentSetLabtext.Caption := '当前未设置!   ';
      Timer2.Enabled := false;
      MessageForm.Hide;
end;

procedure TMainform.Timer2Timer(Sender: TObject);
begin
 if IsReStar  then
  MessageForm.OperationLabel.Caption := '重启  ';
 if IsPowerOff then
  MessageForm.OperationLabel.Caption := '关机  ';
 if isLogoff then
  MessageForm.OperationLabel.Caption := '注销  ';
  MessageForm.TimeLabel.Caption := inttoStr(MessageForm.countTemp);
 Messageform.countTemp := MessageForm.countTemp - 1;
 if  Messageform.countTemp < 0 then
 MessageForm.hide;
end;

procedure TMainform.MessageFormShow(CurrTime,
  SetCompTime: TsystemTime);
var
TempTIme:TsystemTime;
begin
if CurrTime.wSecond = 0 then
 begin
 if not MainForm.Timer2.Enabled then
  begin
 TempTime := CurrTime;
 TempTIme.wMinute := TempTime.wMinute+1;
 if TempTime.wMinute = 60 then
   begin
     TempTime.wMinute := 0 ;
     TempTime.wHour := TempTime.wHour + 1;
     if  TempTime.wHour = 24 then
       begin
         TempTime.wHour := 0;
         TempTIme.wDay := TempTime.wDay+1;
         TempTime.wDayOfWeek := TempTime.wDayOfWeek+1;
         if  TempTime.wDayOfWeek = 7 then
             TempTime.wDayOfWeek :=1;
         if (TEmpTime.wMonth = 4)or(TEmpTime.wMonth =6)or(TEmpTime.wMonth =9)
           or(TEmpTime.wMonth =11)or(TEmpTime.wMonth =2)then
           begin
            if (TEmpTime.wMonth =2)then
              begin
              if TempTime.wYear mod 4 = 0 then
                 if TempTime.wDay = 30 then
                  begin
                   TempTime.wMonth := TempTime.wMonth +1;
                   TempTime.wDay := 1;
                  end;
              if TempTime.wDay = 29 then
                 begin
                 TempTime.wDay := 1;
                 TempTime.wMonth := TempTime.wMonth +1;
                 end;
              end;
            if TempTime.wDay = 31 then
              begin
               TempTime.wDay := 1;
               TempTime.wMonth := TempTime.wMonth +1;
              end;
           end else
           begin
            if TempTime.wDay = 32 then
              begin
              TempTime.wDay := 1;
               TempTime.wMonth := TempTime.wMonth +1;
               if TempTime.wMonth = 12 then
               begin
                TempTime.wMonth := 1;
                TempTime.wYear := TempTime.wYear+1;
               end;
              end;
           end;
       end;
   end;

  end;
 

  if CompTime(TempTime,SetTime) then


 {
     PlaySound('c:\windows\media\chord.wav',0,SND_FILENAME+SND_ASYNC);

    begin
     MainForm.Timer2.Enabled := true;
     MainForm.CoolTrayIcon1.ShowMainForm;
     Messageform.Show;
     PlaySound('c:\windows\media\chord.wav',0,SND_FILENAME+SND_ASYNC);
    end;
   end;
 end; }
  end;
end;


procedure TMainform.ChooseRGClick(Sender: TObject);
begin
   if ChooseRG.ItemIndex = 3 then
   begin
      PlayList.Visible := true;
      StopBtn.Visible := true;
   end
   else begin
      PlayList.Visible := false;
      StopBtn.Visible  := false;
   end;

end;

procedure TMainform.PlayListClick(Sender: TObject);
begin
   PlayListFm.Show;
   PlayListFm.PlayListPanel.Show;
end;

procedure TMainform.OnTimePlaySong;
var
FileName: string;
Freq, Len,DotPos: integer;
begin
   CountSong := PlayListFm.PlayListBox.Items.Count;
   if CountSong = 0 then
   begin
   Timer1.Enabled := false;
   MessageBox(self.Handle,'没有歌曲在列表中!','错误!!',0);
   
   exit;
   end;
   if ISPlaySong = true then
      SongName.Visible := true
      else
      SongName.Visible := false;

 try
   pvInitMp3(hInstance, self.Handle, 1,1, 32);
   Timer1.Enabled := false;
   next := 0;
   SongTimer.Enabled := false;
   FileName := PlayListFm.PlayListBox.Items[next];
   pvGetMp3Info(pchar(FileName), @freq, @len);
	pvPlayMp3(pchar(FileName));
	starTime := Time;
	SongTimer.Interval := len*1000+1000;
   SongTimer.Enabled := true;
   DotPos := pos('.',PlayListFm.ShowListBox.Items[next]);
   SongName.Caption := '歌曲:'+copy(PlayListFm.ShowListBox.Items[next],0,DotPos-1)+'          ';
   PlayListFm.ShowListBox.ItemIndex := next;
 except
   pvFreeMp3;
 end;

end;

procedure TMainform.SongTimerTimer(Sender: TObject);
var
Filename:string;
freq,Len :integer;
DotPos :integer;
begin
	 next := next+1;
	 StopBtn.Caption := '停播';
    if next >= CountSong then
    begin
      Songtimer.Enabled := false;
      exit;
	 end;
	 if CountSong = 0 then
	 exit;
  try
   PvStopMp3;
	SongTimer.Enabled := false;
	FileName := PlayListFm.PlayListBox.Items[next];
	pvGetMp3Info(pchar(FileName), @freq, @len);
	starTime := Time;
	pvPlayMp3(pchar(FileName));

	SongTimer.Interval := len*1000+1000;
	SongTimer.Enabled := true;
   DotPos := pos('.',PlayListFm.ShowListBox.Items[next]);
   SongName.Caption := '歌曲:'+ copy(PlayListFm.ShowListBox.Items[next],0,DotPos-1)+'           ';
   PlayListFm.ShowListBox.ItemIndex := next;
   PlayListFm.ShowListBox.Selected[next] := true;
   except
   ;
	end;
	
end;

procedure TMainform.stopBtnClick(Sender: TObject);
var
//ddd:double;
stime:string;
s_min,s_sec:string;
i_min,i_sec:integer;
begin
if bStopBtn = true then
  begin
	 bStopBtn := false;
	 StopBtn.Caption := '播放';
	 Pasetime := Time;

	 SongTimer.Enabled := false;
	 // pvStopMp3; }
	 pvPauseMp3;
  end else
  begin
	 bStopBtn := true;
	 StopBtn.Caption := '停播';
	 s_min := '00';
	 s_sec := '00';
	 starTime := pasetime-starTime;
	 stime := TimetoStr(startime);

		  s_min[1] := stime[length(stime)-4];
		  s_min[2] := stime[length(stime)-3];
		  s_sec[1] := stime[length(stime)-1];
		  S_sec[2] := stime[length(stime)];

		  i_min := strtoint(s_min);
		  I_sec := Strtoint(s_sec);

	 if IsPlaySong = true then
	  begin
		 SongTimer.Interval := SongTimer.Interval - i_min*60*1000-i_sec*1000;
		 SongTimer.Enabled := true;
		// SongTimerTimer(Sender);  }
	  end; 
	  StarTime := time;
	  pvResumeMp3 ;
  end;

end;

procedure TMainform.CoolTrayIcon1DblClick(Sender: TObject);
begin
	 CooLtrayIcon1.ShowMainForm;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -