mMainMenu.bas
资源名称:IE_VB.rar [点击查看]
上传用户:davilee3
上传日期:2015-04-22
资源大小:986k
文件大小:13k
源码类别:
浏览器
开发平台:
Visual Basic
- Attribute VB_Name = "mMainMenu"
- Option Explicit
- Public Declare Function LoadMenuIndirect Lib "user32" Alias "LoadMenuIndirectA" (ByVal lpMenuTemplate As Long) As Long
- Public Declare Function DestroyMenu Lib "user32" (ByVal hMenu As Long) As Long
- Public Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
- Public Declare Function GetMenuString Lib "user32" Alias "GetMenuStringA" (ByVal hMenu As Long, ByVal wIDItem As Long, ByVal lpString As Long, ByVal nMaxCount As Long, ByVal wFlag As Long) As Long
- 'Public Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
- Public Declare Function TrackPopupMenu Lib "user32" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal x As Long, ByVal y As Long, ByVal nReserved As Long, ByVal hWnd As Long, lprc As Any) As Long
- Private Declare Function SetMenuInfo Lib "user32.dll" (ByVal hMenu As Long, ByRef LPCMENUINFO As MENUINFO) As Long
- Private Declare Function GetMenuInfo Lib "user32.dll" (ByVal hMenu As Long, ByRef LPMENUINFO As MENUINFO) As Long
- 'Private Const MNS_NOTIFYBYPOS As Long = &H8000000
- 'Private Const MIM_STYLE As Long = &H10
- 'Private Type MENUINFO
- ' cbSize As Long
- ' fMask As Long
- ' dwStyle As Long
- ' cyMax As Long
- ' hbrBack As Long
- ' dwContextHelpID As Long
- ' dwMenuData As Long
- 'End Type
- '=============================================
- '===== Main Menu ID ==========================
- '=============================================
- Public Const IDM_Main_File_NewBlank& = 1
- Public Const IDM_Main_File_NewNew& = 2
- Public Const IDM_Main_File_ClipNew& = 3
- Public Const IDM_Main_File_Open& = 4
- Public Const IDM_Main_File_SaveAs& = 5
- Public Const IDM_Main_File_CloseTab& = 6
- Public Const IDM_Main_File_CloseAll& = 7
- Public Const IDM_Main_File_ImportFavorite& = 8
- Public Const IDM_Main_File_ExportFavorite& = 9
- Public Const IDM_Main_File_SavePages& = 10
- Public Const IDM_Main_File_LoadPages& = 11
- Public Const IDM_Main_File_Offline& = 12
- Public Const IDM_Main_File_Exit& = 13
- Public Const IDM_Main_View_Toolbar_StdButton& = 14
- Public Const IDM_Main_View_Toolbar_Address& = 15
- Public Const IDM_Main_View_Toolbar_Searchbar& = 16
- Public Const IDM_Main_View_Toolbar_Tabs& = 17
- Public Const IDM_Main_View_Toolbar_MinTbr& = 18
- Public Const IDM_Main_View_Toolbar_Status& = 19
- Public Const IDM_Main_View_Toolbar_Custom& = 20
- Public Const IDM_Main_View_Toolbar_Lock& = 21
- Public Const IDM_Main_View_SideBand_Favorite& = 84
- Public Const IDM_Main_View_FontSize_1& = 22
- Public Const IDM_Main_View_FontSize_2& = 23
- Public Const IDM_Main_View_FontSize_3& = 24
- Public Const IDM_Main_View_FontSize_4& = 25
- Public Const IDM_Main_View_FontSize_5& = 26
- Public Const IDM_Main_View_Encode_Gb& = 27
- Public Const IDM_Main_View_Encode_Big5& = 28
- Public Const IDM_Main_View_ViewSource& = 29
- Public Const IDM_Main_View_ReloadFavorite& = 30
- Public Const IDM_Main_View_Hideme& = 31
- Public Const IDM_Main_View_FullScreen& = 32
- Public Const IDM_Main_View_PageList& = 33
- Public Const IDM_Main_Favorite_Add& = 34
- Public Const IDM_Main_Favorite_MoreFavs_Lists& = 35
- Public Const IDM_Main_Favorite_MoreFavs_Clear& = 36
- Public Const IDM_Main_Favorite_Reopen_List& = 37
- Public Const IDM_Main_Favorite_Reopen_More& = 38
- Public Const IDM_Main_Tools_Proxy_Config& = 39
- Public Const IDM_Main_Tools_Proxy_Nouse& = 40
- Public Const IDM_Main_Tools_Proxy_UseieCfg& = 41
- Public Const IDM_Main_Tools_Proxy_ProxyList& = 42
- Public Const IDM_Main_Tools_OrganizeFav& = 43
- Public Const IDM_Main_Tools_Option& = 44
- Public Const IDM_Main_Tools_IeOption& = 45
- Public Const IDM_Main_Tools_CollectBoard& = 46
- Public Const IDM_Main_Tools_Slide& = 47
- Public Const IDM_Main_Tabs_DlCtl_Image& = 48
- Public Const IDM_Main_Tabs_DlCtl_Music& = 49
- Public Const IDM_Main_Tabs_DlCtl_Video& = 50
- Public Const IDM_Main_Tabs_DlCtl_Script& = 51
- Public Const IDM_Main_Tabs_DlCtl_ActiveX& = 52
- Public Const IDM_Main_Tabs_DlCtl_JavaApplet& = 53
- Public Const IDM_Main_Tabs_DlCtl_DLActiveX& = 85
- Public Const IDM_Main_Tabs_DlCtl_AllOn& = 54
- Public Const IDM_Main_Tabs_DlCtl_AllOff& = 55
- Public Const IDM_Main_Tabs_NoShowObj& = 56
- Public Const IDM_Main_Tabs_NoShowFloat& = 57
- Public Const IDM_Main_Tabs_ClearMouseLimit& = 58
- Public Const IDM_Main_Tabs_AddFilter& = 59
- Public Const IDM_Main_Tabs_PageZoom_60& = 60
- Public Const IDM_Main_Tabs_PageZoom_80& = 61
- Public Const IDM_Main_Tabs_PageZoom_100& = 62
- Public Const IDM_Main_Tabs_PageZoom_120& = 63
- Public Const IDM_Main_Tabs_PageZoom_140& = 64
- Public Const IDM_Main_Tabs_Script_List& = 65
- Public Const IDM_Main_Tabs_Script_Reload& = 66
- Public Const IDM_Main_Tabs_Script_ViewFolder& = 67
- Public Const IDM_Main_Tabs_HidePage_Hide& = 68
- Public Const IDM_Main_Tabs_HidePage_List& = 69
- 'document designMode
- Public Const IDM_Main_Tabs_designModeOn& = 81
- Public Const IDM_Main_Tabs_designModeOff& = 82
- Public Const IDM_Main_OuterTools_List& = 70
- Public Const IDM_Main_OuterTools_FlashgetDownload& = 71
- Public Const IDM_Main_Window_OpenNew& = 72
- Public Const IDM_Main_Window_Arrange_c& = 73
- Public Const IDM_Main_Window_Arrange_h& = 74
- Public Const IDM_Main_Window_Arrange_v& = 75
- Public Const IDM_Main_Window_Arrange_a& = 76
- Public Const IDM_Main_Help_History& = 77
- Public Const IDM_Main_Help_HomePage& = 78
- Public Const IDM_Main_Help_Blog& = 83
- Public Const IDM_Main_Help_About& = 79
- Public Const IDM_Main_Help_Errlog& = 80
- '===================================================
- '===================================================
- Public Const IDM_Main_Pos_File& = 0
- Public Const IDM_Main_Pos_View& = 1
- Public Const IDM_Main_Pos_Favorite& = 2
- 'Public Const IDM_Main_Pos_Group& = 3
- Public Const IDM_Main_Pos_Tools& = 3
- Public Const IDM_Main_Pos_Tabs& = 4
- 'Public Const IDM_Main_Pos_OuterTools& = 5
- Public Const IDM_Main_Pos_Plugins& = 5
- Public Const IDM_Main_Pos_Windows& = 6
- Public Const IDM_Main_Pos_Help& = 7
- '==== menu item ==================
- Public sMnuItm_Offline As cSmpMenu
- Public sMnuItm_Fontsize As cSmpMenu
- Public sMnuItm_Encode As cSmpMenu
- Public sMnuItm_ViewSource As cSmpMenu
- Public sMnuItm_AddFavorite As cSmpMenu
- Public sMnuItm_DlCtl As cSmpMenu
- Public sMnuItm_NoShowObj As cSmpMenu
- Public sMnuItm_NoShowFloat As cSmpMenu
- Public sMnuItm_ClearMouseLimit As cSmpMenu
- Public sMnuItm_AddFilter As cSmpMenu
- Public sMnuItm_PageZoom As cSmpMenu
- '===============================
- '====== popup menu =========
- Public pMnu_ViewToolbar As cPopMenu
- Public pMnu_ViewSideBand As cPopMenu
- Public Const IdOffset_ViewSideBand& = 200
- Public pMnu_FontSize As cPopMenu
- Public pMnu_MoreFavorite As cPopMenu
- Public Const IdOffset_MoreFavorite& = 200
- Public pMnu_Reopen As cPopMenu
- Public Const IdOffset_Reopen& = 300
- Public pMnu_Proxy As cPopMenu
- Public Const IdOffset_Proxy& = 200
- Public pMnu_DlCtl As cPopMenu
- 'Public pMnu_Plugin_Scripts As cPopMenu
- ' Public Const IdOffset_Plugin_Script& = 200
- 'Public pMnu_OuterTools As cPopMenu
- ' Public Const IdOffset_OuterTools& = 200
- Public pMnu_Windows As cPopMenu
- Public Const IdOffset_Windows& = 200
- Public pMnu_Plugins As cPopMenu
- Public Const IdOffset_Plugins& = 200
- '==============================
- 'menu param flag (MENUINFO.dwMenuData)
- 'main menu(root) flag
- Public Const MenuData_MainMenu As Long = 1
- 'favorite menu flag
- Public Const MenuData_FavoriteMenu As Long = 2
- 'main menu hwnd
- Public gHMainMenu As Long
- '---------------------------------------------------------------------------------------
- ' Procedure : GetMenuTextVb
- ' DateTime : 8/5/2005 12:02
- ' Author : Lingll
- ' Purpose :
- '8/5/2005 :strconv 增加使用了 LocaleID参数
- '---------------------------------------------------------------------------------------
- Public Function GetMenuTextVb(hMenu&, vPos&) As String
- Dim tstr() As Byte, tBffSize&
- ReDim tstr(255)
- tBffSize = GetMenuString(hMenu, vPos, VarPtr(tstr(0)), 255, MF_BYPOSITION)
- ReDim Preserve tstr(0 To tBffSize - 1)
- GetMenuTextVb = StrConv(tstr, vbUnicode, LocaleID_CurUse)
- End Function
- Public Sub LoadMainMenu()
- 'Dim tArr() As Byte
- Dim tcnt&, i&
- 'tArr = LoadResData(500, 4)
- 'gHMainMenu = LoadMenuIndirect(VarPtr(tArr(0)))
- gHMainMenu = LoadMenuVB(500)
- tcnt = GetMenuItemCount(gHMainMenu)
- For i = 0 To tcnt - 1
- SetMenuPosStyle GetSubMenu(gHMainMenu, i)
- SetMenuParam GetSubMenu(gHMainMenu, i), MenuData_MainMenu
- Next i
- Call SetSItems
- Call SetPopMenus
- End Sub
- Private Sub SetSItems()
- Dim tSub&
- '==== file ============
- tSub = GetSubMenu(gHMainMenu, IDM_Main_Pos_File)
- Set sMnuItm_Offline = New cSmpMenu
- sMnuItm_Offline.Ini tSub, IDM_Main_File_Offline, True
- '==== view ===========
- tSub = GetSubMenu(gHMainMenu, IDM_Main_Pos_View)
- Set sMnuItm_Fontsize = New cSmpMenu
- sMnuItm_Fontsize.Ini tSub, 2, False
- '--------
- Set sMnuItm_Encode = New cSmpMenu
- sMnuItm_Encode.Ini tSub, 3, False
- '-----------
- Set sMnuItm_ViewSource = New cSmpMenu
- sMnuItm_ViewSource.Ini tSub, IDM_Main_View_ViewSource, True
- '===== favorite ==========
- tSub = GetSubMenu(gHMainMenu, IDM_Main_Pos_Favorite)
- Set sMnuItm_AddFavorite = New cSmpMenu
- sMnuItm_AddFavorite.Ini tSub, IDM_Main_Favorite_Add, True
- '======= tabs ============
- tSub = GetSubMenu(gHMainMenu, IDM_Main_Pos_Tabs)
- Set sMnuItm_DlCtl = New cSmpMenu
- sMnuItm_DlCtl.Ini tSub, 0, False
- '--------
- Set sMnuItm_NoShowObj = New cSmpMenu
- sMnuItm_NoShowObj.Ini tSub, IDM_Main_Tabs_NoShowObj, True
- '--------
- Set sMnuItm_NoShowFloat = New cSmpMenu
- sMnuItm_NoShowFloat.Ini tSub, IDM_Main_Tabs_NoShowFloat, True
- '--------
- Set sMnuItm_ClearMouseLimit = New cSmpMenu
- sMnuItm_ClearMouseLimit.Ini tSub, IDM_Main_Tabs_ClearMouseLimit, True
- '---------
- Set sMnuItm_AddFilter = New cSmpMenu
- sMnuItm_AddFilter.Ini tSub, IDM_Main_Tabs_AddFilter, True
- '-----------
- Set sMnuItm_PageZoom = New cSmpMenu
- sMnuItm_PageZoom.Ini tSub, 5, False
- End Sub
- Private Sub SetPopMenus()
- Dim tSub&
- tSub = GetSubMenu(gHMainMenu, IDM_Main_Pos_View)
- Set pMnu_ViewToolbar = New cPopMenu
- With pMnu_ViewToolbar
- .Create GetSubMenu(tSub, 0)
- .NODestroy = True
- Call SetMenuPosStyle(.hWnd)
- End With
- Set pMnu_ViewSideBand = New cPopMenu
- With pMnu_ViewSideBand
- .Create GetSubMenu(tSub, 1)
- .NODestroy = True
- Call SetMenuPosStyle(.hWnd)
- End With
- Set pMnu_FontSize = New cPopMenu
- With pMnu_FontSize
- .Create GetSubMenu(tSub, 3)
- .NODestroy = True
- Call SetMenuPosStyle(.hWnd)
- End With
- tSub = GetSubMenu(gHMainMenu, IDM_Main_Pos_Favorite)
- Set pMnu_MoreFavorite = New cPopMenu
- With pMnu_MoreFavorite
- .Create GetSubMenu(tSub, 2)
- .NODestroy = True
- Call SetMenuPosStyle(.hWnd)
- End With
- Set pMnu_Reopen = New cPopMenu
- With pMnu_Reopen
- .Create GetSubMenu(tSub, 3)
- .NODestroy = True
- Call SetMenuPosStyle(.hWnd)
- End With
- tSub = GetSubMenu(gHMainMenu, IDM_Main_Pos_Tools)
- Set pMnu_Proxy = New cPopMenu
- With pMnu_Proxy
- .Create GetSubMenu(tSub, 0)
- .NODestroy = True
- Call SetMenuPosStyle(.hWnd)
- End With
- tSub = GetSubMenu(gHMainMenu, IDM_Main_Pos_Tabs)
- Set pMnu_DlCtl = New cPopMenu
- With pMnu_DlCtl
- .Create GetSubMenu(tSub, 0)
- .NODestroy = True
- Call SetMenuPosStyle(.hWnd)
- End With
- 'Set pMnu_Plugin_Scripts = New cPopMenu
- 'With pMnu_Plugin_Scripts
- ' .Create GetSubMenu(tSub, 6)
- ' .NODestroy = True
- ' 'call SetMenuPosStyle(.hwnd)
- 'End With
- 'tSub = GetSubMenu(gHMainMenu, IDM_Main_Pos_OuterTools)
- 'Set pMnu_OuterTools = New cPopMenu
- 'With pMnu_OuterTools
- ' .Create tSub
- ' .NODestroy = True
- ' Call SetMenuPosStyle(.hwnd)
- 'End With
- tSub = GetSubMenu(gHMainMenu, IDM_Main_Pos_Windows)
- Set pMnu_Windows = New cPopMenu
- With pMnu_Windows
- .Create tSub
- .NODestroy = True
- Call SetMenuPosStyle(.hWnd)
- End With
- tSub = GetSubMenu(gHMainMenu, IDM_Main_Pos_Plugins)
- Set pMnu_Plugins = New cPopMenu
- With pMnu_Plugins
- .Create tSub
- .NODestroy = True
- Call SetMenuPosStyle(.hWnd)
- End With
- End Sub
- '---------------------------------------------------------------------------------------
- ' Procedure : SetMenuPosStyle
- ' DateTime : 2005-??-?? ??:??
- ' Author : Lingll
- ' Purpose : 更改menu style使其能响应wm_menucommand
- '---------------------------------------------------------------------------------------
- Public Sub SetMenuPosStyle(hMenu&)
- Dim tMif As MENUINFO
- With tMif
- .cbSize = Len(tMif)
- .fMask = MIM_STYLE
- End With
- Call GetMenuInfo(hMenu, tMif)
- tMif.dwStyle = tMif.dwStyle Or MNS_NOTIFYBYPOS
- Call SetMenuInfo(hMenu, tMif)
- End Sub
- '加载资源文件中的menu,返回menu的hwnd
- Public Function LoadMenuVB(id&) As Long
- Dim tArr() As Byte
- tArr = LoadResData(id, 4)
- LoadMenuVB = LoadMenuIndirect(VarPtr(tArr(0)))
- End Function