Tải bản đầy đủ - 0 (trang)
Hack 34. Play Videos in Access Forms

Hack 34. Play Videos in Access Forms

Tải bản đầy đủ - 0trang

configuration,thelistboxdisplaysalistofmoviesfromwhichto

select;clickingthebuttonplaystheselectedmovie.

InFigure4-26,thelistboxispopulatedwithpathsto.mpg

moviefiles.Thelistboxhastwocolumns.Thefirstcolumnisthe

boundcolumn,whichholdsthepathstothemoviefiles.Its

widthissettozero,soitisn'tdisplayedtotheuser.Instead,the

secondcolumn,whichcontainsfriendlynamesforthemovies,

isdisplayed.Whentheuserhasselectedamovie,shesimply

pressesthecommandbuttontostartthemovie.Thiseffectively

isasimpleplaylist.Figure4-27showstheforminViewmode

beforeplayingamovie.



Figure4-24.Lookingformorecontrols



Figure4-25.SelectingWindowsMediaPlayer



4.8.2.PlayingaMovie

So,justhowdoesamovieplay?Actually,it'squitesimple:the

pathtoamoviefileishandedtoWindowsMediaPlayer'sURL

propertyandthemoviestartsplayingautomatically.This

exampleshowsthebutton'scode;ittakesthepathfromthe

listboxandhandsittotheplayer:

PrivateSubcmdPlayMovie_Click()

IfNotIsNull(Me.listMovies)Then

Me.WMPlayer.URL=Me.listMovies



Figure4-26.FormdesignwithWindowsMedia

Player



Figure4-27.Selectingamovie















EndSub



Else

MsgBox"Firstselectamovie"

EndIf



Starting,stopping,fast-forwarding,rewinding,andpausingare

functionsbuiltintotheplayer.Thesefunctionsareavailable

throughthebuttonsontheplayeritself.Thisallowstheuserto

workthemovieinanyneededfashion.

WindowsMediaPlayerhasmanyeventsyoucanhookinto.A

littlethoughtandcreativitywillgoalongwaytoward

integratingmoviesintoyourapplications.Thishackshowsthe

basicwaytoimplementamovie,butyoucancodearoundand

workwiththeplayerinmyriadways.



4.8.3.SeeAlso

WindowsMediaSupportCenter

(http://support.microsoft.com/default.aspx?scid=fh;enus;wmp)



Hack35.ViewReportsEmbeddedinForms



Previewreports,whethercurrentorhistorical,directly

ontheformyouareworkingon.

Accessisoneofthemostpowerfulreportingtoolsonthe

market.BeginningwithAccess97,Microsoftintroducedthe

abilitytocreatesnapshotreportsthatyoucanviewwiththe

freeSnapshotViewer,availablefordownloadfromMicrosoft

(searchforActiveXSnapshotViewerathttp://www.

microsoft.com/downloads).

AccessdatabaseapplicationdeveloperscanusetheActiveX

SnapshotViewertocustomizethelookandfeeloftheir

applicationsbydisplayingreportsembeddedinforms.



4.9.1.CreatingtheForm

TheformiscomposedofacomboboxandtheActiveX

SnapshotViewer.Thecomboboxcontainsalistofallthe

reportsinthedatabase.Whentheformopens,theLoadevent

executesthefollowingcodetofillthecomboboxwithalisting

ofallavailablereports:





































PrivateSubForm_Load()

DimobjAsAccessObject,dbsAsObject



DimstrListAsString



Setdbs=Application.CurrentProject



ForEachobjIndbs.AllReports



strList=strList&obj.Name&";"



Nextobj



cboReports.RowSourceType="ValueList"

















cboReports.RowSource=strList

EndSub



ToaddtheActiveXSnapshotViewer,selectMoreControlsfrom

thetoolbox,asshowninFigure4-28,scrolldown,andselect

SnapshotViewerControl11.0.Notethatdependingonyour

versionofAccess,yourcontrolmightbeearlierthanthe11.0

version.



Figure4-28.AddingtheActiveXSnapshotViewer



SizetheSnapshotViewerControltoanapproximatewidththat

matchesthesizeofthepaperonwhichyouwillprintthereport.

Thishelpsavoidhavingtoscrollleftandrighttoseeareport

onceitisdisplayed.Figure4-29showstheformdesignwiththe

SnapshotViewerControlinplace.



Figure4-29.Sizingthesnapshotviewer



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Hack 34. Play Videos in Access Forms

Tải bản đầy đủ ngay(0 tr)

×