⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmmenuswithradiobuttons.frm

📁 100个vb编程实例,什么都有
💻 FRM
字号:
VERSION 5.00
Begin VB.Form form1 
   Caption         =   "在菜单中加入广播按钮"
   ClientHeight    =   2055
   ClientLeft      =   165
   ClientTop       =   735
   ClientWidth     =   3945
   Icon            =   "frmMenusWithRadioButtons.frx":0000
   LinkTopic       =   "Form1"
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   2055
   ScaleWidth      =   3945
   StartUpPosition =   3  '窗口缺省
   Begin VB.Menu Options 
      Caption         =   "选项"
      Begin VB.Menu mnuOptions 
         Caption         =   "Option Radio Item 1"
         Index           =   0
      End
      Begin VB.Menu mnuOptions 
         Caption         =   "Option Radio Item 2"
         Index           =   1
      End
      Begin VB.Menu mnuOptions 
         Caption         =   "Option Radio Item 3"
         Index           =   2
      End
      Begin VB.Menu mnuOptions 
         Caption         =   "-"
         Index           =   3
      End
      Begin VB.Menu mnuOptions 
         Caption         =   "Option Check Item 1"
         Index           =   4
      End
      Begin VB.Menu mnuOptions 
         Caption         =   "Option Check Item 2"
         Index           =   5
      End
      Begin VB.Menu mnuOptions 
         Caption         =   "Option Check Item 3"
         Index           =   6
      End
   End
End
Attribute VB_Name = "form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Form_Load()

' just change the radio check for the first 3 menu items
SetRadioMenuChecks mnuOptions(0), 0
SetRadioMenuChecks mnuOptions(1), 1
SetRadioMenuChecks mnuOptions(2), 2

End Sub
Private Sub SetRadioMenuChecks(Mnu As Menu, ByVal mnuItem&)

Dim hMenu&
Dim mInfo As MENUITEMINFO

' get the menu item handle
hMenu& = GetSubMenu(GetMenu(Mnu.Parent.hwnd), 0)

' copy it's attributes to the new Type,
' changing the checkmark to a radio button
mInfo.cbSize = Len(mInfo)
mInfo.fType = MFT_RADIOCHECK
mInfo.fMask = MIIM_TYPE
mInfo.dwTypeData = Mnu.Caption & Chr$(0)

' change the menu checkmark
SetMenuItemInfo hMenu&, mnuItem&, 1, mInfo

End Sub

Private Sub Label2_Click()

End Sub

Private Sub mnuOptions_Click(Index As Integer)

Static prevSelection As Integer

mnuOptions(prevSelection).Checked = False
mnuOptions(Index).Checked = True
prevSelection = Index

End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -