home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1999 October / pcp156b.iso / handson / files / vbwkshp / examples / menu.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-06-28  |  2.5 KB  |  83 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   3195
  5.    ClientLeft      =   165
  6.    ClientTop       =   735
  7.    ClientWidth     =   4680
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   3195
  10.    ScaleWidth      =   4680
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.CommandButton Write 
  13.       Caption         =   "Save INI file"
  14.       Height          =   615
  15.       Left            =   2640
  16.       TabIndex        =   1
  17.       Top             =   360
  18.       Width           =   1575
  19.    End
  20.    Begin VB.CommandButton Add 
  21.       Caption         =   "Add Menu Item"
  22.       Height          =   615
  23.       Left            =   600
  24.       TabIndex        =   0
  25.       Top             =   360
  26.       Width           =   1695
  27.    End
  28.    Begin VB.Menu mnuFile 
  29.       Caption         =   "File"
  30.       Begin VB.Menu mnuClose 
  31.          Caption         =   "Close"
  32.       End
  33.       Begin VB.Menu mnuOpen 
  34.          Caption         =   "Open"
  35.       End
  36.       Begin VB.Menu x 
  37.          Caption         =   "-"
  38.       End
  39.       Begin VB.Menu mnuRecentFile 
  40.          Caption         =   ""
  41.          Enabled         =   0   'False
  42.          Index           =   0
  43.          Visible         =   0   'False
  44.       End
  45.    End
  46. Attribute VB_Name = "Form1"
  47. Attribute VB_GlobalNameSpace = False
  48. Attribute VB_Creatable = False
  49. Attribute VB_PredeclaredId = True
  50. Attribute VB_Exposed = False
  51. Option Explicit
  52. Private Declare Function WritePrivateProfileString Lib _
  53.        "kernel32" Alias "WritePrivateProfileStringA" _
  54.        (ByVal lpApplicationName As String, _
  55.        ByVal lpKeyName As Any, _
  56.        ByVal lpString As Any, _
  57.        ByVal lpFileName As String) As Long
  58. Private Declare Function GetPrivateProfileString Lib _
  59.     "kernel32" Alias "GetPrivateProfileStringA" _
  60.     (ByVal lpApplicationName As String, _
  61.     ByVal lpKeyName As Any, _
  62.     ByVal lpDefault As String, _
  63.     ByVal lpReturnedString As String, _
  64.     ByVal nSize As Long, ByVal lpFileName As String) As Long
  65. Private Sub Add_Click()
  66. mnuRecentFile(0).Visible = True
  67. mnuRecentFile(0).Enabled = True
  68. mnuRecentFile(0).Caption = "hello"
  69. Load mnuRecentFile(2)
  70. mnuRecentFile(2).Caption = "yyy"
  71. End Sub
  72. Private Sub Form_Load()
  73. Dim r As Long, s As String
  74. s = String(255, 0)
  75. r = GetPrivateProfileString("VBMenu", "Files", "default", s, 255, "menu.ini")
  76. Load mnuRecentFile(1)
  77. mnuRecentFile(1).Caption = s
  78. End Sub
  79. Private Sub Write_Click()
  80. Dim r As Long
  81. r = WritePrivateProfileString("VBmenu", "Files", "xxx", "menu.ini")
  82. End Sub
  83.