VBGood网站全文搜索 Google

首页 - 经验之谈 - 在隐含工具条中如何建立一个ActiveX控件
发表评论(0)作者:不详, 平台:VB6.0+Win98, 阅读:8347, 日期:2001-04-11
How to create an ActiveX Control which hides the Taskbar

This tip shows how to really hide the Windows Taskbar, not to move it outside the desktop, and to avoid the API磗 in the future we can make an ActiveX Control which does the work.

First create a new ActiveX Control project, add a module to it, just like you would in a normal .exe project. Put the following API declaracions into it:

Declare Function ShowWindow Lib _
"user32" (ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long

Declare Function FindWindow Lib _
"user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) _
As LongNow we have to set some properties for the UserControl1.

BorderStyle=1-Fixed Single
Picture= Choose one
ToolBoxBitmap=Choose one
Adjust the UserControl磗 size to the picture.

Put the following codes to the UserControl:

注释:Creates the property TaskBar.Show
Public Property Let Show(ByVal VShow As Boolean)
TBwnd& = FindWindow("Shell_traywnd", "")

If VShow = True Then
注释:if TaskBar.Show=true it shows the TaskBar
ShowWnd& = ShowWindow(TBwnd&, 1)
注释:if not it hides the TaskBar
ShowWnd& = ShowWindow(TBwnd&, 0)
End If
End PropertySave your project with the name TaskBar and "Make TaskBar.ocx".

Now we have to try the Control so create a new (normal) .exe app and put 2 commandbuttons on form1, with the captions "Show" and "Hide".  We have to look for our own control now, click menu-project-components (or right click on the toolbox),   normally all ActiveX Controls (.ocx) are located in your windowssystem folder they should appear directlly in the list if not click on the browse button and select the pathTaskBar.ocx, and confirm.  The Control should appear in the toolbox with the picture you磛e selected in ToolBoxBitmap.

Place the Control on the form together with the 2 commandbuttons and add the following code to the click events of the commandbuttons:

Private Sub Command1_Click()
taskbar1.Show = True
End Sub

Private Sub Command2_Click()
taskbar1.Show = False
End SubExecute the app. (F5) and click on the buttons.