Resizable Window wwwwwwwwwwwwwwp wwwwwwwwwwwwwwp wwwwwwwwwwwwwwp wwwwwwwwwwwwwwp wwwwwwwwwwwwwwp wwwwwwwwwwwwwwp wwwwwwwwwwwwwwp wwwwwwwwwwwwwwp wwwwwwwwwwwwwwp wwwwwwwwwwwwwwp wwwwwwwwwwwwwwp wwwwwwwwwwwwwwp wwwwwwwwwwwwwp wwwwwwwwwwwwwp wwwwwwwwwwwwwwp wwwwwwwwwwwwwwp wwwwwwwwwwwwwwp wwwwwwwwwwwwwwp wwwwwwwwwwwwwwp wwwwwwwwwwwwwwp wwwwwwwwwwwwwwp wwwwwwwwwwwwwwp wwwwwwwwwwwwwwp wwwwwwwwwwwwwwp wwwwwwwwwwwwwwp wwwwwwwwwwwwwp wwwwwwwwwwwwwp Form21 tabbox invbox SSFrame 3d Containers MS Sans Serif V. A note on 3d effects. MS Sans Serif SSFrame Dummy MS Sans Serif MS Sans Serif SSFrame Intro MS Sans Serif SSFrame Step 1 MS Sans Serif I. Creating the controls. MS Sans Serif SSFrame Step 2 MS Sans Serif II. Adding the code. MS Sans Serif SSFrame Step 3 MS Sans Serif III. Set additional properties. MS Sans Serif SSFrame Step 4 MS Sans Serif IV. That's it! MS Sans Serif zfile &File zedit &Edit &Options Dummy Dummy Dummy Form_Load Initialize numpages PicBox active orientY tabsup tLeft< DefineControl tabbox invboxP control TabData Form_Resize: windowstate TabResize tabbox_Click tabbox_MouseUp Button^ Shift[ TabClick tabbox_Paint DrawTextu Visible PageResizeJ minheight minwidthA f3d_DragDrop Index Source invbox_Click zedit_Click zfile_Clickg zopt_Click paint tabbox_Resize l_Click leftO tightening resizing5 Width Height LoadText+ specify larger sizes ResizeTextboxes z1_Click t_Change SendMessageq EM_SETRECT rightc screen TwipsPerPixelX bottom TwipsPerPixelY WM_USER wParam- lParam EM_GETRECT dummy added check> alignment wrapsm SomeX pages still contain labels place container panel modify DrawTabs routine shading lines match Form_Load Form_Resize Initialize set to highest index (total-1) ===create an array of controls ===fill in the fields of the struct number of tabs initial focusa number of tabs in each row 0 = up, 1 = down for resizable forms, set a minimum for a page h,wa LoadText This sample shows how to create a tab control on a sizable Form. The initial width of the window and the tab control is still determined by the design-time size of Page(0), but if the window is resized, the tab control and each of the pages will be resized to fit the window. The window can be maximized and minimized. If the window is resized too small to allow display of the tab captions, the window size is reset to a minimum size. The default minimum width is the width needed for the display of the captions; the default minimum height is set (in TabResize()) to tab control height + 20 pixels. You may specify larger sizes by setting tb.minwidth and tb.minheight before calling DefineControl(). The tab control will resize the tabs and pages(), but it does not resize the controls on each page(). You must do this in response to one of the resize events. This sample uses textboxes for the display of text so that a scrolling functionality can be enabled as needed, and it resizes them in response to form_resize. The tabbox and invbox are exactly the same as in the first sample. This sample uses 3D frames instead of pictureboxes for the pages, and a single textbox in place of multiple labels on each page(). The 3d frames are named f3d(0) - f3d(6). The textboxes are named t(0) - t(6). Some of the pages still contain some labels. There are 7 pages on this sample, which produces one blank (unused) tab. To create a sizable window, set the borderstyle = 2. Create controls on each page with an eye toward how they will be affected by resizing. A dummy menu was added to the form to check the alignment of the tabs when the menu wraps. The solution to this problem was sloppy (it simply resizes the form again) and if there is no better solution that can be implemented from within VB, there are at least 2 possible workarounds. 1. Use a message subclass control to intercept WM_GETMINMAXINFO. 2. Set the tb.minwidth to a size that accomodates all the menu text. The code is similar to the code in the first sample with a few additions. 1. Add the following lines to the general declarations section: Dim page() As Control Dim tb As TabData 2. Add the following lines to the form_load procedure (note that in the samples this code is actually in the procedure 'Initialize()' called from form_load): Redim page(0 To 6) For i = 0 to 6: Set page(i) = f3d(i): Next tb.num = 6 tb.active = 0 tb.cols = 4 tb.orient = 0 (Note the following lines may be necessary if you have multiple instances of the tab control and the tb.structure is not being properly initialized to 0. Note also that all 4 must be 0 or it will be assumed you are creating a 'nonaligned' tab and the form will not be fitted to the tab. See sample 3 for an example of this type.) tb.left = 0 tb.top = 0 tb.width = 0 tb.height = 0 (the following lines are optional but should be used if you have a menu and wish to prevent wrapping) tb.minwidth = (some value) tb.minheight = (some value) DefineControl Me, tabbox, invbox, page(), tb 3. Add the following line to the form_resize event: If windowstate <> 1 then TabResize Me, -1, -1, tabbox, invbox, page(), tb 4. Add the following to tabbox_MouseUp: TabClick Button, X, Y, tabbox, page(), tb 5. Add the following to tabbox_Paint: DrawText tabbox, page(), tb Size page(0) to the size to which you wish all the other page()s and the tab control to be initialized when the form is loaded. Again, set the Font properties of the tabbox to those you wish the captions to have. Add the following line to form_load before calling DefineControl() if you wish the tabs to be at the bottom of the pages: tb.orient = 1 Add the following line to form_KeyDown if you wish to toggle through the pages: If KeyCode = (some value) Then PageNext If KeyCode = (some value) Then PagePrev The resizing of the window is handled by TabResize(). It is not a good idea to manipulate the form size from within this event and the routine uses flags to keep from redrawing the tabs and text more than once. The refresh rate is nontheless poor, and as mentioned previously, it must resize the form twice if a menu wraps. I'm sure this section could be improved, but I just haven't hit on it. All in all, the resizable window is not the optimal use for this control. That's it. The final sample includes some controls to manipulate the tabs at runtime. The tab control assumes one pixel shading outline in white and dark grey around the inside of the container in which it sits. The first sample uses line controls to shade the form's borders for convenience. This sample omitted the shading to avoid having to write code to move and resize the line controls. If you place the control in a 3d container such as a 3d panel, you may need to modify the DrawTabs routine to get the shading lines to match up. The third sample uses a 3d panel, but the size of the tab control must be specified at designtime and it is not resizable. ResizeTextboxes this just buts the text in a little off the scroll bar tabbox_MouseUp tabbox_Paint call DrawText from tabbox_Paint=========