|
|
|
|
|
|
|
|
Keeping a Window On Top
|
Total Hit (3123) |
«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
|
|
|
|
SetWindowShape - Create elliptical or rounded forms
|
Total Hit (3577) |
«Code LangId=1»Private Type POINTAPI
X As Long
Y As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
' Region API functins
Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, _
ByVal Y1 As L
....Read More |
Rating
|
|
|
|
|
|
The best setting for the RunAs option in a server package
|
Total Hit (1822) |
When you deploy COM objects in DLLs no security issues arise since DLLs run in the process of the caller. On the contrary, when you deploy your COM objects into an .EXE, you have to deal with such issues.
- (D)COM needs to know under what security principal (read identity) the process, where you
....Read More |
Rating
|
|
|
Determine the number of mouse buttons
|
Total Hit (3255) |
Sometimes is useful to know how many buttons the user's mouse has. This value can be obtained by calling GetSystemMetrics. The constant to pass as parameter is SM_ CMOUSEBUTTONS. Here's an example:
«Code LangId=1»
Const SM_CMOUSEBUTTONS = 43
Private Declare Function GetSystemMetrics Lib "user3
....Read More |
Rating
|
|
|
Get login information the easy way (without any API call)
|
Total Hit (2939) |
While you can use many different API function to get user and domain information, if you're running under Windows NT or 2000 Server there is a shortest path, based on the fact that the operating system loads many piece of data into environment variables:
«Code LangId=1»
' this code works only un
....Read More |
Rating
|
|
|
Correct usage for binary compatibility settings
|
Total Hit (3087) |
When working on an updated version of a COM component, you should always enforce Binary Compatibility in the Component tab of the Project Properties dialog box. When enforcing binary compatibility there are a number of common mistakes that you should stay clear of:
Always use the last EXE or DLL
....Read More |
Rating
|
|
|
Make a Checkbox control read-only
|
Total Hit (3028) |
By default, VB's CheckBox controls automatically toggle their Value property when the user clicks on them. This is usually the desired behavior, but at times you may want to be able to change their value only programmatically. Unfortunately, you can't achieve this result by simply setting the CheckB
....Read More |
Rating
|
|
|
Caution when moving or resizing forms
|
Total Hit (2844) |
Any action that affects a form's size or position should be inhibited when the form is minimized or maximized, because this causes a runtime error 384. Always double check your code to ensure that when a form is moved or resized – using a Move method or acting on a form's Left, Top, Width or Height
....Read More |
Rating
|
|
|
Search a file in a directory tree using the Imagehlp DLL
|
Total Hit (3795) |
You can search a file in all the subdirectories of a given drive in VB using a recursive routine based on the Dir$ function, the FileSystemObject component, or the FindFirstFile/FindNextFile API functions. There is a fourth way you might want to try out, based on the SearchTreeForFile function embed
....Read More |
Rating
|
|
|
Undocumented trick to speed up functions that return array
|
Total Hit (2700) |
VB6 functions can return an array. Unlike regular functions that return scalar values or objects, however, you can't use the name of the function as a local variable where to store intermediate result, and you are forced to work with a temporary local array, and then assign this array to the Functio
....Read More |
Rating
|
|
|
Fixed-length strings allocate and deallocate faster
|
Total Hit (3002) |
Fixed-length strings are generally slower than conventional strings, because all VB string functions and operators only recognize conventional strings, thus all fixed-length strings must be transparently converted to and from conventional strings.
However, arrays of fixed-length strings occupy a
....Read More |
Rating
|
|
|
Never use the End statement
|
Total Hit (3715) |
There are a lot of risks involved in using End in VB programs: your databases might not be correctly closed, your objects are not correctly terminated, etc. You should always terminate a program by unloading all the forms. You can do this using the following routine:
«Code LangId=1»
For index = F
....Read More |
Rating
|
|
|
How to Print a Multiline TextBox with Alignment!
|
Total Hit (5126) |
API Declarations
«Code LangId=1» 'Add this to your Declarations Section:
Public Declare Function SetTextAlign Lib "gdi32.dll" (ByVal hdc As Long, ByVal wFlags As Long) As Long
Public Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wmsg As Long, ByV
....Read More |
Rating
|
|
|
How to start/stop and enum services using ADSI
|
Total Hit (4213) |
This article will show you sample code to use ADSI to manage services.
«b»Step-By-Step Example«/b»
- Create a new standard exe project
- Add reference to "Active Ds Type Library" (Project->Add Reference)
- Add windows common control 6.0 (Project->Controls)
- Add one listview, five command b
....Read More |
Rating
|
|
|
|
|
Obtaining Logical Disk Information using WMI
|
Total Hit (1319) |
Windows Script Host is built into Microsoft Windows 98, 2000, ME and XP. If you are running Windows 95 or NT4, you can download Windows Script Host from the Microsoft Windows Script Technologies Web site at http://msdn.microsoft.com/scripting/. Some information is not returned on non-NT-based system
....Read More |
Rating
|
|
|
Tutorial : Using DLLs and The Windows API
|
Total Hit (2403) |
Windows provides a number of function calls, in the form of DLLs, that are useful to VB programmers. You can also co-opt DLLs from other programs to do work for you. We'll concentrate on using the Windows DLLs here, but what we learn is widely applicable
....Read More |
Rating
|
|
|
Thumbnail Extraction Using the Shell
|
Total Hit (2264) |
Since Windows Me/2000, the Windows Shell has included a mechanism for extracting a small thumbnail image for any item in the namespace. This sample demonstrates how to use this function to get thumbnail images for web pages, images, Office documents - in fact anything that supports thumbnailing in E
....Read More |
Rating
|
|