




已閱讀5頁(yè),還剩73頁(yè)未讀, 繼續(xù)免費(fèi)閱讀
版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
上學(xué)吧:VB程序設(shè)計(jì)基礎(chǔ):窗體屬性程序設(shè)計(jì)是指為計(jì)算機(jī)編制一些軟件和程序。學(xué)習(xí)的目的是理解計(jì)算機(jī)的工作方式和運(yùn)行的方式。VB是運(yùn)行在Windows視窗操作系統(tǒng)上,設(shè)計(jì)程序的思想在于在窗口中放置對(duì)象和針對(duì)對(duì)象設(shè)計(jì)代碼。(一)啟動(dòng)VB:?jiǎn)螕簟伴_(kāi)始”“程序”“Microsoft Visual Basic 6.0 中文版”選擇“標(biāo)準(zhǔn)EXE”,單擊“打開(kāi)”進(jìn)入窗口。(二)VB窗口1、標(biāo)題欄:在最上面藍(lán)色標(biāo)題是“工程1.”,是我們當(dāng)前正在設(shè)計(jì)的程序,被稱(chēng)作“工程1”。2、菜單欄:菜單欄在第二行,包含一組菜單,菜單中有各種命令,我們應(yīng)該理解操作計(jì)算機(jī)就是向計(jì)算機(jī)提供一系列的指令。(1)“文件”菜單,要求記住“保存”命令,VB要保存兩次,注意保存文件到自己的文件夾中。(本書(shū)中雙引號(hào)當(dāng)中均是指操作命令)(2)“視圖”菜單,顯示各個(gè)窗口,如果一個(gè)窗口找不著了,就到這個(gè)菜單中找出來(lái)。(3)“運(yùn)行”菜單,第一個(gè)“啟動(dòng)”命令要記住,可以運(yùn)行我們的程序。3、工具欄:第三行是工具欄,工具欄是一些最常用的命令,而且是用圖標(biāo)表示的,因而便于形象記憶和操作,要求記住“啟動(dòng)”按鈕。(在視窗操作系統(tǒng)中,我們不僅要會(huì)認(rèn)識(shí)文字說(shuō)明,還要特別留意圖標(biāo)含義。)4、工作區(qū):工作區(qū)占據(jù)窗口的絕大部分,從左向右包括工具箱、窗體、和屬性窗口。(1) 工具箱:在工作區(qū)的左側(cè),包含許多編程用到的基本對(duì)象,被稱(chēng)作“控件”。(2) 窗體:中間的灰色的窗口,是我們?cè)O(shè)計(jì)的程序的基本框架,所有的對(duì)象都放在這個(gè)窗口當(dāng)中。(3)小窗口:在右側(cè)有三個(gè)縱向排列的窗口。最上面是工程窗口,上邊有三個(gè)按鈕,中間的按鈕是顯示對(duì)象窗口;下面是屬性窗口,屬性是一個(gè)對(duì)象的名稱(chēng)、大小、顏色等等;最下面是布局窗口,里面顯示程序運(yùn)行時(shí)的位置,拖動(dòng)里面的小框可以改變程序的顯示位置。4、下面修改窗體的屬性,在右側(cè)的屬性窗口中找到Caption項(xiàng),在它右邊的格子里點(diǎn)一下鼠標(biāo)左鍵,然后輸入“窗體”兩個(gè)字,觀察一下工作區(qū)中的窗體的標(biāo)題是否已經(jīng)改變,Caption是設(shè)置一個(gè)應(yīng)用程序的窗口標(biāo)題,再在屬性窗口中找到BackColor項(xiàng),單擊右邊格子里的黑色三角按鈕上點(diǎn)擊一下鼠標(biāo)左鍵,在彈出的面板上邊的一行文字中選擇“調(diào)色板”標(biāo)簽,選中淺紫色,觀察一下工作區(qū)中間的窗體的變化。單擊工具欄上的啟動(dòng)按鈕,運(yùn)行一下我們的程序,看一下這個(gè)窗口,還不錯(cuò)吧?單擊“關(guān)閉”按鈕(或者AltF4),回到窗體中,在屬性窗口中找到Icon項(xiàng),在右邊的格子里點(diǎn)一下鼠標(biāo)左鍵再點(diǎn)一下三個(gè)小點(diǎn),在彈出的“加載圖標(biāo)”對(duì)話框中,點(diǎn)擊“向上”按鈕退一步,再選擇打開(kāi)Common,再選擇打開(kāi)Graphics,再選擇打開(kāi)Icon,再打開(kāi)Misc,在里面找一個(gè)圖標(biāo),單擊打開(kāi),再看一下工作區(qū)中的窗體的標(biāo)題欄左側(cè)是否有一個(gè)圖標(biāo)。單擊“啟動(dòng)”按鈕,運(yùn)行一下程序,然后最小化,看一下任務(wù)欄上的圖標(biāo)找到我們的程序,單擊一下圖標(biāo)恢復(fù)窗口。關(guān)閉程序回到屬性窗口,找到Picture屬性,在右邊的格子里單擊一下鼠標(biāo)左鍵,打開(kāi)“加載圖片”對(duì)話框,找一幅較大的背景圖片打開(kāi),觀察一下工作區(qū)窗體的變化。單擊“啟動(dòng)”按鈕運(yùn)行一下程序,很漂亮的一個(gè)窗口是吧?關(guān)閉程序,同樣再修改Font屬性和ForeColor屬性,屬性都是按照字母排序的,在最后的WindowState屬性中選擇2Maxing最大化,運(yùn)行一下程序看一下效果。如何保存自己的程序呢?方法是在“文件”菜單中選擇“保存工程”或者點(diǎn)擊工具欄上的磁盤(pán)按鈕,保存文件到自己的文件夾(如果沒(méi)有就新建一個(gè))以“MyForm”為文件名(如果能用中文就輸入漢字“窗體”)。保存兩次,一次是窗體,另一次是工程。保存好的程序要編譯成可以在Windows下運(yùn)行的可執(zhí)行程序,方法是選擇“文件”菜單中的“生成工程1.exe”命令,以“窗體”為文件名保存文件到自己的文件夾,這個(gè)程序關(guān)閉VB后也可以運(yùn)行,退出VB,打開(kāi)自己的文件夾,找到程序,運(yùn)行一下看看。本節(jié)主要講述了VB的基本窗口和窗體屬性,以后會(huì)經(jīng)常用到。API在VB中應(yīng)用之技巧集錦API在VB中應(yīng)用之技巧集錦API函數(shù)在VB中得到了充分的運(yùn)用,同時(shí)也讓無(wú)數(shù)VB愛(ài)好者沉溺于其中。以下是筆者幾年來(lái)收集整理的幾十個(gè)API函數(shù)在VB中應(yīng)用的實(shí)例,現(xiàn)在寫(xiě)出來(lái)與大伙分享,希望能對(duì)大伙有所幫助。1、如何讓窗體總在最前面?*API函數(shù)聲明Declare Function SetWindowPos Lib user32 ( ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long注釋?zhuān)撼A柯暶鱌rivate Const SWP_NOSIZE = &H1Private Const SWP_NOMOVE = &H2Private Const HWND_TOPMOST = -1Private Const HWND_NOTOPMOST = -2注釋?zhuān)?在某個(gè)form里寫(xiě):SetWindowPos me.hWnd,WND_TOPMOST,0,0,0,0, SWP_NOMOVE 注釋?zhuān)夯蛳旅鍿etWindowPos me.hWnd,WND_TOPMOST,0,0,0,0, SWP_NOSIZE2、使用API函數(shù)sendmessage,獲得光標(biāo)所在行和列。Sub getcaretpos(byval TextHwnd&,LineNo&,ColNo&)注釋?zhuān)篢extHwnd為T(mén)extBox的hWnd屬性值,LineNo為所在行數(shù),ColNo為列數(shù)dim i&,j&,k& 注釋?zhuān)韩@取起始位置到光標(biāo)所在位置字節(jié)數(shù)i=SendMessage(TextHwnd,&HB0&,0,0) j=i/216 注釋?zhuān)捍_定所在行LineNo=SendMessage(TextHwnd,&HC9&,j,0)+1注釋?zhuān)捍_定所在列k=SendMessage(TextHwnd,&HBB&,-1,0)ColNo=j-k+1End sub3、如何以某種顏色填充某區(qū)域?*API函數(shù)聲明Private Declare Sub FloodFill Lib gdi32 _ (ByVal hDC As Long, ByVal X As Long, ByVal Y As _ Long, ByVal crColor As Long注釋?zhuān)涸O(shè)(fillx,filly)為此區(qū)域內(nèi)任一點(diǎn)注釋?zhuān)篊olor為某種顏色FloodFill Picture1.hDC, fillx, filly,Color4、如何關(guān)閉計(jì)算機(jī)?*API函數(shù)聲明Declare Function ExitWindows Lib User (ByVal dwReturnCode As Long, ByVal wReserved As Integer) As Integer注釋?zhuān)簣?zhí)行Dim DUMMYDUMMY=ExitWindows(0,0)5、如何獲取Windows目錄和System目錄?注釋?zhuān)簭?fù)制以下代碼到一模塊中Public Declare Function GetWindowsDirectory Lib kernel32 Alias GetWindowsDirectoryA (ByVal lpBuffer As String, ByVal nSize As Long) As LongPublic Declare Function GetSystemDirectory Lib kernel32 Alias GetSystemDirectoryA (ByVal lpBuffer As String, ByVal nSize As Long) As Long注釋?zhuān)涸诔绦蛑姓{(diào)用Dim WindowsDirectory As String, SystemDirectory As String, x As LongWindowsDirectory = Space(255)SystemDirectory = Space(255)x = GetWindowsDirectory(WindowsDirectory, 255)x = GetSystemDirectory(SystemDirectory, 255)MsgBox Windows的安裝目錄是: + WindowsDirectory+,系統(tǒng)目錄是: + SystemDirectory6、如何建立簡(jiǎn)單的超級(jí)連接?*API函數(shù)聲明Private Declare Function ShellExecute Lib shell32.dll Alias ShellExecute A (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd A s Long) As Long注釋?zhuān)捍蜷_(kāi)某個(gè)網(wǎng)址ShellExecute 0, open, , vbNullString, vbNullString, 3注釋?zhuān)航o某個(gè)信箱發(fā)電子郵件ShellExecute hwnd, open, mailto:, vbNullString, vbNullString, 07、如何得知TextBox中文字所有的行數(shù)?*API函數(shù)聲明Declare Function SendMessage Lib user32 Alias SendMessageA (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongPublic Const EM_GETLINECOUNT = &HBA注釋?zhuān)涸诔绦蛑姓{(diào)用LineCnt = SendMessage(ctl.hwnd, EM_GETLINECOUNT, 0, 0)注釋?zhuān)篖ineCnt即為此TextBox的行數(shù)。8、如何設(shè)置ListBox的水平卷動(dòng)軸的寬度?*API函數(shù)聲明Const LB_SETHORIZONTALEXTENT = &H194Private Declare Function SendMessage Lib user32 Alias SendMessageA _ (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _ lParam As Any) As Long注釋?zhuān)赫{(diào)用Call SendMessage(List1.hwnd, LB_SETHORIZONTALEXTENT, 400, ByVal 0&)注釋?zhuān)鹤⒁?00是以象素為單位,你可以根據(jù)情況自行設(shè)定。9、如何交換鼠標(biāo)按鍵?*API函數(shù)聲明Declare Function SwapMouseButton& Lib user32 _ (ByVal bSwap as long)要交換鼠標(biāo)按鍵,將bSwap參數(shù)設(shè)置為T(mén)rue。要恢復(fù)正常設(shè)置,將bSwap設(shè)置為False。 然后調(diào)用函數(shù)就可以交換和恢復(fù)鼠標(biāo)按鍵了。10、如何讓窗體的標(biāo)題條閃爍以引起用戶(hù)注意?在窗體中放一個(gè)Timer控件Timer1,設(shè)置其Inteval=200*API函數(shù)聲明Private Declare Function FlashWindow Lib user32 (ByVal hwnd As Long, ByVal bInvert As Long) As Long注釋?zhuān)涸诖绑w中寫(xiě)下如下代碼:Private Sub Timer1_Timer()FlashWindow Me.hwnd, TrueEnd Sub11、怎樣找到鼠標(biāo)指針的XY坐標(biāo)?*API函數(shù)聲明Type POINTAPIx As Longy As LongEnd TypeDeclare Function GetCursorPos Lib user32 (lpPoint As POINTAPI) As Long調(diào)用:GetCursorPos zprint z.xprint z.y12、怎樣獲得和改變雙擊鼠標(biāo)的時(shí)間間隔?獲得鼠標(biāo)雙擊間隔時(shí)間:Public Declare Function GetDoubleClickTime Lib user32 Alias _ GetDoubleClickTime () As Long獲得鼠標(biāo)雙擊間隔時(shí)間:Declare Function SetDoubleClickTime Lib user32 Alias SetDoubleClickTime (ByVal wCount As Long) As Long注釋?zhuān)鹤⒁猓哼@種改變將影響到整個(gè)操作系統(tǒng)以上兩個(gè)函數(shù)都可精確到毫秒級(jí)。13、在程序中如何打開(kāi)和關(guān)閉光驅(qū)門(mén)?*API函數(shù)聲明如下:Private Declare Function mciSendString Lib winmm.dll Alias mciSendStringA (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long注釋?zhuān)赫{(diào)用時(shí)的代碼如下Dim Ret As LongDim RetStr As String注釋?zhuān)捍蜷_(kāi)光驅(qū)門(mén)Ret = mciSendString(set CDAudio door open, RetStr, 0, 0)注釋?zhuān)宏P(guān)閉光驅(qū)門(mén)Ret = mciSendString(set CDAudio door closed, RetStr, 0, 0)14、如何獲得Windows啟動(dòng)方式?在Form1中加入一個(gè)CommandButton、一個(gè)Label并加入如下代碼:Private Declare Function GetSystemMetrics Lib user32 (ByVal nIndex As Long) As LongConst SM_CLEANBOOT = 67Private Sub Command1_Click()Select Case GetSystemMetrics(SM_CLEANBOOT)Case 1Label1 = 安全模式.Case 2Label1 = 支持網(wǎng)絡(luò)的安全模式.Case ElseLabel1 = Windows運(yùn)行在普通模式.End SelectEnd Sub15、怎樣使Ctrl-Alt-Delete無(wú)效?*API函數(shù)聲明Private Declare Function SystemParametersInfo Lib user32 Alias SystemParametersInfoA (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long編寫(xiě)如下函數(shù):Sub DisableCtrlAltDelete(bDisabled As Boolean)Dim X As LongX = SystemParametersInfo(97, bDisabled, CStr(1), 0)End Sub使Ctrl-Alt-Delete無(wú)效 :Call DisableCtrlAltDelete(True)恢復(fù)Ctrl-Alt-Delete :Call DisableCtrlAltDelete(False)16、如何移動(dòng)沒(méi)有標(biāo)題欄的窗口?我們一般是用鼠標(biāo)按住窗口的標(biāo)題欄,然后移動(dòng)窗口,當(dāng)窗口沒(méi)有標(biāo)題欄時(shí),我們可以用下面的方法來(lái)移動(dòng)窗口:*API函數(shù)聲明:Declare Function ReleaseCapture Lib user32 () As Long Declare Function SendMessage Lib user32 Alias SendMessageA (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongPublic Const HTCAPTION = 2Public Const WM_NCLBUTTONDOWN = &HA1在 Form_MouseDown 事件中:Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)ReleaseCapture SendMessage hwnd, WM_NCLBUTTONDOWN, HTCAPTION,0&End Sub17、VB中如何使用延時(shí)函數(shù)?*API函數(shù)聲明:Declare Sub Sleep Lib kernel32 (ByVal dwMilliseconds As Long)調(diào)用:注釋?zhuān)貉訒r(shí)1秒Call Sleep(1000)18、調(diào)用修改屏幕保護(hù)口令的窗口:Private Declare Function PwdChangePassword Lib mpr Alias PwdChangePasswordA (ByVal lpcRegkeyname As String, ByVal hwnd As Long, ByVal uiReserved1 As Long, ByVal uiReserved2 As Long) As Long調(diào)用:Call PwdChangePassword(SCRSAVE, Me.hwnd, 0, 0)19、使Windows開(kāi)始屏幕保護(hù):*API函數(shù)聲明Private Declare Function SendMessage Lib user32Alias SendMessageA (ByVal hWnd As Long, ByVal wMsgAs Long, ByVal wParam As Long, ByVal lParam As Long)As LongConst WM_SYSCOMMAND = &H112&Const SC_SCREENSAVE = &HF140&注釋?zhuān)赫{(diào)用Dim result As Longresult = SendMessage(Form1.hWnd, WM_SYSCOMMAND, SC_SCREENSAVE, 0&)20、如何改變Windows桌面背景?*API函數(shù)聲明Const SPI_SETDESKWALLPAPER = 20Const SPIF_UPDATEINIFILE = &H1Declare Function SystemParametersInfo Lib user32 Alias SystemParametersInfoA (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long注釋?zhuān)赫{(diào)用Call SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, C:windowsClouds.bmp, SPIF_UPDATEINIFILE)21、怎樣確定系統(tǒng)是否安裝了聲卡?*API函數(shù)聲明:Declare Function waveOutGetNumDevs Lib winmm.dll Alias waveOutGetNumDevs () As Long代碼如下:Dim i As Integeri = waveOutGetNumDevs()If i 0 Then MsgBox 你的系統(tǒng)可以播放聲音。, vbInformation, 聲卡檢測(cè)ElseMsgBox 你的系統(tǒng)不能播放聲音。, vbInformation, 聲卡檢測(cè)End If22、如何找到CD-ROM驅(qū)動(dòng)器的盤(pán)號(hào)?下面的函數(shù)將檢查你計(jì)算機(jī)所有的驅(qū)動(dòng)器看是否是 CD-ROM,如果是就返回驅(qū)動(dòng)器號(hào),如果沒(méi)有就返回空字符Public Function GetCDROMDrive() As StringDim lType As Long,i As Integer,tmpDrive as String,found as BooleanOn Error GoTo errLFor i = 0 To 25tmpDrive = Chr(65 + i) & :lType = GetDriveType(tmpDrive) 注釋?zhuān)篧in32 API 函數(shù)If (lType = DRIVE_CDROM) Then 注釋?zhuān)篧in32 API 常數(shù)found = TrueExit ForEnd IfNextIf Not found Then tmpDrive = BI_GetCDROMDrive = tmpDriveexit FunctionerrL: msgbox error$End Function23、如何將文件放入回收站?*API函數(shù)聲明Public Type SHFILEOPSTRUCThwnd As LongwFunc As LongpFrom As StringpTo As StringfFlags As IntegerfAnyOperationsAborted As LonghNameMappings As LonglpszProgressTitle As LongEnd TypePublic Declare Function SHFileOperation Lib _ shell32.dll Alias SHFileOperationA (lpFileOp As SHFILEOPSTRUCT) As LongPublic Const FO_DELETE = &H3Public Const FOF_ALLOWUNDO = &H40注釋?zhuān)赫{(diào)用Dim SHop As SHFILEOPSTRUCT, strFile as stringWith SHop.wFunc = FO_DELETE.pFrom = strFile + Chr(0).fFlags = FOF_ALLOWUNDOEnd With24、VB中如何使用未安裝的字體?Declare Function AddFontResource Lib gdi32 Alias AddFontResourceA (ByVal lpFileName As String) As LongDeclare Function RemoveFontResource Lib gdi32 Alias RemoveFontResourceA (ByVal lpFileName As String) As Long增加字體:Dim lResult As LonglResult = AddFontResource(c:myAppmyFont.ttf)刪除字體:Dim lResult As LonglResult = RemoveFontResource(c:myAppmyFont.ttf)MCI播放器在VB中實(shí)現(xiàn)用MCI命令來(lái)實(shí)現(xiàn)多媒體的播放功能下面的內(nèi)容幾乎有播放器軟件的各種功能,你只是引用這些函數(shù)就能做出一個(gè)播放器來(lái)Public Declare Function mciSendString Lib winmm.dll Alias mciSendStringA (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As LongPublic Declare Function mciGetDeviceID Lib winmm.dll Alias mciGetDeviceIDA (ByVal lpstrName As String) As LongPublic Declare Function waveOutGetVolume Lib winmm.dll (ByVal uDeviceID As Long, lpdwVolume As Long) As LongPublic Declare Function GetWindowLong Lib user32 Alias GetWindowLongA (ByVal hwnd As Long, ByVal nIndex As Long) As LongPublic Declare Function CallWindowProc Lib user32 Alias CallWindowProcA (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As LongPublic Declare Function SetWindowLong Lib user32 Alias SetWindowLongA (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As LongPublic Declare Function GetShortPathName Lib kernel32 Alias GetShortPathNameA (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As LongEnum PlayTypeNameFile = 1CDAudio = 2VCD = 3RealPlay = 4End EnumDim PlayType As PlayTypeNameEnum AudioSourceAudioStereo = 0 stereoAudioLeft = 1 leftAudioRight = 2 rightEnd EnumDim hWndMusic As LongDim prevWndproc As Long=打開(kāi)MCI設(shè)備,urlStr為網(wǎng)址,傳值代表成功與否=Public Function OpenURL(urlStr As String, Optional hwnd As Long) As BooleanOpenMusic = FalseDim MciCommand As StringDim DriverID As StringCloseMusicMCI命令DriverID = GetDriverID(urlStr)If DriverID = RealPlayer ThenPlayType = RealPlayExit FunctionEnd IfMciCommand = open & urlStr & type & DriverID & alias NOWMUSICIf DriverID = AVIVideo Or DriverID = MPEGVideo Or DriverID = MPEGVideo2 ThenIf hwnd 0 ThenMciCommand = MciCommand + parent & hwnd & style childhWndMusic = GetWindowHandleprevWndproc = GetWindowLong(hWndMusic, -4)SetWindowLong hWndMusic, -4, AddressOf WndProcElseMciCommand = MciCommand + style overlapped End IfEnd IfRefInt = mciSendString(MciCommand, vbNull, 0, 0)mciSendString set NOWMUSIC time format milliseconds, vbNullString, 0, 0If RefInt = 0 Then OpenMusic = TrueEnd Function=打開(kāi)MCI設(shè)備,F(xiàn)ILENAME為文件名,傳值代表成功與否=Public Function OpenMusic(FileName As String, Optional hwnd As Long) As BooleanOpenMusic = FalseDim ShortPathName As String * 255Dim RefShortName As StringDim RefInt As LongDim MciCommand As StringDim DriverID As StringCloseMusic獲取短文件名GetShortPathName FileName, ShortPathName, 255RefShortName = Left(ShortPathName, InStr(1, ShortPathName, Chr(0) - 1)MCI命令DriverID = GetDriverID(RefShortName)If DriverID = RealPlayer ThenPlayType = RealPlayExit FunctionEnd IfMciCommand = open & RefShortName & type & DriverID & alias NOWMUSICIf DriverID = AVIVideo Or DriverID = MPEGVideo Or DriverID = MPEGVideo2 ThenIf hwnd 0 ThenMciCommand = MciCommand + parent & hwnd & style childhWndMusic = GetWindowHandleprevWndproc = GetWindowLong(hWndMusic, -4)SetWindowLong hWndMusic, -4, AddressOf WndProcElseMciCommand = MciCommand + style overlapped End IfEnd IfRefInt = mciSendString(MciCommand, vbNull, 0, 0)mciSendString set NOWMUSIC time format milliseconds, vbNullString, 0, 0If RefInt = 0 Then OpenMusic = TrueEnd FunctionFunction WndProc(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As LongIf Msg = &H202 ThenMsgBox OKEnd IfWndProc = CallWindowProc(prevWndproc, hwnd, Msg, wParam, lParam)End Function=根據(jù)文件名,確定設(shè)備=Public Function GetDriverID(ff As String) As StringSelect Case UCase(Right(ff, 3)Case MID, RMI, IDIGetDriverID = SequencerCase WAVGetDriverID = WaveaudioCase ASF, ASX, IVF, LSF, LSX, P2V, WAX, WVX, .WM, WMA, WMX, WMPGetDriverID = MPEGVideo2Case .RM, RAM, .RAGetDriverID = RealPlayerCase ElseGetDriverID = MPEGVideoEnd SelectEnd Function=播放文件=Public Function PlayMusic() As BooleanDim RefInt As LongPlayMusic = FalseRefInt = mciSendString(play NOWMUSIC, vbNull, 0, 0)If RefInt = 0 Then PlayMusic = TrueEnd Function=獲取媒體的長(zhǎng)度=Public Function GetMusicLength() As LongDim RefStr As String * 80mciSendString status NOWMUSIC length, RefStr, 80, 0GetMusicLength = Val(RefStr)End Function=獲取當(dāng)前播放進(jìn)度=Public Function GetMusicPos() As LongDim RefStr As String * 80mciSendString status NOWMUSIC position, RefStr, 80, 0GetMusicPos = Val(RefStr)End Function=獲取媒體的當(dāng)前進(jìn)度=Public Function SetMusicPos(Position As Long) As BooleanDim RefInt As LongSetMusicPos = FalseRefInt = mciSendString(seek NOWMUSIC to & Position, vbNull, 0, 0)If RefInt = 0 Then SetMusicPos = TrueEnd Function=暫停播放=Public Function PauseMusic() As BooleanDim RefInt As LongPauseMusic = FalseRefInt = mciSendString(pause NOWMUSIC, vbNull, 0, 0)If RefInt = 0 Then PauseMusic
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 粗加工考試題及答案
- 速寫(xiě)創(chuàng)作考試題及答案
- 學(xué)生興趣愛(ài)好培養(yǎng)發(fā)展
- 2025年安徽省中考地理試題(解析版)
- 心理健康師資加強(qiáng)
- 第三章 產(chǎn)業(yè)區(qū)位因素復(fù)習(xí)課件+2024-2025學(xué)年高中地理人教版(2019)必修第二冊(cè)
- 構(gòu)建智慧校園管理服務(wù)體系方案提
- 心理師資與輔導(dǎo)力量的加強(qiáng)
- 校園信息學(xué)創(chuàng)新能力賽培養(yǎng)編程思
- 寧夏銀川六中2025屆化學(xué)高二下期末綜合測(cè)試試題含解析
- 人教版(2023版)初中語(yǔ)文九年級(jí)上冊(cè)全冊(cè)同步練習(xí)+單元綜合訓(xùn)練+專(zhuān)項(xiàng)訓(xùn)練+期中期未測(cè)試合集(含答案)【可編輯可打印】
- 電磁兼容中抗擾度試驗(yàn)教學(xué)課件
- 中國(guó)郵政儲(chǔ)蓄銀行理財(cái)考試真題模擬匯編(共719題)
- 醫(yī)務(wù)科崗前培訓(xùn)
- 市政雨污水管道清污清淤工程地下有限空間作業(yè)專(zhuān)項(xiàng)方案2020年10月10
- GB/T 8685-2008紡織品維護(hù)標(biāo)簽規(guī)范符號(hào)法
- 醫(yī)療器械行業(yè)市場(chǎng)部人員崗位職責(zé)
- 旅行社導(dǎo)游帶團(tuán)操作流程
- 部編版小學(xué)道德與法治三年級(jí)下冊(cè)期末質(zhì)量檢測(cè)試卷【含答案】5套
- 怎樣當(dāng)好一名師長(zhǎng)
- DB21T 3354-2020 遼寧省綠色建筑設(shè)計(jì)標(biāo)準(zhǔn)
評(píng)論
0/150
提交評(píng)論