Others
Work with word document
This example shows, how to run MS Word, open *.doc file and insert some string to this file, save and close document. Don't forget add ComObj in uses chapter.
uses ComObj; ... var Word: Variant; ... procedure TForm1.Button1Click(Sender: TObject); begin Word:=CreateOLEObject('Word.Application'); Word.Visible:=True; Word.Documents.Open(GetCurrentDir+'\Test.doc'); Word.WordBasic.Insert('Greatis '); Word.Documents.Save; end; procedure TForm1.Button2Click(Sender: TObject); begin Word.Documents.Close; end;
Use animated cursors
Use LoadCursorFromFile procedure to set your cursor in a list of cursores. Use for this Cursors and Cursor properties of TScreen class.
procedure TForm1.FormCreate(Sender: TObject); const MyCursor=1; begin Screen.Cursors[MyCursor]:=LoadCursorFromFile('C:\Shuttle.ani'); Screen.Cursor:=MyCursor; end;
Unlimited playing in MediaPlayer
Use onNotify event, Notify and NotifyValue properties of MediaPlayer component.
procedure TForm1.MediaPlayer1Notify(Sender: TObject); begin with MediaPlayer1 do if NotifyValue = nvSuccessful then begin Notify := True; Play; end; end; procedure TForm1.Button1Click(Sender: TObject); begin with MediaPlayer1 do begin Filename:='test.wav'; Open; Play; end; end;
Set sound volume
To change sound volume, use WaveOutSetVolume function. A value of 0xFFFF represents full volume, and a value of 0x0000 is silence.
uses mmsystem; procedure TForm1.Button1Click(Sender: TObject); var MyWaveOutCaps: TWaveOutCaps; Volume: Integer; begin Volume:=Scrollbar1.Position; if WaveOutGetDevCaps( WAVE_MAPPER, @MyWaveOutCaps, sizeof(MyWaveOutCaps))=MMSYSERR_NOERROR then WaveOutSetVolume(WAVE_MAPPER, MakeLong(Volume, Volume)); end;