|
|
|
Animate How Forms are Displayed and Hidden,
|
Total Hit (2987) |
Windows 98 and later provides the ability to slide your form in or out of view. See how to tile an image across the entire background of your form.
|
Rating
|
|
|
Create a Scrollable Form
|
Total Hit (2831) |
Add more controls than can fit on the visible portion of a form and scroll though the form moving the controls into and out of view.
|
Rating
|
|
|
Dynamically Add Controls and Create a Scrollable Form
|
Total Hit (2811) |
Dynamically add and remove controls at runtime using the controls collection, add controls to any container control and not the form itself, detect events from the new controls and create a scrollable form.
|
Rating
|
|
|
Move A Form Without A Title Bar/Resize Controls
|
Total Hit (3048) |
Method one retrieves the X and Y coordinates of the cursor and then moves the form to that locatoin. Method two calls ReleaseCapture and SendMessage to move the form.
|
Rating
|
|
|
Change a Control's Style / Owner Drawn Controls
|
Total Hit (2760) |
See how to change the font of individual ListBox items by changing the Style of the control. Creating Owner Drawn controls lets you customize VB's intrinsic controls to look the way you want.
|
Rating
|
|
|
Create a Dockable, AutoHide AppBar
|
Total Hit (4155) |
The Window's taskbar and IE4+ toolbars are called Appbars. Create an Appbar which can float or be docked to a screen edge and can be set to AutoHide.
|
Rating
|
|
|
Dock Your Forms
|
Total Hit (2769) |
Create child forms that you can dock to the edges of your main form. Child forms used are Toolbar type windows. See how to create toolbar and ToolTip windows.
|
Rating
|
|
|
|
|
Add an horizontal scrollbar to a ListBox control
|
Total Hit (4867) |
By default, VB ListBox controls don't display an horizontal scrollbar, so if the items you add to the controls are wider than the control's Width, the end user isn't able to read them in their entirety.
Adding an horizontal scrollbar to a ListBox control is easy, however. You only have to increas
....Read More |
Rating
|
|
|
Add size grips to a form
|
Total Hit (2885) |
There are two simple ways to add the so-called size-grips to the bottom-right corner of a form. The first method is to add a StatusBar control, which includes a size-grip of its own. The second method is to add a multiline TextBox control, set its ScrollBars property to 3-Both and add some resizing
....Read More |
Rating
|
|
|
Append a string to a textbox quickly and without flickering
|
Total Hit (2998) |
The usual way to append text to a TextBox or a RichTextBox control is to concatenate the current contents with the new string:
«Code LangId=1»
Text1.Text = Text1.Text & newString
«/Code»
Here is a different approach, which is slightly faster and causes less flickering: «Code LangId=1»
Text1
....Read More |
Rating
|
|
|
Avoid beeps on forms without a default button
|
Total Hit (4072) |
If a form contains one CommandButton control whose Default property is set to True, the Enter key activates the CommandButton. If the form doesn't contain any default CommandButton control, however, pressing the Enter key when the focus is inside a TextBox control (and a few other controls as well)
....Read More |
Rating
|
|
|
Bind a group of OptionButtons to a Data control
|
Total Hit (2928) |
You can't directly bind a group of OptionButton controls to a Data control, RDO Data control or ADO Data control. However, you can work around this limitation by adding an hidden TextBox control and add a few lines of code:
«Code LangId=1»
Private Sub optRadioButton_Click(Index As Integer)
....Read More |
Rating
|
|
|
Catch user's attention with a flashing caption
|
Total Hit (3382) |
If you want to draw user's attention but you don't want to force the form to move to the foreground, you can simply flash its caption (and its icon in the taskbar), using the FlashWindow API function. To do so, just add a Timer with a suitable Interval property (for example, 1000 milliseconds) and t
....Read More |
Rating
|
|
|
Caution when moving or resizing forms
|
Total Hit (2847) |
Any action that affects a form's size or position should be inhibited when the form is minimized or maximized, because this causes a runtime error 384. Always double check your code to ensure that when a form is moved or resized – using a Move method or acting on a form's Left, Top, Width or Height
....Read More |
Rating
|
|
|
Change a CheckBox or OptionButton style at runtime
|
Total Hit (4346) |
Visual Basic doesn't let you change the Style property of a CheckBox or an OptionButton control at runtime. However, you can easily do it by manipulating the control's style bit, with the SetWindowLong API function. Here's a routine that does the trick:
Using the routine is straightforward. For
....Read More |
Rating
|
|
|
Change caret size and blink rate
|
Total Hit (4096) |
You can alter the size of the caret (this is the name of the cursor within text boxes, not to be confused with the mouse cursor), for instance to ease visibility on notebook computers, or to signal that the text box is in overwrite mode. All you need is a couple of API functions:
«Code LangId=1»
....Read More |
Rating
|
|
|
Change the DataSource at runtime
|
Total Hit (3838) |
Visual Basic 6 is the first VB version that lets you programmatically change the DataSource property at runtime, for example to point to another ADO Data control or another ADO Recordset.
However, when you assign the new DataSource property VB immediately checks that the DataField and DataMember
....Read More |
Rating
|
|
|
Change the ShowInTaskbar property at runtime
|
Total Hit (4491) |
The ShowInTaskbar property lets you decide whether a form is visible in Windows taskbar or not. However, this property is read-only at runtime, so it seems that you can't change this setting while the program is running. Luckly, you just need to change the window's style, using a pair of API functio
....Read More |
Rating
|
|
|
Change the width of the dropdown portion of a ComboBox
|
Total Hit (3393) |
The ComboBox control doesn't expose any property that lets you to control the width of its list area, but this can be easily accomplished by sending it the CB_SETDROPPEDWIDTH message, and passing the new length in pixel in wParam:
«Code LangId=1»
Private Declare Function SendMessage Lib "user32"
....Read More |
Rating
|
|
|
Check whether a form is loaded
|
Total Hit (2844) |
You can load several instances of the same form, but VB doesn't let you determine how many forms of a given class are currently loaded. You can work around this flaw by iterating over the Forms collection:
«Code LangId=1»
' Return the number of instances of a form
' that are currently loaded
....Read More |
Rating
|
|
|
Clone a Font object
|
Total Hit (2949) |
When you want to assign a control's Font to another control, the first obvious way is to assign the Font property directly, as in:
«Code LangId=1»
Set Text2.Font = Text1.Font
«/Code»
but in most cases this approach doesn't really work, because it assigns a reference to the same font to both c
....Read More |
Rating
|
|
|
Correctly set scrollbars' width and height
|
Total Hit (3345) |
You should always modify a vertical scrollbar's width and a horizontal scrollbar's height to conform to the display resolution. You can learn the suggested size (in pixels) using the GetSystemMetrics API function, then convert it to twips, and rezise all the scrollbars on your forms accordingly. The
....Read More |
Rating
|
|
|
Create a owner form with API functions
|
Total Hit (3109) |
Starting with VB5, the Show method supports a second optional argument, that lets you specify which form owns the form that is about to be displayed:
«Code LangId=1»
Form2.Show , Me
«/Code»
A owned form is always displayed in front of its owner, and when the owner is unloaded, VB automatical
....Read More |
Rating
|
|
|
Create arrowed buttons without icons
|
Total Hit (4073) |
You don't need to use icons or bitmap to create buttons with arrows on them. In fact, you just have to select the "Windings" font, set a suitable font size (e.g. 12 or 14 points), and then enter one of these characters:
«Code LangId=1»
Line arrows
Chr$(223) Left Arrow
Chr$(224) Right Arrow
Chr
....Read More |
Rating
|
|
|
Create colorful Command Buttons
|
Total Hit (4318) |
The VB CommandButton control supports neither the ForeColor nor the BackColor properties. If you want to create colorful buttons without resorting to 3rd party controls, you can use an OptionButton control with the Style property set to 1-Graphical. Such OptionButton controls appear to be very simil
....Read More |
Rating
|
|
|
Create ListBox controls with companion priority buttons
|
Total Hit (2898) |
You can easily create a ListBox control similar to the one found in the VB's Project References dialog box, that lets you select multiple items and move them up and down using two companion buttons.
First of all, create a ListBox control (say, List1) and two CommandButton controls to its right, n
....Read More |
Rating
|
|