home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form frmMenusWithRadioButtons
- Caption = "Menus With Radio Buttons"
- ClientHeight = 2880
- ClientLeft = 165
- ClientTop = 735
- ClientWidth = 5130
- Icon = "frmMenusWithRadioButtons.frx":0000
- LinkTopic = "Form1"
- PaletteMode = 1 'UseZOrder
- ScaleHeight = 2880
- ScaleWidth = 5130
- StartUpPosition = 3 'Windows Default
- Begin VB.Label Label1
- Alignment = 1 'Right Justify
- AutoSize = -1 'True
- Caption = "Written for the VB Center Code Library"
- BeginProperty Font
- Name = "Small Fonts"
- Size = 6.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 165
- Left = 2700
- TabIndex = 1
- Top = 2400
- Width = 2355
- End
- Begin VB.Label Label2
- Alignment = 1 'Right Justify
- AutoSize = -1 'True
- Caption = "http://www.geocities.com/SiliconValley/Way/6445"
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00800000&
- Height = 195
- Left = 720
- TabIndex = 0
- Top = 2640
- Width = 4365
- End
- Begin VB.Menu Options
- Caption = "Options"
- 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
- Attribute VB_Name = "frmMenusWithRadioButtons"
- 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 mnuOptions_Click(Index As Integer)
- Static prevSelection As Integer
- mnuOptions(prevSelection).Checked = False
- mnuOptions(Index).Checked = True
- prevSelection = Index
- End Sub
-