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: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145:
| var Form1: TForm1; AviDatei: String; ButtonZahl: Integer; Programmzeile, Buttontext: Array[1..10] of String; Programm_Button: Array of TButton;
implementation
{$R *.dfm}
procedure RunProcessAndWait (aFilename: String); var StartupInfo : TStartupInfo; ProcessInfo : TProcessInformation; Result: Boolean; begin FillChar (StartupInfo, SizeOf (TStartupInfo), 0); StartupInfo.cb := Sizeof (TStartupInfo); StartupInfo.dwFlags := STARTF_USESHOWWINDOW OR STARTF_USEPOSITION OR STARTF_USESIZE ; StartupInfo.wShowWindow := SW_SHOWDEFAULT; Result := CreateProcess ( nil, pChar (aFilename), nil, nil, False, NORMAL_PRIORITY_CLASS, nil, nil, StartupInfo, ProcessInfo ); If Result then WaitForSingleObject (ProcessInfo.hProcess, INFINITE); if ProcessInfo.hProcess <> 0 then begin CloseHandle (ProcessInfo.hProcess); Application.Restore; Form1.MediaPlayer1.Resume; end; end;
procedure MachButton; var Abstand, i: Integer; begin SetLength(Programm_Button,ButtonZahl); Abstand:=(Form1.Height-(ButtonZahl*50)) div (ButtonZahl+1); if Abstand<2 then Abstand:=2; for i:=1 to ButtonZahl do begin Programm_Button[i]:=TButton.Create(Form1); with Programm_Button[i] do begin Parent:=Form1; Left:=(Form1.Width div 2)-75; Top:=(((i-1)*50)+(i*Abstand))-10; Width:=150 div 2; Height:=50 div 2; Name:='Programm'+IntToStr(i); Caption:=Buttontext[i]; Programm_Button[i].BringToFront; end; end;end;
procedure TForm1.FormCreate(Sender: TObject); var ini: TIniFile; n: Integer; begin WindowState:=wsMaximized; ini:= TIniFile.Create(ExtractFilePath(ParamStr(0))+'AVI-Parameter.ini'); ButtonZahl:=StrToInt(ini.ReadString('Anzahl','Menge','10')); for n:=1 to ButtonZahl do begin Programmzeile[n]:=ini.ReadString('Programmoptionen','Programm '+IntToStr(n), 'C:\Programme\AVI\P'+IntToStr(n)+'.exe'); Buttontext[n]:=ini.ReadString('Programmoptionen','Text '+IntToStr(n), 'P'+IntToStr(n)+'.exe'); end; AviDatei:=ini.ReadString('AVI-Angabe','AVI-Datei','C:\Programme\AVI\File.avi'); ini.Free; Sam(nil); end;
procedure TForm1.Sam(Sender: TObject); begin With MediaPlayer1 do begin Filename :=AviDatei; Display := Panel1; Open; Application.ProcessMessages; DisplayRect := Panel1.ClientRect; if MediaPlayer1.Mode<>mpPlaying then begin Play; end; end; end;
procedure TForm1.MediaPlayer1Notify(Sender: TObject); begin Sam(nil); end;
procedure TForm1.Button1Click(Sender: TObject); begin Application.Minimize; MediaPlayer1.Pause; RunProcessAndWait('c:\windows\calc.exe'); end;
procedure TForm1.FormResize(Sender: TObject); begin Panel1.Width:=Width; Panel1.Height:=Height; MediaPlayer1.DisplayRect := Panel1.ClientRect; Button1.BringToFront; Button2.BringToFront; end;
procedure TForm1.Timer1Timer(Sender: TObject); begin Timer1.Enabled:=False; MachButton; end;
procedure TForm1.Button2Click(Sender: TObject); begin MediaPlayer1.Stop; MediaPlayer1.Close; Close; end;
end. |