home *** CD-ROM | disk | FTP | other *** search
/ Dan Appleman's Visual Bas…s Guide to the Win32 API / Dan.Applmans.Visual.Basic.5.0.Programmers.Guide.To.The.Win32.API.1997.Ziff-Davis.Press.CD / VB5PG32.mdf / vbpg32 / samples5 / ch18 / listtest.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-02-16  |  6.1 KB  |  174 lines

  1. VERSION 5.00
  2. Begin VB.Form frmList 
  3.    Caption         =   "Listbox Example"
  4.    ClientHeight    =   3015
  5.    ClientLeft      =   1095
  6.    ClientTop       =   1515
  7.    ClientWidth     =   5040
  8.    LinkTopic       =   "Form1"
  9.    PaletteMode     =   1  'UseZOrder
  10.    ScaleHeight     =   3015
  11.    ScaleWidth      =   5040
  12.    Begin VB.CommandButton Command4 
  13.       Caption         =   "Add2"
  14.       Height          =   435
  15.       Left            =   3540
  16.       TabIndex        =   4
  17.       Top             =   2220
  18.       Width           =   1095
  19.    End
  20.    Begin VB.CommandButton Command3 
  21.       Caption         =   "Add1"
  22.       Height          =   435
  23.       Left            =   3540
  24.       TabIndex        =   3
  25.       Top             =   1740
  26.       Width           =   1095
  27.    End
  28.    Begin VB.CommandButton Command2 
  29.       Caption         =   "Scrollbars"
  30.       Height          =   495
  31.       Left            =   3540
  32.       TabIndex        =   2
  33.       Top             =   1200
  34.       Width           =   1095
  35.    End
  36.    Begin VB.CommandButton Command1 
  37.       Caption         =   "Fill Listbox"
  38.       Height          =   495
  39.       Left            =   3540
  40.       TabIndex        =   1
  41.       Top             =   600
  42.       Width           =   1095
  43.    End
  44.    Begin VB.ListBox List1 
  45.       Height          =   1980
  46.       Left            =   240
  47.       TabIndex        =   0
  48.       Top             =   600
  49.       Width           =   2955
  50.    End
  51. Attribute VB_Name = "frmList"
  52. Attribute VB_GlobalNameSpace = False
  53. Attribute VB_Creatable = False
  54. Attribute VB_PredeclaredId = True
  55. Attribute VB_Exposed = False
  56. Option Explicit
  57. ' copyright 
  58.  1997 by Desaware Inc. All Rights Reserved
  59. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
  60. Private Declare Function SendMessageBynum Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  61. Private Declare Function SendMessageByString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
  62. Private Const LB_ADDSTRING = &H180
  63. Private Const LB_INSERTSTRING = &H181
  64. Private Const LB_DELETESTRING = &H182
  65. Private Const LB_SELITEMRANGEEX = &H183
  66. Private Const LB_RESETCONTENT = &H184
  67. Private Const LB_SETSEL = &H185
  68. Private Const LB_SETCURSEL = &H186
  69. Private Const LB_GETSEL = &H187
  70. Private Const LB_GETCURSEL = &H188
  71. Private Const LB_GETTEXT = &H189
  72. Private Const LB_GETTEXTLEN = &H18A
  73. Private Const LB_GETCOUNT = &H18B
  74. Private Const LB_SELECTSTRING = &H18C
  75. Private Const LB_DIR = &H18D
  76. Private Const LB_GETTOPINDEX = &H18E
  77. Private Const LB_FINDSTRING = &H18F
  78. Private Const LB_GETSELCOUNT = &H190
  79. Private Const LB_GETSELITEMS = &H191
  80. Private Const LB_SETTABSTOPS = &H192
  81. Private Const LB_GETHORIZONTALEXTENT = &H193
  82. Private Const LB_SETHORIZONTALEXTENT = &H194
  83. Private Const LB_SETCOLUMNWIDTH = &H195
  84. Private Const LB_ADDFILE = &H196
  85. Private Const LB_SETTOPINDEX = &H197
  86. Private Const LB_GETITEMRECT = &H198
  87. Private Const LB_GETITEMDATA = &H199
  88. Private Const LB_SETITEMDATA = &H19A
  89. Private Const LB_SELITEMRANGE = &H19B
  90. Private Const LB_SETANCHORINDEX = &H19C
  91. Private Const LB_GETANCHORINDEX = &H19D
  92. Private Const LB_SETCARETINDEX = &H19E
  93. Private Const LB_GETCARETINDEX = &H19F
  94. Private Const LB_SETITEMHEIGHT = &H1A0
  95. Private Const LB_GETITEMHEIGHT = &H1A1
  96. Private Const LB_FINDSTRINGEXACT = &H1A2
  97. Private Const LB_SETLOCALE = &H1A5
  98. Private Const LB_GETLOCALE = &H1A6
  99. Private Const LB_SETCOUNT = &H1A7
  100. Private Const LB_MSGMAX = &H1A8
  101. Private Const LB_INITSTORAGE = &H1A8
  102. Private Const LB_ITEMFROMPOINT = &H1A9
  103. ' Combo Box return Values
  104. Private Const CB_OKAY = 0
  105. Private Const CB_ERR = (-1)
  106. Private Const CB_ERRSPACE = (-2)
  107. ' Combo Box messages
  108. Private Const CB_GETEDITSEL = &H140
  109. Private Const CB_LIMITTEXT = &H141
  110. Private Const CB_SETEDITSEL = &H142
  111. Private Const CB_ADDSTRING = &H143
  112. Private Const CB_DELETESTRING = &H144
  113. Private Const CB_DIR = &H145
  114. Private Const CB_GETCOUNT = &H146
  115. Private Const CB_GETCURSEL = &H147
  116. Private Const CB_GETLBTEXT = &H148
  117. Private Const CB_GETLBTEXTLEN = &H149
  118. Private Const CB_INSERTSTRING = &H14A
  119. Private Const CB_RESETCONTENT = &H14B
  120. Private Const CB_FINDSTRING = &H14C
  121. Private Const CB_SELECTSTRING = &H14D
  122. Private Const CB_SETCURSEL = &H14E
  123. Private Const CB_SHOWDROPDOWN = &H14F
  124. Private Const CB_GETITEMDATA = &H150
  125. Private Const CB_SETITEMDATA = &H151
  126. Private Const CB_GETDROPPEDCONTROLRECT = &H152
  127. Private Const CB_SETITEMHEIGHT = &H153
  128. Private Const CB_GETITEMHEIGHT = &H154
  129. Private Const CB_SETEXTENDEDUI = &H155
  130. Private Const CB_GETEXTENDEDUI = &H156
  131. Private Const CB_GETDROPPEDSTATE = &H157
  132. Private Const CB_FINDSTRINGEXACT = &H158
  133. Private Const CB_SETLOCALE = &H159
  134. Private Const CB_GETLOCALE = &H15A
  135. Private Const CB_MSGMAX = &H15B
  136. Private Const CB_GETDROPPEDWIDTH = &H15F
  137. Private Const CB_GETHORIZONTALEXTENT = &H15D
  138. Private Const CB_GETTOPINDEX = &H15B
  139. Private Const CB_INITSTORAGE = &H161
  140. Private Const CB_SETDROPPEDWIDTH = &H160
  141. Private Const CB_SETHORIZONTALEXTENT = &H15E
  142. Private Const CB_SETTOPINDEX = &H15C
  143. Private Const WM_SETREDRAW = &HB
  144. Private Sub Command1_Click()
  145.     Dim tabpos(3) As Long
  146.     Dim x&
  147.     tabpos(0) = 40  ' About 10 characters
  148.     tabpos(1) = 50
  149.     tabpos(2) = 70
  150.     Call SendMessage(List1.hwnd, LB_SETTABSTOPS, 3, tabpos(0))
  151.     For x = 1 To 20
  152.         List1.AddItem "first" & vbTab & "2nd" & vbTab & "3rd" & vbTab & "4th and last entry"
  153.     Next x
  154. End Sub
  155. Private Sub Command2_Click()
  156.     Call SendMessageBynum(List1.hwnd, LB_SETHORIZONTALEXTENT, 400, 0)
  157. End Sub
  158. Private Sub Command3_Click()
  159.     Dim l&
  160.     List1.Clear
  161.     For l = 1 To 1000
  162.         Call SendMessageByString(List1.hwnd, LB_ADDSTRING, 0, "string entry")
  163.     Next l
  164. End Sub
  165. Private Sub Command4_Click()
  166.     Dim l&
  167.     List1.Clear
  168.     Call SendMessageBynum(List1.hwnd, WM_SETREDRAW, False, 0)
  169.     For l = 1 To 1000
  170.         Call SendMessageByString(List1.hwnd, LB_ADDSTRING, 0, "string entry")
  171.     Next l
  172.     Call SendMessageBynum(List1.hwnd, WM_SETREDRAW, True, 0)
  173. End Sub
  174.