正在阅读:vb高手搜集-常见问题总结(3)vb高手搜集-常见问题总结(3)

2005-06-16 10:14 出处: 作者:阳光宝宝 责任编辑:moningfeng
三、如何隐藏及显示任务栏   有时候,我们希望在我们的程序执行中,将任务栏隐藏,让桌面变得比较清爽,等到我们的程序执行完毕之后,再将任务栏显示出来,这时就要用到 SetWindowPos 这个 API 了!

Private 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 Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Const SWP_HIDEWINDOW = &H80 '隐藏视窗 Const SWP_SHOWWINDOW = &H40 '显示视窗   '在程序中若要隐藏任务栏 Private Sub Command1_Click() Dim Thwnd As Long Thwnd = FindWindow("Shell_traywnd", "") Call SetWindowPos(Thwnd, 0, 0, 0, 0, 0, SWP_HIDEWINDOW) End Sub   '在程序中若要再显示任务栏 Private Sub Command2_Click() Dim Thwnd As Long Thwnd = FindWindow("Shell_traywnd", "") Call SetWindowPos(Thwnd, 0, 0, 0, 0, 0, SWP_SHOWWINDOW) End Sub

四、如何得到文件路径的文件名

Dim sFilePath As String sFilePath = "C:\Windows\System\sytem.dll" Dim lGetLen As Long, lNum As Long Dim sGetFile As String, sTemp As String lGetLen = Len(sFilePath) '得到文件路径长度 sTemp = lGetLen For lNum = 1 To lGetLen If Left(sGetFile, 1) = "\" Then Exit For sGetFile = Mid(sFilePath, sTemp, lNum) sTemp = sTemp - 1 Next lNum sGetFile = Mid(sGetFile, 2) '得到文件名 MsgBox sGetFile

五、如何防止使用者按下 CTRL + ALT + DEL   有些时候,我们的应用程序执行时,不希望使用者按下 CTRL + ALT + DEL 来异常结束程序或关机,这时候我们可以在启动程序时,将 CTRL + ALT + DEL 功能键之功能取消,然后在结束程序之前,再从新恢复 CTRL + ALT + DEL 之功能。   在模组声明区中加入以下声明及模组:

Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, lpvParam As Any, ByVal fuWinIni As Long) As Long Public Const SPI_SCREENSAVERRUNNING = 97 Public Sub Disable_Ctrl_Alt_Del()   '让 CTRL+ALT+DEL 失效 Dim AyW As Integer Dim TurFls As Boolean AwY = SystemParametersInfo(SPI_SCREENSAVERRUNNING, True, TurFls, 0) End Sub Public Sub Enable_Ctrl_Alt_Del()   '让 CTRL+ALT+DEL 恢复功能 Dim AwY As Integer Dim TurFls As Boolean AwY = SystemParametersInfo(SPI_SCREENSAVERRUNNING, False, TurFls, 0) End Sub   '实际使用时,在 Form 中加入以下程序码: Private Sub Form_Load() Disable_Ctrl_Alt_Del End Sub Private Sub Form_Unload(Cancel As Integer) Enable_Ctrl_Alt_Del End Sub

键盘也能翻页,试试“← →”键

关注我们

最新资讯离线随时看 聊天吐槽赢奖品