home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / 3d_tabs / dialog.frm (.txt) next >
Visual Basic Form  |  1994-05-30  |  14KB  |  192 lines

  1.     DialogBox
  2. Form15b
  3. tabbox
  4. invbox
  5. PicBox
  6. About this control
  7. Please feel free to modify this code in any way you please. If you make any signifigant improvements, upload the files. Suggestions: 3D effects for the Form, more tab styles, multiple focus (one for each row),
  8. MS Sans Serif
  9. Since this control is VB source code and freely modifiable by the user, I didn't feel it was necessary to anticipate every possible usage. Most of this kind of code would need to be removed each time it was used.. For example, the Resize code can be removed if your forms are not sizable.
  10. MS Sans Serif
  11. This control is Freeware. It is based on a similar control written by James Parr and uploaded to compuserve. It is 100% VB code, no DLL's, no VBX's, yet it should perform about as well. This control adds 3D effects, multiple instances, and mixed control types for pages.
  12. MS Sans Serif
  13. V. About this control.
  14. MS Sans Serif
  15. PicBox
  16. Step 4
  17. The tab control is generated by first drawing one tab in the proper size and orientation (invbox) and then blitting this picture to the visible picturebox (tabbox). Rescaling and StretchBlting seemed even more cumbersome than the method used. When a tab is clicked, only the tab captions  and the focus line are redrawn. While the speed could be improved a little, the response of the control seems to depend more on the pages and their contents at this point than on the tab element.
  18. MS Sans Serif
  19. Run the project and examine the control. The code controlling the graphic appearance is in DrawTabs(). TabClick() controls the behavior of the tabs when clicked. Try resetting the tb.num and tb.cols values. Note that unused spaces are filled with unlabeled tabs; this was done because of the awkward effect produced when a partial row was moved beneath a full row, so be prepared to tackle this problem if you wish to eliminate unused tabs.
  20. MS Sans Serif
  21. IV. That's it!
  22. MS Sans Serif
  23. PicBox
  24. Step 3
  25. Size the first member of the page() array to the proper size. All the pages will be resized automatically to match it, and the tabbox and Form will be resized to fit it. See the other samples for examples of how to position the tabs on other types of Forms.
  26. MS Sans Serif
  27. If Keycode = H22 then NextPage
  28. Courier New
  29. If Keycode = H21 then PrevPage
  30. Courier New
  31. "tb.orient = 1   ' 0 = up, 1 = down
  32. Courier New
  33. III. Set additional properties.
  34. MS Sans Serif
  35. bIf you wish to handle keyboard events, add code such as the following to the Form's KeyDown event.
  36. MS Sans Serif
  37. sIf you want the tabs to appear below the pages, add the following line to Form_Load before calling DefineControl():
  38. MS Sans Serif
  39. If you wish to set the Font properties of the tab captions, set the properties of the tabbox picturebox to the desired settings.
  40. MS Sans Serif
  41. PicBox
  42. Step 1
  43. I. Creating the controls.
  44. MS Sans Serif
  45. 4. Set the tag property of each pictuebox to the text you want to appear on the tab for this page. Add whatever controls you want on each page to the appropriate PicBox()..
  46. MS Sans Serif
  47. 3. Create a control array of 6 pictureboxes. (Any control which can act as container can be used instead of pictureboxes.) These are the 'pages'. On this Form, they are PicBox(0) - PicBox(5).
  48. MS Sans Serif
  49. 2. Set borderstyle=0 and scalemode=3 on both pictureboxes. Set visible=False on the child picturebox (invbox). Set the backcolor of both boxes and the Form to light grey
  50. MS Sans Serif
  51. x1. Create a picturebox. Create a second picturebox within the first. On this Form, they are named 'tabbox' and 'invbox'.
  52. MS Sans Serif
  53. PicBox
  54. Step 2
  55. II. Adding the code.
  56. MS Sans Serif
  57. 33. Add the follwing line to the tabbox_Paint event:
  58. MS Sans Serif
  59. DrawText tabbox, page(), tb
  60. Courier New
  61. )TabClick Button, X, Y, tabbox, page(), tb
  62. Courier New
  63. 53. Add the follwing line to the tabbox_MouseUp event:
  64. MS Sans Serif
  65. ,DefineControl Me, tabbox, invbox, page(), tb
  66. Courier New
  67. tb.cols = 3
  68. Courier New
  69. -For i = 0 to 5: Set page(i) = PicBox(i): Next
  70. Courier New
  71. ReDim page(0 to 5)
  72. Courier New
  73. 22. Add the following lines to the Form_Load event:
  74. MS Sans Serif
  75. Dim tb as TabData
  76. Courier New
  77. Dim page() as control
  78. Courier New
  79. ?1. Add the following lines to the general declarations section:
  80. MS Sans Serif
  81. PicBox
  82. Intro
  83. )Several pictureboxes or frames --------->
  84. MS Sans Serif
  85. 2 Pictureboxes --------->
  86. MS Sans Serif
  87. Image1
  88. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
  89. pwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
  90. pwwwp
  91. wwwwwwwwwwwwwwwwwwwwwwwwwww
  92. pwwwpwwwwwwwwwwwww
  93. wwwwwwwwwwwwwwwwwwwwwwwwwww
  94. pwwwpwwwwwwwwwwwww
  95. wwwwwwwwwwwwwwwwwwwwwwwwwww
  96. pwwwpwwwwwwwwwwwww
  97. wwwwwwwwwwwwwwwwwwwwwwwwwww
  98. pwwwpwwwwwwwwwwwww
  99. wwwwwwwwwwwwwwwwwwwwwwwwwww
  100. pwwwpwwwwwwwwwwwww
  101. wwwwwwwwwwwwwwwwwwwwwwwwwww
  102. pwwwp
  103. wwwwwwwwwwwwwwwwwwwwwwwwwww
  104. pwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
  105. pwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
  106. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
  107. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
  108. E The following tabs explain the steps required to create this sample.
  109. MS Sans Serif
  110.  To handle events, add function calls to the KeyPress and Resize events of your Form, and to the MouseUp and Paint events of the tab picturebox.
  111. MS Sans Serif
  112. nThe tab 'control' consists of 2 picture boxes and whatever other controls are needed to implement each 'page':
  113. MS Sans Serif
  114.  To create an instance of the tab control, you must declare a page array, a TabData structure, and create the picture boxes and page controls. You then need only call DefineControl() and pass these elements as parameters.
  115. MS Sans Serif
  116.     Form_Load
  117. caption
  118. InitializeTabs6
  119. folder
  120. DefineFoldersE
  121. Ftabsl
  122. TabPic
  123. Form_Resize(
  124. windowstate
  125.     TabResizey
  126. tabbox_ClickU
  127. FolderClick#
  128. Button
  129. tabbox_MouseDown
  130. Shift
  131. tabbox_Paint
  132. DrawText
  133. control
  134. TabData
  135. captions
  136. Frames
  137. PicBox
  138. FrameMSQ
  139. Frame3Dr
  140. Panel3D@
  141. tabbox.
  142. invbox
  143. Parent
  144. activeW
  145. pages
  146. DefinePages
  147.     PageClick
  148. numpages
  149. orient
  150. DefineControl
  151. mother
  152. left/
  153. boxes
  154. tLeft
  155. tTopu
  156. TabClick
  157. visible
  158. Heightb
  159. picture1
  160. tabsup
  161. invbox_Click
  162. PicBox_Click
  163. Index
  164. tabbox_MouseUpg
  165. l_ClickK
  166. Form_KeyDown
  167. KeyCode
  168. Form_KeyPress
  169. KeyAscii
  170. scalewidth
  171. screen
  172. TwipsPerPixelX
  173. scaleheight
  174. TwipsPerPixelY
  175. Width
  176. tControlWidth
  177. tControlHeight.
  178. Form_Load
  179. Form_Resize
  180. this draws 3d lines on the formy
  181. InitializeTabs
  182. set to highest index (total-1)
  183. ===create an array of controls 
  184. ===fill in the fields of the struct
  185. number of tabs
  186. initial focusa
  187. number of tabs in each row
  188. 0 = up, 1 = down
  189. vb won't always reinitialize these to 00
  190. tabbox_MouseUp
  191. tabbox_Paint
  192.