home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / menubutn / form1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-07-09  |  2.9 KB  |  94 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Menus With Radio Buttons"
  4.    ClientHeight    =   2715
  5.    ClientLeft      =   165
  6.    ClientTop       =   735
  7.    ClientWidth     =   5190
  8.    Icon            =   "Form1.frx":0000
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   2715
  11.    ScaleWidth      =   5190
  12.    StartUpPosition =   3  'Windows Default
  13.    Begin VB.Label Label1 
  14.       AutoSize        =   -1  'True
  15.       Caption         =   "
  16.  1997 VB Center"
  17.       Height          =   195
  18.       Left            =   120
  19.       TabIndex        =   1
  20.       Top             =   2040
  21.       Width           =   1305
  22.    End
  23.    Begin VB.Label Label2 
  24.       AutoSize        =   -1  'True
  25.       Caption         =   "VB Center Home: http://www.geocities.com/SiliconValley/Way/6445"
  26.       Height          =   195
  27.       Left            =   120
  28.       TabIndex        =   0
  29.       Top             =   2400
  30.       Width           =   4920
  31.    End
  32.    Begin VB.Menu Options 
  33.       Caption         =   "Options"
  34.       Begin VB.Menu mnuOptions 
  35.          Caption         =   "Option Radio Item 1"
  36.          Index           =   0
  37.       End
  38.       Begin VB.Menu mnuOptions 
  39.          Caption         =   "Option Radio Item 2"
  40.          Index           =   1
  41.       End
  42.       Begin VB.Menu mnuOptions 
  43.          Caption         =   "Option Radio Item 3"
  44.          Index           =   2
  45.       End
  46.       Begin VB.Menu mnuOptions 
  47.          Caption         =   "-"
  48.          Index           =   3
  49.       End
  50.       Begin VB.Menu mnuOptions 
  51.          Caption         =   "Option Check Item 1"
  52.          Index           =   4
  53.       End
  54.       Begin VB.Menu mnuOptions 
  55.          Caption         =   "Option Check Item 2"
  56.          Index           =   5
  57.       End
  58.       Begin VB.Menu mnuOptions 
  59.          Caption         =   "Option Check Item 3"
  60.          Index           =   6
  61.       End
  62.    End
  63. Attribute VB_Name = "Form1"
  64. Attribute VB_GlobalNameSpace = False
  65. Attribute VB_Creatable = False
  66. Attribute VB_PredeclaredId = True
  67. Attribute VB_Exposed = False
  68. Private Sub Form_Load()
  69. ' just change the radio check for the first 3 menu items
  70. SetRadioMenuChecks mnuOptions(0), 0
  71. SetRadioMenuChecks mnuOptions(1), 1
  72. SetRadioMenuChecks mnuOptions(2), 2
  73. End Sub
  74. Private Sub SetRadioMenuChecks(Mnu As Menu, ByVal mnuItem&)
  75. Dim hMenu&
  76. Dim mInfo As MENUITEMINFO
  77. ' get the menu item handle
  78. hMenu& = GetSubMenu(GetMenu(Mnu.Parent.hwnd), 0)
  79. ' copy it's attributes to the new Type,
  80. ' changing the checkmark to a radio button
  81. mInfo.cbSize = Len(mInfo)
  82. mInfo.fType = MFT_RADIOCHECK
  83. mInfo.fMask = MIIM_TYPE
  84. mInfo.dwTypeData = Mnu.Caption & Chr$(0)
  85. ' change the menu checkmark
  86. SetMenuItemInfo hMenu&, mnuItem&, 1, mInfo
  87. End Sub
  88. Private Sub mnuOptions_Click(Index As Integer)
  89. Static prevSelection As Integer
  90. mnuOptions(prevSelection).Checked = False
  91. mnuOptions(Index).Checked = True
  92. prevSelection = Index
  93. End Sub
  94.