|
|
Clip lines to a text string
|
Total Hit (3040) |
Use the BeginPath, EndPath, and SelectClipPath API functions to set the
form's clipping path. Then draw the lines.
|
Rating
|
|
|
|
A better beep
|
Total Hit (4047) |
If you aren't satisfied with the standard Beep command (who is?) you can use the Beep API function instead, that lets you control both the frequency (in Hertz) and the duration (in milliseconds) of the beep. Note that you need an aliased Declare to avoid a name conflict with the VB command:
«Code
....Read More |
Rating
|
|
|
Never use the GetLastError API function
|
Total Hit (3872) |
If you heavily use API calls and strictly follow the SDK documentation, you might be tempted to use the GetLastError API to retrieve the error returned by your last API function or procedure. However, this function doesn't always return valid error codes, because Visual Basic internally does a lot o
....Read More |
Rating
|
|
|
Use Currency instead of LARGE_INTEGER values
|
Total Hit (3413) |
A few API calls require that you pass one or more LARGE_INTEGER arguments. These are 64-bit integer values, defined as follows:
«Code LangId=1»
Type LARGE_INTEGER
lowpart As Long ' lower 32-bit value
highpart As Long ' higher 32-bit value
End Type
«/Code»
Unfortunately, wor
....Read More |
Rating
|
|
|
Moving a Window Without a Titlebar
|
Total Hit (3521) |
«Code LangId=1»'Place this code in the declarations section of your form:
Option Explicit
Declare Function ReleaseCapture Lib "user32" () As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As _
Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Lo
....Read More |
Rating
|
|
|
Centering a Window with a Taskbar Visual
|
Total Hit (3195) |
«Code LangId=1»Option Explicit
Private Const SPI_GETWORKAREA = 48
Private Declare Function SystemParametersInfo& Lib "User32" Alias _
"SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As _
Long, lpvParam As Any, ByVal fuWinIni As Long)
Private Type RECT
Left As Long
Top As Long
....Read More |
Rating
|
|
|
Changing Display Settings on the Fly
|
Total Hit (3962) |
«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
|
|
|
Flashing Form Caption
|
Total Hit (3097) |
«Code LangId=1»'Ever wanted to get the users attention without one of those annoying BEEPs, or just have a 'little fun? Here is a good way to do it. Flash the caption of your Form. That should get 'their attention!
'Place this code into a Module:
Option Explicit
Declare Function FlashWindow L
....Read More |
Rating
|
|
|
Keeping a Window On Top
|
Total Hit (3095) |
«Code LangId=1»'Place this into your Module:
Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, _
ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Global Const SWP_NOMOVE = 2
Global Const SWP_NO
....Read More |
Rating
|
|
|
LOG Files
|
Total Hit (2778) |
«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
|
|
|
|
|
|
|
|
|
|
|
|
Give user ability to interrupt loop
|
Total Hit (2896) |
Private Declare Function GetAsyncKeyState Lib "user32.dll" _
(ByVal vKey As Long) As Integer
'//ESCAPE
Const VK_ESCAPE = &H1B
'//Button Click
Const VK_LBUTTON = &H1
'//Interrupting A Do Loop
'//Give user ability to interrupt loop
Private Sub cmdStart_Click()
....Read More |
Rating
|
|
|
|
Create Controls at RunTime
|
Total Hit (4749) |
API Declarations
«Code LangId=1» 'API Calls
Public Declare Function CreateWindowEx Lib "user32.dll" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal n
....Read More |
Rating
|
|
|
How to obtain the description of the System's Processor
|
Total Hit (4178) |
API Declarations
«Code LangId=1» 'API Structures
Public Type SYSTEM_INFO
wProcessorArchitecture As Integer
wReserved As Integer
dwPageSize As Long
lpMinimumApplicationAddress As Long
lpMaximumApplicationAddress As Long
dwActiveProcessorMask As Long
dwNumberOfP
....Read More |
Rating
|
|
|
How to Disable the Ctrl-Alt-Del keys combination...
|
Total Hit (3312) |
API Declarations
«Code LangId=1»
Private Declare Function SystemParametersInfo Lib "user32.dll" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long
«/Code»
Module
«Code LangId=1»
Sub DisableCtrlAltDelete(bDis
....Read More |
Rating
|
|
|
How to Hide/Show the Windows Task Bar and the Desktop...
|
Total Hit (3136) |
API Declarations
«Code LangId=1» Private Declare Function ShowWindow Lib "user32.dll" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declar
....Read More |
Rating
|
|
|
...and how to change the name of your computer...
|
Total Hit (2957) |
API Declarations
«Code LangId=1» Private Declare Function SetComputerName Lib "kernel32.dll" Alias "SetComputerNameA" (ByVal lpComputerName As String) As Long
«/Code»
Module «Code LangId=1»
Public Function SetComputerName(Name as String) as Boolean
Dim res As Long
res=SetCo
....Read More |
Rating
|
|
|
How to Obtain the name of the computer...
|
Total Hit (3142) |
API Declarations
«Code LangId=1» Private Declare Function GetComputerName Lib "kernel32.dll" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
«/Code»
Module
«Code LangId=1»
Public Function ComputerName() As String
Dim cn As String
Dim ls As Long
Di
....Read More |
Rating
|
|