home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / VISUAL_B / CODIGO_1 / LTB_DEMO / LTBDEM.FRM (.txt) next >
Encoding:
Visual Basic Form  |  1992-04-01  |  14.2 KB  |  317 lines

  1. Form1
  2.  Linked Text Box & SmartFill Demo
  3. Form1
  4. Text1
  5. Command1
  6. List1
  7. Command2
  8.     &About...
  9. Command3
  10. Cancel
  11. txtEntry_Change
  12. String2Find!
  13. TxtEntry
  14. wIndex
  15. LstFindEntry
  16. Result
  17. SendMessage
  18. GetFocus
  19. LB_SELECTSTRINGq
  20. cmdClear_Click^
  21.     DropCombo
  22. AutoRedraw
  23. start
  24. LB_RESETCONTENT
  25. CurrentXj
  26. CmdClear
  27. CurrentY
  28. Height
  29. Totalz
  30. cmdOk
  31. cmdClearVB_Click
  32. whiel
  33.     ListCount
  34. cmdLoad_ClickL
  35. AddStr
  36. cmdOK_Click
  37. LstFindEntry_ClickS
  38.     SPEEDTYPE-
  39. SelStart
  40. List'
  41.     SelLength|
  42. Cbo_Last`
  43. SelectionStart
  44. txtEntry_KeyPress
  45. KeyAscii
  46. TxtLen
  47. txtEntry_KeyUp
  48. KeyCode
  49. Shift
  50. DontSearch"
  51. FALSE
  52. txtEntry_KeyDown
  53.     ListIndex
  54. Index
  55. LstFindIndex
  56. Lindexx
  57. STARTSPEEDTYPING
  58. Lscroll
  59.     TxtEntrly1
  60. LoadSampleDataV
  61. Form_Click
  62. @    Form_Load
  63. window_
  64. state
  65. LoadSomeSampleData
  66. WindowState
  67. Txt_Text1_Change"
  68.     Txt_Text1.
  69. Txt_Text1_KeyDownB
  70.     Lst_Link1N
  71. Lst_Link1_Click
  72. Cmd_Command1_Click
  73. SearchString
  74. StartSearch;
  75. TxtText1_Change
  76. TxtText1
  77. TxtText1_KeyDowni
  78. LstLink1`
  79. LstLink1_Click
  80. List1Q
  81. List1_Click3
  82. Text1
  83. Text1_Change
  84. Text1_KeyDownd
  85. Command1_Click
  86. wParm
  87. lparamU
  88. NewListIndex
  89. StartSmartFill
  90. NORMAL
  91. KEY_BACK
  92. KEY_DELETE?
  93. KEY_PGUPI
  94. KEY_PGDN
  95. KEY_UP
  96. KEY_DOWN
  97. Text1_KeyUp
  98. Command2_Click
  99. CRLF9
  100.     Microsoft
  101. there
  102. product
  103. give[
  104. users
  105. Command3_Click
  106. MB_YESNO2
  107. ID_YESD
  108. MB_YESCANCEL
  109. IDYES
  110. andIf
  111. MB_OKCANCEL
  112. AText1
  113. sTemp
  114. lTemp'
  115. characters
  116.     SmartFill
  117. typed
  118. enough
  119. MB_ICONINFORMATION
  120.     List1hWnd
  121. Visible
  122. Boerne
  123. Command1
  124. Default0
  125. Form1C
  126. Title
  127. Banner
  128. ScaleWidth
  129. List1_DblClickj
  130.      Title: LINKDEMO.FRM
  131.  Version: 2.0
  132.  Project: LINKDEMO.MAK
  133.    Description: Demonstration of Linked Text/ListBoxes and SmartFill Demo '
  134.  Author: Jack Presley
  135.  Created: Jan 4, 1992
  136.  Last Revision: Mar 31, 1992 21:45
  137.  Only GetFocus once--no need to do it everytime.
  138.  Display a version number.
  139.  Corrected address info.
  140.  Click on "Demo Info" for more information about this demonstration.
  141.  API Function Declarations.n
  142.  GetFocus returns hWnd% for the control with the
  143.  current focus.  VB's hWnd% only returns a value
  144.  for forms, not controls.d
  145.  This function does all the work of selecting thet
  146.  matching element in our linked list box.  It will do 
  147.  much more, such as clear a listbox with one call.  SeeS
  148.  the January 1992 "Inside Visual Basic" journal forf
  149.  more details.
  150.  Change this value to determine when to start filling in
  151.  text box with data from list box.  If the value is 2,
  152.  and a link exists, when the user types the 3rd character
  153.  the remaining characters will be filled in.
  154. LoadSampleData
  155.  Just some junk mail to put in our list box...
  156. Ralph"
  157. Janet"
  158. Lloyd"
  159. Thomas
  160. Andrew
  161. Anderson
  162. Anderman
  163. Beeson
  164. Martin
  165. McAngus"
  166. Caroline
  167. Joseph
  168. Steven
  169. Robert
  170. Sarah"
  171. Cindy"
  172. Karen"
  173. Dennis
  174. Gladys
  175. Form_Load
  176.  This is explained in Text1_Change
  177.  Get the hWnd of the List control.
  178. Version 2.0  Jack Presley"
  179. List1_Click
  180.  This routine places the item which was clicked upon
  181.  into the Text box.  This in turn causes a Text1_Changen
  182.  event to occur, which resets the focus to the linkedk
  183.  text box.
  184. Text1_Change
  185.  If certain keys are pressed we do not want to searchr
  186.  the linked list box.  'DontSearch' is set in thet
  187.  Text1_KeyUp procedure.  See it for more info.
  188.  Can't pass Text1.Text "ByVal" so assign it to a
  189.  normal string variable...
  190.  Save our position in the text box
  191.  This is where our SmartFill will begin...
  192.  Start our search at the beginning...w
  193.  Make the call...t
  194.  If we found a match and we want to search and we have
  195.  typed enough characters to start SmartFill...
  196.  restore the insertion point and selection...t
  197. Command1_Click
  198.  Okay Button
  199. You did not select anyone.
  200. Linked Textbox Demo"
  201.  Nothing in the text box, leave...
  202.  We've hit the list
  203.  Test for a match...
  204. You have selected 
  205.  for updating.
  206. Linked Textbox Demo"
  207.  Exit now to avoid next test...s
  208.  The selection has failed both previous tests, must be
  209.  a new guy.  Do we add him/her or move on?
  210.  is not in the list.
  211. Would you like to add them to the list?"
  212. Linked Textbox Demo"
  213.  Add the item...
  214.  Highlight the new guy in the text and list boxes...
  215.  Let them start over
  216. Command2_Click
  217.  About Button
  218.  Define All messages first for a little faster response...
  219. Linked Text Box and SmartFill Demonstration"
  220.                                     Jack Presley
  221.                                     Version  2.0
  222.                                     March 31, 1992 "
  223. This program demonstrates two effective tools which you may use 
  224. in your Visual Basic applications.  The first is the Linked Text "
  225. and List box.  Although I had previously accomplished this "
  226. without any API calls by trapping keys, the recent article "
  227. 'Creating a new control--the Combo Dropdown List box' in 'Inside "
  228. Visual Basic' Vol. 2 No. 1 (January 1992) provided me with a "
  229. better and faster way to make the link. 
  230. As the user types in the text box, a 'greater than or equal to' 
  231. search is performed on the linked list box using whatever has 
  232. been typed into the text box as the key.  When the user presses 
  233. OK to confirm his choice, a simple comparison of the Text box 
  234. text and the Listbox index text will tell you if the text is in 
  235. the list box or not.  There's more... 
  236. I use this 'modified' control regularly in my database "
  237. applications.  I put the key field in a linked text/list box.  "
  238. When the user makes a selection in this control I can either "
  239. update the form with that records data or query the user if they "
  240. would like to add this as a new record.  I've got to admit that 
  241. the side affect I like the most is NO SCROLL controls are on my 
  242. forms!  The linked list/text box IS the scroll bar.  On small 
  243. forms I update the form with every Link_Change.  This makes  "
  244. scrolling a little slower, but lets the user browse through the 
  245. records.  On large forms I update the form with Link_DoubleClick "
  246. or Command1_Click, unless the user selects a browse option.  This 
  247. is just one example of the way I put Linked Text/List boxes to "
  248. use.  Click OK for information on SpeedFill... "
  249. SpeedFill is a real time saver.  It uses the match found in the 
  250. Linked List box to 'fill in' the remainder of the selection being 
  251. made in the Linked Text box.  You may  change the number of 
  252. keystrokes required to 'kick in' SpeedFill.  Normally you don't 
  253. want to start it until  after the second keystroke or so. 
  254. The way SpeedFill works is really pretty simple.  When a key is 
  255. pressed the program records how may characters are in the Text "
  256. box text.  If a match is found in the Linked list box, that text "
  257. is assigned to the Text box text.   Here's the magic:  Assign the 
  258. previous text length to the SelStart property and SelLength to "
  259. the length of the new Text box text.  Everything in the new 
  260. SUGGESTED text that was NOT typed by the user is highlighted.  "
  261. Since Windows replaces highlighted text with the next keystroke, "
  262. the user can simply keep typing until a match is made or the text 
  263. is complete.  I make this an option in all my apps."
  264. If you use the Linked Text box, SpeedFill is an easy option to give your users."
  265. This snippet of code and unsolicited advice is free. Please feel "
  266. free to use it as you wish.  Make as many changes as you want...  
  267. But if you decide to upload it to a BBS with these changes, please document them clearly."
  268. Thanks, and good luck. "
  269. Jack Presley
  270. CIS: 70700,166  BIX: JackPresley
  271. Presley Computing"
  272. 29322 Mandetta Drive
  273. Boerne, TX 78006-4529"
  274. (512) 981-9554
  275. (512) 977-6250 (FAX)
  276. I'm an active member of the MSBASIC Forum on CIS in the Visual Basic Section (5).  "
  277. I am very rarely (once or twice a year) on BIX.  "
  278. I'm a consultant in the San Antonio area.  Any referrals will be appreciated!"
  279. Link Text Box Demo  2.0"
  280. Link Text Box Demo  2.0"
  281. About SpeedFill"
  282. Link Text Box Demo  2.0"
  283. Command3_Click
  284.  Cancel 
  285.  Hopefully this isn't the end.  If you improve these
  286.  procedures, please let me and others know about it.
  287.  Everyone needs feedback... good or bad.
  288.  Thanks,
  289.  Jack Presley
  290.  70700,166,
  291. Text1_KeyDown
  292.  This routine allows the user to scroll through the list box
  293.  while the focus is in the text box.  This simulates a link.
  294.  This routine needs to be in the KeyDown vs. KeyUp to allowl
  295.  the user to hold a key down and scroll.  You may experiment
  296.  by replacing the word 'KeyDown' with 'KeyUp' in the above
  297.  Sub statement and watch what happens when you press and holdo
  298.  the up or down arrow, or PgUp/PgDn.
  299.  If there is nothing in the list, leave...
  300.  A temp variable because I'm a lazy typer...
  301.  Determine how much to scroll with a PgUp or PgDnh
  302.  minimum
  303.  will use 1/10 of the total...
  304.  If the user presses the backspace or delete key, we don't want'
  305.  to search for a match in our linked listbox on this pass.  If
  306.  we did the search we would find a match and probably replace thea
  307.  text he just deleted with the same text.  The user could keep
  308.  typing, but could never back up or erase the selected text.  Yout
  309.  may change the TRUE (below) to FALSE to see what happens.
  310.  These lines do the scrolling in the list box.  The "KeyCode = 0" 
  311.  statement, effectively erases the keystroke so the text box is notn
  312.  affected.
  313.  Don't Change anything
  314.  Make sure the new ListIndex value is legal...
  315.  Set the new value...s
  316. List1_DblClick
  317.