正在阅读:用VB制作IE工具条自定义按钮用VB制作IE工具条自定义按钮

2005-07-08 10:23 出处: 作者:张庆 责任编辑:moningfeng


’把字符串值存入注册表
Private Sub SaveString(hKey As Long, strPath As String, strValue As String, strdata As String)
Dim keyhand As Long
Dim r As Long
r=RegCreateKey(hKey, strPath, keyhand)
r=RegSetValueEx(keyhand, strValue, 0,REG_SZ, ByVal strdata, Len(strdata))
r=RegCloseKey(keyhand)
End Sub

’从注册表中删除字符串值
Private Function DeleteValue(ByVal hKey As Long, ByVal strPath As String, ByVal strValue As String)
Dim r, keyhand As Long
r = RegOpenKey(hKey, strPath, keyhand)
r = RegDeleteValue(keyhand, strValue)
r = RegCloseKey(keyhand)
End Function

'把设置写入注册表,定义按钮
Public Sub AddBtn2IEtoolbar()
Dim subKey As String
subKey = subKey0 & Trim(GUID) & “\"
Call SaveString(hKey, subKey, “ButtonText", ButtonText)
Call SaveString(hKey, subKey,“Clsid", “{1FBA04EE-3024-11D2-8F1F0000F87ABD16}")
Call SaveString(hKey, subKey, “Default Visible", “Yes")
Call SaveString(hKey, subKey, “Exec", Exec)
Call SaveString(hKey, subKey, “HotIcon", HotIcon)
Call SaveString(hKey, subKey, “Icon", Icon)
Call SaveString(hKey, subKey, “MenuStatusBar", MenuStatusBar)
Call SaveString(hKey,subKey,“MenuText", MenuText)
End Sub

'从注册表中删除自定义按钮
Public Sub DelBtnFromIEtoolbar()
Dim subKey As String
subKey = subKey0 & Trim(GUID) & “\"
Call DeleteValue(hKey, subKey, “ButtonText")
Call DeleteValue(hKey, subKey, “Clsid")
Call DeleteValue(hKey, subKey, “Default Visible")
Call DeleteValue(hKey, subKey, “Exec")
Call DeleteValue(hKey, subKey, “HotIcon")
Call DeleteValue(hKey, subKey, “Icon")
Call DeleteValue(hKey, subKey, “MenuStatusBar")
Call DeleteValue(hKey, subKey, “MenuText")
End Sub

'初始化控件属性
Private Sub UserControl_InitProperties()
m_ButtonText = m_def_ButtonText
m_Exec = m_def_Exec
m_HotIcon = m_def_HotIcon
m_Icon = m_def_Icon
m_MenuText = m_def_MenuText
m_MenuStatusBar = m_def_MenuStatusBar
m_GUID = m_def_GUID
End Sub

'从存储器中加载属性值
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
m_ButtonText = PropBag.ReadProperty (“ButtonText", m_def_ButtonText)
m_Exec = PropBag.ReadProperty(“Exec",
m_def_Exec)
m_HotIcon = PropBag.ReadProperty(“HotIcon",
m_def_HotIcon)
m_Icon = PropBag.ReadProperty(“Icon",
m_def_Icon)
m_MenuText = PropBag.ReadProperty (“MenuText",m_def_MenuText)
m_MenuStatusBar =PropBag.ReadProperty (“MenuStatusBar", m_def_MenuStatusBar)
m_GUID =PropBag.ReadProperty(“GUID",
m_def_GUID)
End Sub

Private Sub UserControl_Resize()
UserControl.Width = 540
UserControl.Height = 540
Image1.Move 0, 0, ScaleWidth, ScaleHeight
End Sub

'将属性值写到存储器
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Call PropBag.WriteProperty(“ButtonText", m_ButtonText, m_def_ButtonText)
Call PropBag.WriteProperty(“Exec", m_Exec, m_def_Exec)
Call PropBag.WriteProperty(“HotIcon", m_HotIcon, m_def_HotIcon)
Call PropBag.WriteProperty(“Icon", m_Icon, m_def_Icon)
Call PropBag.WriteProperty(“MenuText", m_MenuText, m_def_MenuText)
Call PropBag.WriteProperty(“MenuStatusBar", m_MenuStatusBar, m_def_MenuStatusBar)
Call PropBag.WriteProperty(“GUID",m_GUID, m_def_GUID)
End Sub

’获取按钮文本
Public Property Get ButtonText() As String
ButtonText = m_ButtonText
End Property

’设置按钮文本
Public Property Let ButtonText(ByVal New_ButtonText As String)
m_ButtonText = New_ButtonText
PropertyChanged “ButtonText"
End Property

’获取当前按钮执行目标
Public Property Get Exec() As String
Exec = m_Exec
End Property

’设置当前按钮执行目标
Public Property Let Exec(ByVal New_Exec As String)
m_Exec = New_Exec
PropertyChanged “Exec"
End Property

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

关注我们

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