|
|
|
Changing Display Settings on the Fly
|
Total Hit (4000) |
«Code LangId=1»'Place this code in a Module:
'Place this code in a Module:
Option Explicit
Private Declare Function lstrcpy Lib "kernel32" Alias "lstrcpyA" (lpString1 As _
Any, lpString2 As Any) As Long
Const CCHDEVICENAME = 32
Const CCHFORMNAME = 32
Private Type DEVMODE
dmDevi
....Read More |
Rating
|
|
|
|
MakeModalForm - Make a modeless form modal
|
Total Hit (1693) |
«Code LangId=1»' make a modeless form modal
'
' this procedure should be called by passing TRUE
' in the 2nd argument to make the form modal, and
' called again with FALSE in the 2nd argument when
' the form is being unloaded.
'
' Private Sub Form_Load()
' MakeModalForm Me, True
' End Su
....Read More |
Rating
|
|
|
DrawBorder - Draw a raised/bump/etched/sunken border
|
Total Hit (2466) |
«Code LangId=1»Option Explicit
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Enum mbBorderTypeConstants
mbRaised = 0
mbSunken = 1
mbEtched = 2
mbBump = 3
End Enum
'draw a raised/bump/etched/sunken border at
....Read More |
Rating
|
|
|
ReplaceWord - Replace whole words
|
Total Hit (1802) |
«Code LangId=1»' Replace a whole word
Function ReplaceWord(Source As String, Find As String, ReplaceStr As String, _
Optional ByVal Start As Long = 1, Optional Count As Long = -1, _
Optional Compare As VbCompareMethod = vbBinaryCompare) As String
Dim findLen As Long
Dim rep
....Read More |
Rating
|
|
|
|
HiWord - The most significant word in a Long value
|
Total Hit (2232) |
«Code LangId=1»
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (dest As _
Any, source As Any, ByVal bytes As Long)
' Return the high word of a Long value.
Function HiWord(ByVal value As Long) As Integer
CopyMemory HiWord, ByVal VarPtr(value) + 2, 2
End Function
....Read More |
Rating
|
|
|
IsValidEmail - Validate an email address
|
Total Hit (2957) |
«Code LangId=1»' Validates an email address
' Returns True if valid, False if invalid
'
' Example:
' If IsValidEmail(Value:="x@y.com", MaxLength:=255, IsRequired:=True) then ...
Function IsValidEmail(ByRef Value As String, Optional ByVal MaxLength As Long = _
255, Optional ByVal IsRequi
....Read More |
Rating
|
|
|
Find out the Windows version a program require
|
Total Hit (3785) |
Not all programs may run on all the Windows platforms. Often programs require at least a certain version of Windows. In most cases, this is due to the lack of specific functions in the SDK.
Anyway, to detect yourself whether a given EXE file can run under the current version of Windows (without r
....Read More |
Rating
|
|
|
Retrieve the size of an AVI movie
|
Total Hit (3993) |
To retrieve the original size of an AVI file that you've already opened with the mciSendString API function you can use this command
«Code LangId=1»
Dim RetString As String
RetString = Space$(256)
CommandString = "where AVIFile destination"
RetVal = mciSendString(CommandString, RetString, Len
....Read More |
Rating
|
|
|
Clear a MaskEditBox control without raising error
|
Total Hit (3168) |
You can't clear the contents of a MaskEdBox control by setting the Text property to a null string if the MaskEdBox's Mask property contains delimiter. In fact, you must include those separators in the value you assign to the Text property, otherwise you get Error 380 - Invalid property value.
A s
....Read More |
Rating
|
|
|
|
Use a ListBox as a poor man's grid
|
Total Hit (2273) |
You can easily create columns of data in a ListBox control by setting its tab stop at appropriate positions. This way, you can use a ListBox control as a sort of grid control with (very) limited functionality, but without using third-party controls.
You can set ListBox's tab stop by sending the
....Read More |
Rating
|
|
|
Extended user interface for combo boxes
|
Total Hit (2975) |
Apart from the different kind of combo boxes you can obtain by manipulating the Style property, another feature is made available by Windows when dealing with combo box controls, the so-called extended user interface. With standard combo box controls, the list portion stays invisible until the user
....Read More |
Rating
|
|
|
Fast Copy of Properties between Controls
|
Total Hit (2444) |
You probably already know that if you select multiple controls on a form you can use the Property Window to change one of their common property in one single operation. However, here is a trick that is likely to be ignored by most programmer (included me, until recently).
If you want to copy a n
....Read More |
Rating
|
|
|
High-precision timing with the QueryPerformanceCounter API function
|
Total Hit (4943) |
While VB Timer functions is sufficiently precise for most tasks, it doesn't provide the highest possible resolution most modern computer can provide. If your hardware supports high-resolution counters, you can do a much better job with a pair of API functions:
«Code LangId=1»
Private Type LARGE_
....Read More |
Rating
|
|
|
Polymorphic array procedures
|
Total Hit (2361) |
You can create "polymorphic" routines that work with any type of array (except arrays of fixed-length strings, or UDTs) by using Variant parameters. Take for example the following code:
«Code LangId=1»
Function Sum(arr As Variant) As Variant
Dim i As Long
For i = LBound(arr) To UBound(
....Read More |
Rating
|
|
|
How to display shortcut PopupMenu generated at runtime ?
|
Total Hit (5437) |
This article will show you simple demo of creating and displaying popup menu using TrackPopupMenu api. You will learn the following items from this sample code.
«UL»«LI»How to create PopupMenu, MenuItems and Submenu at runtime using CreatePopupMenu and AppendMenu APIs
«LI»How to display popupmen
....Read More |
Rating
|
|
|
Drawing Chord using API
|
Total Hit (2560) |
«b»About Chords«/b»
A chord is a region bounded by the intersection of an ellipse and a line segment called a secant. The following illustration shows a chord drawn by using the Chord function.
When calling Chord, an application supplies the coordinates of the upper-left and lower-right corne
....Read More |
Rating
|
|
|
Transparent form (glass effect)
|
Total Hit (2602) |
This example will show you how to create a transparent form.
«b»Step-By-step example«/b»
- Create a standard exe project
- Add the following code in form1
«code LangId=1»Option Explicit
Private Declare Function CreateRectRgn Lib "gdi32" ( _
ByVal X1 As Long, ByVal Y1 As Long, ByVal
....Read More |
Rating
|
|
|
Programmatically Select a Node in TreeView.
|
Total Hit (3461) |
This is very easy but tricky. By default HideSelection property of treeview is true. So it confuses many programmer. When you use Treeview.Selected=True and HideSelection is True then it wont show the selection even though node is selected. Check the following example for that
....Read More |
Rating
|
|
|
|
Subclassing Listview Scrollbar Messages
|
Total Hit (944) |
When it is necessary for your application to maintain synchronization between two or more Listview controls - or two or more List boxes for that matter - as the user interacts with the primary ListView's control's scrollbar, subclassing must be used in order to determine the user's interaction refle
....Read More |
Rating
|
|
|
Button ListBar Control
|
Total Hit (1423) |
The Button ListBar control provides an emulation of the ListBar provided in the Windows Add/Remove Programs window. Under XP it uses the UxTheme API to draw parts of the toolbar, and degrades to use standard GDI drawing calls when used on earlier OS versions.
....Read More |
Rating
|
|
|
ComCtl32 Header Control
|
Total Hit (794) |
This article provides a fully-featured Header Control directly from COMCTL32.DLL. The latest version uniquely provides support for Outlook-style drag-drop grouping of columns as well as in place column filtering.
It is a good building block for generating your own controls. Check out the S-Grid
....Read More |
Rating
|
|
|
Tile a Bitmap Into a TextBox Background
|
Total Hit (2955) |
This sample presents a small class that allows you to tile a bitmap into the background of a TextBox. Note that the technique only works on multi-line text boxes, as the drawing of single-line TextBoxes is done in a different way and cannot be easily overridden in code.
....Read More |
Rating
|
|
|
Compressing and Expanding with the Freeware zLib.DLL
|
Total Hit (1162) |
This project from Benjamin Dowse (bendowse@dingoblue.net.au) provides a reusable DLL which allows you to compress and decompress byte arrays and strings. You can compress data in memory, or using file IO in Visual Basic you can also compress files.
|
Rating
|
|
|
Tutorial: Setting data transfer options
|
Total Hit (3497) |
In this tutorial you will learn how to define the method of the data connection establishment and how to specify the data transfer type. For each of these options the CFtpClient class provides separate properties: PassiveMode and TransferMode respectively.
....Read More |
Rating
|
|