|
|
|
|
|
|
|
GetFileIcon - Retrieve the icon associated to a file
|
Total Hit (5050) |
«Code LangId=1»Private Const MAX_PATH = 260
Private Type SHFILEINFO
hIcon As Long
iIcon As Long
dwAttributes As Long
szDisplayName As String * MAX_PATH
szTypeName As String * 80
End Type
Private Declare Function SHGetFileInfo Lib "Shell32" Alias "SHGetFileInfoA" _
....Read More |
Rating
|
|
|
AddBackslash - Append a backslash to a path if needed
|
Total Hit (3164) |
«Code LangId=1»' Append a backslash (or any character) at the end of a path
' if it isn't there already
Function AddBackslash(Path As String, Optional Char As String = "\") As String
If Right$(Path, 1) <> Char Then
AddBackslash = Path & Char
Else
AddBackslash = Path
....Read More |
Rating
|
|
|
|
RotateRightI - Rotate an Integer to the right
|
Total Hit (1634) |
«Code LangId=1»' Rotate an Integer to the right the specified number of times
'
' NOTE: requires Power2()
Function RotateRightI(ByVal value As Integer, ByVal times As Long) As Integer
Dim i As Long, signBits As Integer
' no need to rotate more times than required
times = ti
....Read More |
Rating
|
|
|
Setting authentication across different domains
|
Total Hit (1684) |
COM doesn't have a built in security mechanism, but relies on Windows authentication services (Security Service Providers). When you access a resource or invoke a method in a remote DCOM server (or MTS package / COM+ Application), security checks cannot be performed in the standard way if the client
....Read More |
Rating
|
|
|
Detect when the application gets or loses the input focus
|
Total Hit (3474) |
VB forms exposes the Activate and Deactivate events, which fire when the form gets and loses the focus because the user has clicked on another form of the same application. However, VB doesn't fire any event when the user clicks on a form that belongs to another Windows application. In some cases th
....Read More |
Rating
|
|
|
Create and delete DSN at runtime
|
Total Hit (10634) |
If you're developing a VB database application, you're probably using a DSN (data source name) because it makes the access to your database file easier. Of course, when you distribuite your application, you must create the DSN.
There are some installation programs that offers the possibility to
....Read More |
Rating
|
|
|
Hide the Automation Manager
|
Total Hit (3431) |
If you haven't switched to DCOM yet, and still use Remote OLE Automation, you must launch the Automation Manager program on the server machine, in order to let the server respond to requests coming from client workstations.
The Automation Manager displays a visible window at launch time, which t
....Read More |
Rating
|
|
|
Determine the number of visible items in a ListView control
|
Total Hit (4507) |
Microsoft "forgot" to provide the ListView control with the GetVisibleCount property, as it did, for example, with the TreeView control. However, getting this information is as easy as sending a message to the control:
«Code LangId=1»
Private Const LVM_FIRST = &H1000
Private Const LVM_GETCOUNT
....Read More |
Rating
|
|
|
Get full control on the text typed in a ListView's item
|
Total Hit (3520) |
The ListView control exposes the AfterLabelEdit event to let the programmer validate the text entered in a ListItem, but there is no way to trap keys as they are typed by the user. This prevents you from discarding unwanted characters while the user types them.
You can work around this problem by
....Read More |
Rating
|
|
|
Optimized Paint procedures with subclassing
|
Total Hit (2589) |
The Paint event doesn't provide with information about which region of the form must be actually repainted, and therefore forces the programmer to repaint the entire client area, which in some cases can be a time-consuming operation.
You can determine the smallest rectangle that needs to be updat
....Read More |
Rating
|
|
|
|
Change caret size and blink rate
|
Total Hit (4059) |
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
|
|
|
Use integer division operator
|
Total Hit (2996) |
Use "\" instead of "/" when performing divisions between Integers. The "/" operator returns a Single value, therefore the seemingly efficient line
«Code LangId=1»
C% = A% / B%
«/Code»
actually requires three implicit conversions, two for converting the operands from Integer to Single (to pre
....Read More |
Rating
|
|
|
Property Procedures in BAS modules
|
Total Hit (3600) |
Visual Basic supports Property procedures to implement properties in your own CLS and FRM modules. However, it turns out that you can use Property procedures even within BAS code modules.
How can this improve your programming skills? In many a way, as I will demonstrate. Say your program include
....Read More |
Rating
|
|
|
How to load BMP file into memory and perform rotation on it ?
|
Total Hit (8984) |
Bitmap rotation is a graphic effect that Visual Basic does not natively offer. This article shows how to rotate a given image in 90-degree increments. It allows you to rotate any image 0, 90, 180 or 270 degrees. With a little work, the code can be modified to rotate to any angle, but that is beyond
....Read More |
Rating
|
|
|
How to retrive font name from font file.
|
Total Hit (3026) |
I tried so many places but never found any simple code which retrive font name. Because to set font for drawing/printing we have to set font name and ususally font name is different than file name.
|
Rating
|
|
|
Print a Picture to Fit a Page!
|
Total Hit (2999) |
Module
«Code LangId=1» Option Explicit
Public Sub PrintPictureToFitPage(Pic As Picture)
Dim PicRatio As Double
Dim printerWidth As Double
Dim printerHeight As Double
Dim printerRatio As Double
Dim printerPicWidth As Double
Dim printerPicHeight As Double
'
....Read More |
Rating
|
|
|
How to get a listview control to sort numbers correctly...
|
Total Hit (2449) |
This is one I discovered after banging my head against the wall for a few hours trying to get a list view control to sort numbers correctly. When trying to create a list view control in report mode that would allow a user to quickly sort by a text listing (in this case a column of state abbreviation
....Read More |
Rating
|
|
|
Binding a socket : Winsock API Test Bench sample application
|
Total Hit (3627) |
Today we will learn how to use the bind Winsock API function that allows to associate a local address with a socket. We'll modify the Winsock API TestBench sample application in order to give the user of the program to specify local host address and port number for a socket.
....Read More |
Rating
|
|
|
|
An API 'DriveExists' Routine
|
Total Hit (1294) |
For the API purest, here's a tiny function that simply returns True if a specified drive exists, or False if not.
Using GetLogicalDriveStrings, its a simple matter of retrieving all the available drives, then performing a case-insensitive Instr() against the result to determine if the passed drive
....Read More |
Rating
|
|
|
GetLastErr
|
Total Hit (1066) |
This code snippet returns any error codes from net related functions and system related functions.
Author: Elvio Serrao
|
Rating
|
|
|