Forum
Grundkurs
»Introduktion
»Snabbguide
»Komponenter
»Händelser
»Strängar
»Räkna med Delphi »Egna
typer
»Selektion
»Iteration
»Menyer
»Funktioner
»Arraystrukturer
Tips & Tricks
»Nya tips
»Blandat
»Databaser
»Filer
»Forms
»Grafik
»Internet
»Komponenter
»Matematik
»Multimedia
»Objekt/ActiveX
»Skrivare
»Strängar
»System
»Mest lästa tips
Artiklar
»Delphi och ADO
»Bygga en DLL
»Skapa en enkel rapport
»Hantera registret
»Enheter, units
»Klassen TCanvas
»Använd LookUp Controls
Nya
tips
Lägg
till tips
Delphilänkar
Gästbok
|
|
|
|
Ljudrutiner i Windows
|
Kategori: Multimedia
Inlagt: 2004-06-19
Läst: 1403
Inlagt av: Staffan Berg
|
Beskrivning |
Diverse ljudrutiner. Läs och begrunda!
|
Kod |
program SoundProg; uses WinTypes, WinProcs, WObjects; const ButtonID= 100; type TMyApp = object(TApplication) procedure InitMainWindow; virtual; end; PMyWindow = ^TMyWindow; TMyWindow = object(TWindow) But: PButton; DurationCount: integer; constructor Init(AParent: PWindowsObject; ATitle: PChar); procedure MakeNoise(var Msg: TMessage); virtual id_First + ButtonID; procedure WMKillFocus(var Msg: TMessage); virtual wm_First + wm_KillFocus; end; procedure TMyApp.InitMainWindow; begin MainWindow:= new(PMyWindow,init(nil,'Sound Window')); end; constructor TMyWindow.Init(AParent: PWindowsObject; ATitle: PChar); begin DurationCount:= 0; TWindow.Init(AParent, ATitle); but:= New(PButton,init(@self,ButtonId,'&Make Noise',10,10,100,50,false)); end; procedure TMyWindow.MakeNoise(var Msg: TMessage); const Duration = 100; var err: integer; Pitch: integer; begin OpenSound; for Pitch:= 1 to 84 do begin SetVoiceNote(1, Pitch, 10, 1); end; StartSound; WaitSoundState(S_QueueEmpty); StopSound; CloseSound; end; procedure TMyWindow.WMKillFocus(var Msg: TMEssage); begin messageBeep(0); end; var x: TMyApp; begin x.Init('Test'); x.Run; x.Done; end.
|
|
|