|
|
|
|
OverwriteHandler - A class for handling overwrite mode
|
Total Hit (2329) |
«Code LangId=1»'---------------------------------------------------------
' OverwriteHandler class
'
' you can associate this class to a form, using the
' Form property, and all the textbox controls in the
' form will support insert/overwrite mode switching
'
' Usage: Dim ov As New Overwrite
....Read More |
Rating
|
|
|
|
|
IsNullString - Check whether a string contains white-spaces
|
Total Hit (2093) |
«Code LangId=1»
' Return True is a string is made only of spaces, tabs, and Null characters.
' This function is especially useful to test whether fixed-length strings
' are initialized.
Function IsNullString(Text As String) As Boolean
Dim i As Long
For i = 1 To Len(Text)
Se
....Read More |
Rating
|
|
|
|
InstrWord - Search a whole word
|
Total Hit (1649) |
«Code LangId=1»' Return the next occurrence of a whole word
Function InstrWord(start, Text, search, compareMethod) As Long
Dim index As Long
Dim charcode As Integer
' assume the search fails
InstrWord = 0
index = start - 1
Do
' search the next
....Read More |
Rating
|
|
|
Display the dialog to configure a port
|
Total Hit (3007) |
The ConfigurePort API function lets you programmatically bring up the system dialog box for configuring a COM or LPT port. The function returns a non-zero value if successful (that is, the dialog appears). Here is the Declare of this function, and an example of its usage:
«Code LangId=1»
Privat
....Read More |
Rating
|
|
|
Undocumented dialog box to change screen saver's password
|
Total Hit (2087) |
When you write a screen saver in C and SDK you can use a static library (SCRNSAVE.LIB) that allows you to create custom dialogs to change and request the password. In VB you can't access this library, but if you don't want to create your forms to replace the custom dialogs, you can use a couple of u
....Read More |
Rating
|
|
|
Retrieving Bitmap properties
|
Total Hit (4222) |
The Picture box control does not directly expose any property that returns information on the bitmap currently loaded. You can retrieve this information by calling the GetObject API function, passing it the handle of the bitmap. This value is the Handle property of the IPictureDisp object (which is
....Read More |
Rating
|
|
|
Load items faster in the TreeView and ListView controls
|
Total Hit (2691) |
There is an easy, but under-utilized, technique for loading many nodes in a TreeView control (or ListItems in a ListView control) that is faster than the standard technique. Consider this loop:
«Code LangId=1»
For i = 1 To 5000
TreeView1.Nodes.Add , , , "Node " & i
Next
«/Code»
Instea
....Read More |
Rating
|
|
|
Create ListBox controls with companion priority buttons
|
Total Hit (2897) |
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
|
|
|
Scan all the items in a multi-dimensional array with only one loop
|
Total Hit (2482) |
It seems that you need two nested For loops to iterate over all the elements of a 2-dimensional array, and three loops for a 3-dimensional array, and so on. However, the For Each loop offers you a neat and concise solution, as this code proves:
«Code LangId=1»
' a 2-dimensional array of Strings
....Read More |
Rating
|
|
|
Count distinct characters in a string
|
Total Hit (3923) |
When you need to count how many occurrences of a given character are in a string, you might be tempted to go along the "traditional" Visual Basic way:
«Code LangId=1»
' count spaces
For i = 1 To Len(text)
If Mid$(text, i, 1) = " " Then count = count + 1
Next
«/Code»
Ev
....Read More |
Rating
|
|
|
Undocumented Shell Path APIs (Combining and Constructing Path).
|
Total Hit (3257) |
Way back when Microsoft released Internet Explorer 4.0, they bundled with it a number of upgrades to the operating system including a new DLL called SHLWAPI.DLL (Shell Lightweight Utility APIs). That DLL provided programmers with some useful path manipulation functions (amongst other things), but ob
....Read More |
Rating
|
|
|
Mapping network share as a mapped drive using API
|
Total Hit (3895) |
«code LangId=1»Option Explicit
Private Declare Function WNetAddConnection Lib "mpr.dll" Alias "WNetAddConnectionA" ( _
ByVal lpszNetPath As String, _
ByVal lpszPassword As String, _
ByVal lpszLocalName As String) As Long
Private Sub MapDrive(share_name As String, Optional drive_
....Read More |
Rating
|
|
|
|
|
FillFlexGrid - Routine to fill flexgrid from ADO recordset
|
Total Hit (3710) |
The following routine takes 2 arguments, ADO recordset and flexgrid which you want to fill.
«code LangId=1»
Sub FillFlexgrid(rst As ADODB.Recordset, msfGrid As MSFlexGrid)
Dim cln As Field
With msfGrid
.Rows = 2
.Cols = rst.Fields.Count
'get the number of gri
....Read More |
Rating
|
|
|
How to use AnimateWindow API to animate form on Load/Unload events
|
Total Hit (7188) |
The AnimateWindow function enables you to produce special effects when showing or hiding windows. There are three types of animation: roll, slide, and alpha-blended fade.
«b»Step-By-Step Example«/b»
- Create a standard exe project
- Add a new form called Form2 (Form1 is added by default)
- A
....Read More |
Rating
|
|
|
Path API Demo (BeginPath, EndPath, AbortPath)
|
Total Hit (4359) |
This is very simple demo to demonstrate how to use path API in grawing.
To learn more about path Please visit following URL
«a href='http://msdn.microsoft.com/library/en-us/gdi/paths_8acz.asp'»http://msdn.microsoft.com/library/en-us/gdi/paths_8acz.asp«/a»
«b»To implement Quick Demo, Copy/Past
....Read More |
Rating
|
|
|
Search for values in a FlexGrid control and sort it by columns
|
Total Hit (2407) |
To search for values, simply loop through the grid looking for the target value. Use the TopRow property to ensure that the row is visible after you find it.
To sort by columns, use the MouseRow property to see if the user clicked the control's column header. Use MouseCol to see which column was
....Read More |
Rating
|
|
|
How to Toggle a Checkbox in a ListView
|
Total Hit (761) |
The routines here set and retrieve checked ListItems from a ListView control in report view.
Basically, here we are again using the enhanced comctl32.dll functionality, this time using the LVIS_STATEIMAGEMASK and LVIF_STATE to toggle the bits at &H1000 and &H2000. In addition, by using the messag
....Read More |
Rating
|
|
|
Changing a VB Toolbar to a Rebar-Style Toolbar
|
Total Hit (1015) |
Here's a quick routine to set a standard VB toolbar to a IE-style Rebar style control (aka 'coolbar') for IE4 Active Desktop users. The illustration shows the original and flattened style for the same toolbar.
Place a toolbar with images (and optionally text), and add a placeholder. Set the place
....Read More |
Rating
|
|
|
|
Create an API hFont from a VB StdFont object
|
Total Hit (2378) |
If you are working with API based controls you will find that to set fonts you need a GDI hFont handle to the font. The StdFont object does not directly supply you with this handle. Although it is possible to cast the StdFont object as an IFont object, which does have a hFont handle property, you st
....Read More |
Rating
|
|
|
Get an RGB Colour from an OLE_COLOR
|
Total Hit (1611) |
Sometimes you need to know the Red, Green and Blue values of a Visual Basic/COM OLE_COLOR, particularly if you are going to use the colour in an API function. This tip shows you how to correctly convert an OLE_COLOR type to a RGB value using the OleTranslateColor API call exposed by OLEPRO32.DLL. It
....Read More |
Rating
|
|
|
Multi-Threaded VB Using ActiveX EXEs
|
Total Hit (2658) |
Ever since VB5 service pack 2, there has been the possibility of running VB applications multi-threaded by using ActiveX EXEs. However, if you try and research this you will find it is fiddly to get working. This article presents a method which makes running operations asynchronously really easy.
....Read More |
Rating
|
|