|
|
|
|
|
 |
LOG Files
|
Total Hit (2858) |
«Code LangId=1»'Just place this in a Module and you can call it from anywhere in your program!
Sub SetLog(Message As String)
'This Sub writes to a LOG file.
Dim theFile As String, theMessage As String
theFile = App.Path & "\PRGMLOG.TXT"
theMessage = Message & vbCrLf
Open theFile For Append A
....Read More |
Rating
 |
|
|
|
 |
GetTreeViewNodeHandle - The handle of any node in a TreeView
|
Total Hit (3376) |
«Code LangId=1»
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal _
hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long
Private Const TVM_GETNEXTITEM = &H110A
Private Const TVGN_CARET = 9
' The handle of any node in a TreeVie
....Read More |
Rating
 |
|
 |
NodeNestingLevel - The nesting level of a TreeView's node
|
Total Hit (2409) |
«Code LangId=1»' Returns the nesting level of a TreeView's Node object
' (returns zero for root nodes.)
Function NodeNestingLevel(ByVal Node As Node) As Integer
Do Until (Node.Parent Is Nothing)
NodeNestingLevel = NodeNestingLevel + 1
Set Node = Node.Parent
Loop
End
....Read More |
Rating
 |
|
|
|
 |
RotateRight - Rotate a Long to the right
|
Total Hit (1888) |
«Code LangId=1»' Rotate a Long to the right the specified number of times
'
' NOTE: requires Power2()
Function RotateRight(ByVal value As Long, ByVal times As Long) As Long
Dim i As Long, signBits As Long
' no need to rotate more times than required
times = times Mod 32
....Read More |
Rating
 |
|
 |
Read and write File ODBC data sources
|
Total Hit (4444) |
A file DSN is nothing but a text file that contains all the parameters for an ODBC connection. To prove this, just go to the default directory that holds all File DSNs (this is the \Program Files\Common Files\ODBC\Data Sources directory on Windows's boot drive) and load any .dsn file into a text edi
....Read More |
Rating
 |
|
 |
Get the Command$ value from inside an ActiveX DLL
|
Total Hit (3268) |
At times you may need to access the command line passed to the application from within an ActiveX DLL. Unfortunately, when inside a DLL the Command$ function returns a null string, so you have to resort to some API trickery:
«Code LangId=1»
Private Declare Function GetCommandLine Lib "kernel32"
....Read More |
Rating
 |
|
 |
Default Properties tend to hide programming mistakes
|
Total Hit (2956) |
Visual Basic lets you create a default property or method by simply selecting the "(Default)" item in the combo box that appear if you click the Advanced button in the Procedure Attributes dialog box. (You can display this dialog from the Tools menu, or by right-clicking on a property name in the ri
....Read More |
Rating
 |
|
 |
Change a CheckBox or OptionButton style at runtime
|
Total Hit (4398) |
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
 |
|
 |
The "Assume No Aliasing" compiler option
|
Total Hit (3106) |
A procedure is said to contain aliased values if it can refer to the same memory addresses in two or more distinct ways. A typical example is the following procedure:
«Code LangId=1»
Dim g_GlobalVariable As Long
...
Sub ProcWithAliases(x As Long)
x = x + 1
g_GlobalVariable = g_GlobalV
....Read More |
Rating
 |
|
 |
Persistent breakpoints
|
Total Hit (3474) |
When you close a VB IDE session, VB saves the code but doesn't save the current set of breakpoints. If you need (non-conditional) breakpoints to persist among sessions, don't use the F9 key. Instead, use the following statement
«Code LangId=1»
Debug.Assert False
«/Code»
The above code will alwa
....Read More |
Rating
 |
|
|
|
 |
High quality image scaling
|
Total Hit (2879) |
Have you ever tried to use StretchBlt to resize image. Yep its easy to use with VB but if you use it without setting correct "Stretch Mode" it wont be a high quality image. To get high quality stretched image you can call SetStretchBltMode and set HALFTONE mode for highest quality image resizing. Fo
....Read More |
Rating
 |
|
|
|
|
 |
Determining Free Disk Space on a Fat32 (or NTFS) Drive
|
Total Hit (1891) |
The routine presented here will return the correct free and used disk sizes on volumes over 2 gigabytes as supported by the FAT32 partitions implemented in Windows95 OEM Service Pack 2, aka OSR2, and in Windows 98 where the Fat32 drive conversion has been made, or on NTFS partitions on NT4, Windows
....Read More |
Rating
 |
|
 |
Creating and using your own VC++ dlls
|
Total Hit (1044) |
Using the Windows API is a wonderful way to speed up your applications when they need to perform processor intensive tasks like graphics manipulation. However, the Windows API doesn’t always provide all the functionality you need for your application. Perhaps some 3rd party control does what you wan
....Read More |
Rating
 |
|
 |
Hue Luminance and Saturation (HLS) Model and Manipulating Colours
|
Total Hit (740) |
Normally in computers colours are described in terms of their Red, Green and Blue components. Whilst you can specify all displayable colours this way, it leaves something to be desired when it comes to picking a colour. For example, most people find it very difficult to determine what RGB values you
....Read More |
Rating
 |
|
 |
SGrid 2.0
|
Total Hit (3331) |
SGrid 2.0 is an updated version of the popular SGrid control which adds drag-drop hierarchical grouping, owner-draw cells and many other features. It has the same highly-optimised display code but is now further enhanced by much better sort, row insert and delete performance. It remains a great alte
....Read More |
Rating
 |
|
|