mDrawMenu.bas
资源名称:IE_VB.rar [点击查看]
上传用户:davilee3
上传日期:2015-04-22
资源大小:986k
文件大小:5k
源码类别:
浏览器
开发平台:
Visual Basic
- Attribute VB_Name = "mDrawMenu"
- Option Explicit
- '###############################################
- 'Public MeOldWndProc As Long '旧的窗体消息处理程序地址
- Public SMenus As New CCSMenu '菜单集合
- Public IcoImgList As ImageList '菜单图标的ImageList
- '注册菜单
- Public Function RstMenu(MenuUpID As Long, MenuID As Long, _
- Optional Key As String, _
- Optional ByVal IcoIndex As Variant, _
- Optional ByVal IcoSelIndex As Variant = -1, _
- Optional ByVal IcoDisIndex As Variant = -1, _
- Optional ByPosition As Long = 1, _
- Optional Tag$ _
- ) As ClsSMenu
- Dim TempCSM As ClsSMenu
- Dim TempMII As MENUITEMINFO
- Dim StrByt(0 To 256) As Byte
- TempMII.cbSize = 44 '结构大小为44字节
- TempMII.fMask = MIIM_ID Or MIIM_STATE Or MIIM_TYPE Or MIIM_DATA '要取得的数据项目
- TempMII.dwTypeData = VarPtr(StrByt(0)) '菜单文字存储地址
- TempMII.cch = UBound(StrByt) '菜单文字长度
- '如果返回0(不成功)则退出
- If GetMenuItemInfo(MenuUpID, MenuID, ByPosition, TempMII) = 0 Then Exit Function
- Set TempCSM = SMenus.Add(Key) '添加项目
- TempCSM.Tag = Tag
- TempCSM.IcoIndex = IcoImgList.ListImages(IcoIndex).index '给图标索引赋值
- If IcoSelIndex < 0 Then
- TempCSM.IcoSelIndex = TempCSM.IcoIndex ' IcoIndex
- Else
- TempCSM.IcoSelIndex = IcoImgList.ListImages(IcoSelIndex).index
- End If
- If IcoDisIndex < 0 Then
- TempCSM.IcoDisableIndex = TempCSM.IcoIndex 'IcoIndex
- Else
- TempCSM.IcoDisableIndex = IcoImgList.ListImages(IcoDisIndex).index
- End If
- TempCSM.MeUpID = MenuUpID '菜单上级句柄
- TempCSM.MeID = TempMII.wID '菜单句柄
- TempCSM.Text = StrConv(LeftB(StrByt, TempMII.cch), vbUnicode) '菜单文字
- If TempMII.fState And MFS_CHECKED Then TempCSM.Check = True 'Check属性
- If TempMII.fState And MFT_RADIOCHECK Then TempCSM.Radio = True 'Radio属性
- If TempMII.fState And (MFS_DISABLED Or MFS_GRAYED) Then TempCSM.Enabled = False 'Enabled属性
- TempMII.cbSize = 44 '结构大小为44字节
- TempMII.fMask = MIIM_TYPE '要改变的数据项目
- TempMII.dwTypeData = VarPtr(StrByt(0)) '菜单文字存储地址
- TempMII.fType = TempMII.fType Or MFT_OWNERDRAW '改为 自画 属性
- Call SetMenuItemInfo(MenuUpID, MenuID, ByPosition, TempMII) '设置菜单
- Set RstMenu = TempCSM '返回值
- Set TempCSM = Nothing
- End Function
- '确定ImageList中有没有Index指定的图片
- Public Function ImgListMapTrue(pImgList As ImageList, index As Long) As Boolean
- If pImgList Is Nothing Then ImgListMapTrue = False: Exit Function
- If index < 1 Or index > pImgList.ListImages.Count Then ImgListMapTrue = False: Exit Function
- ImgListMapTrue = True
- End Function
- '绘制网格
- Public Sub FillWG(hdc As Long, _
- X1 As Long, Y1 As Long, _
- X2 As Long, Y2 As Long, _
- Mode As Integer, C As Long)
- Dim i As Integer, j As Integer
- Dim I1 As Integer, J1 As Integer
- If Mode < 0 Then '25%
- For i = Y1 To Y2 Step 2
- For j = X1 To X2 Step 4
- For I1 = 0 To 1
- For J1 = 0 To 3
- If i + I1 <= Y2 And j + J1 <= X2 Then
- If ((I1 = 0 And J1 = 0) Or (I1 = 1 And J1 = 2)) Then
- SetPixelV hdc, j + J1, (i + I1), C
- Else
- End If
- End If
- Next J1
- Next I1
- Next j
- Next i
- ElseIf Mode = 0 Then '50%
- For i = Y1 To Y2
- For j = X1 To X2
- If (i - Y1 + j - X1) And 1 Then
- Else
- SetPixelV hdc, j, i, C
- End If
- Next j
- Next i
- Else '75%
- For i = Y1 To Y2 Step 2
- For j = X1 To X2 Step 4
- For I1 = 0 To 1
- For J1 = 0 To 3
- If i + I1 <= Y2 And j + J1 <= X2 Then
- If ((I1 = 1 And J1 = 1) Or (I1 = 0 And J1 = 3)) And (i + I1 <= Y2 And j + J1 <= X2) Then
- Else
- SetPixelV hdc, j + J1, (i + I1), C
- End If
- End If
- Next J1
- Next I1
- Next j
- Next i
- End If
- End Sub