home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / mnuradio / mnuradio.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-01-08  |  2.6 KB  |  88 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   2445
  5.    ClientLeft      =   1545
  6.    ClientTop       =   3735
  7.    ClientWidth     =   3120
  8.    Height          =   3135
  9.    Icon            =   "mnuRadio.frx":0000
  10.    Left            =   1485
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   2445
  13.    ScaleWidth      =   3120
  14.    Top             =   3105
  15.    Width           =   3240
  16.    Begin VB.Menu test 
  17.       Caption         =   "Radio Menu"
  18.       Begin VB.Menu Menu 
  19.          Caption         =   "Menu1"
  20.          Checked         =   -1  'True
  21.          Index           =   1
  22.       End
  23.       Begin VB.Menu Menu 
  24.          Caption         =   "Menu2"
  25.          Index           =   2
  26.       End
  27.       Begin VB.Menu Menu 
  28.          Caption         =   "Menu3"
  29.          Index           =   3
  30.       End
  31.    End
  32. Attribute VB_Name = "Form1"
  33. Attribute VB_Creatable = False
  34. Attribute VB_Exposed = False
  35. Option Explicit
  36. Private Type MENUITEMINFO
  37.     cbSize As Long
  38.     fMask As Long
  39.     fType As Long
  40.     fState As Long
  41.     wID As Long
  42.     hSubMenu As Long
  43.     hbmpChecked As Long
  44.     hbmpUnchecked As Long
  45.     dwItemData As Long
  46.     dwTypeData As String
  47.     cch As Long
  48. End Type
  49. Private Declare Function SetMenuItemInfo Lib "user32" Alias "SetMenuItemInfoA" (ByVal hmenu As Long, ByVal uItem As Long, ByVal fByPosition As Long, lpmii As MENUITEMINFO) As Long
  50. Private Declare Function GetMenu Lib "user32" (ByVal hWnd As Long) As Long
  51. Private Declare Function GetSubMenu Lib "user32" (ByVal hmenu As Long, ByVal nPos As Long) As Long
  52. Private Const MIIM_STATE = &H1
  53. Private Const MIIM_ID = &H2
  54. Private Const MIIM_SUBMENU = &H4
  55. Private Const MIIM_CHECKMARKS = &H8
  56. Private Const MIIM_TYPE = &H10
  57. Private Const MIIM_DATA = &H20
  58. Private Const MFT_RADIOCHECK = &H200&
  59. Private Function SetMenuRadio(Mnu As Menu, ByVal BarPos As Long, ByVal MenuPos As Long)
  60.     Dim M As MENUITEMINFO
  61.     Dim hmenu As Long
  62.     hmenu = GetSubMenu(GetMenu(Mnu.Parent.hWnd), BarPos)
  63.     M.cbSize = Len(M)
  64.     M.fMask = MIIM_TYPE
  65.     M.fType = MFT_RADIOCHECK
  66.     M.fState = 0
  67.     M.wID = 0
  68.     M.hSubMenu = 0
  69.     M.hbmpChecked = 0
  70.     M.hbmpUnchecked = 0
  71.     M.dwItemData = 0
  72.     M.dwTypeData = Mnu.Caption & Chr$(0)
  73.     M.cch = 0
  74.     SetMenuItemInfo hmenu, MenuPos, 1, M
  75. End Function
  76. Private Sub Form_Load()
  77.     SetMenuRadio Menu(1), 0, 0
  78.     SetMenuRadio Menu(2), 0, 1
  79.     SetMenuRadio Menu(3), 0, 2
  80. End Sub
  81. Private Sub Menu_Click(Index As Integer)
  82.     Dim i As Integer
  83.     For i = 1 To 3
  84.         Menu(i).Checked = False
  85.     Next i
  86.     Menu(Index).Checked = True
  87. End Sub
  88.