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 / samples4 / ch18 / listtest.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-02-16  |  6.1 KB  |  175 lines

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