|
...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
|
|
|
|
|
|
|
|
|
GetFilePath - Extract the path portion of a file name
|
Total Hit (3904) |
«Code LangId=1»
' Retrieve a file's path
'
' Note: trailing backslashes are never included in the result
Function GetFilePath(FileName As String) As String
Dim i As Long
For i = Len(FileName) To 1 Step -1
Select Case Mid$(FileName, i, 1)
Case ":"
....Read More |
Rating
|
|
|
SearchFileOnPath - Search a file on system path
|
Total Hit (1673) |
«Code LangId=1»
Private Declare Function SearchPath Lib "kernel32" Alias "SearchPathA" (ByVal _
lpPath As String, ByVal lpFileName As String, ByVal lpExtension As String, _
ByVal nBufferLength As Long, ByVal lpBuffer As String, _
ByVal lpFilePart As String) As Long
' Search a fil
....Read More |
Rating
|
|
|
CompareList - Compare an argument with a list of values
|
Total Hit (2443) |
«Code LangId=1»
' Return the position of the argument in a list of values
' or zero if the argument isn't included in the list
' It works for both regular values and for objects
'
' This handy function can often save you a lengthy Select Case
' statement or a complex series of If...ElseIf blo
....Read More |
Rating
|
|
|
Record a WAV file
|
Total Hit (3753) |
You can use MCI functions if you want to record a WAV file. The main MCI function is mciSendString, that sends command strings to the system and execute them.
«Code LangId=1»
Declare Function mciSendString Lib "winmm" Alias "mciSendStringA" (ByVal _
lpstrCommand As String, ByVal lpstrReturn
....Read More |
Rating
|
|
|
Suppress Max and Min buttons in MDI forms
|
Total Hit (2160) |
Unlike regular forms, forms don't expose the MinButton and MaxButton properties and these buttons are always displayed. You can suppress these buttons using the following code:
|
Rating
|
|
|
Undo changes in a TextBox control
|
Total Hit (3878) |
The TextBox control supports the capability to undo changes, but there is no property or method that exposes this feature. You can achieve the same goal with a a set of messages.
«Code LangId=1»
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal _
hwnd As Long,
....Read More |
Rating
|
|
|
Determine whether a control has a scrollbar
|
Total Hit (2849) |
There is no built-in VB function that lets you know whether a control - such as a ListBox - is currently displaying a vertical scrollbar. Here's a pair of functions that check the control's style bits and return a Boolean that tells if a vertical or horizontal scrollbar is visible:
«Code LangId=1
....Read More |
Rating
|
|
|
Ensure that a form's TextBox and ComboBox controls have same height
|
Total Hit (3270) |
In general you don't have any control on a ComboBox's Height property, because it is determined automatically by VB depending on the font used for the ComboBox control. If you have a form that contains both TextBox and ComboBox controls, you should ensure that all your single-line TextBox controls a
....Read More |
Rating
|
|
|
Change the ShowInTaskbar property at runtime
|
Total Hit (4448) |
The ShowInTaskbar property lets you decide whether a form is visible in Windows taskbar or not. However, this property is read-only at runtime, so it seems that you can't change this setting while the program is running. Luckly, you just need to change the window's style, using a pair of API functio
....Read More |
Rating
|
|
|
Create a system timer using AddressOf and a callback function
|
Total Hit (4106) |
The Timer control is great when you want to periodically execute a piece of code while the program is doing something else. However, it also has a couple of shortcomings: (1) it requires a parent form, so you can't use it directly inside a BAS module, and (2) it's Interval property can't be higher t
....Read More |
Rating
|
|
|
Guitar simulation using MIDI APIs
|
Total Hit (5965) |
«b»Step-By-Step Example«/b»
- Create a standard exe project
- Add one listbox, combobox and 2 command button controls
- Add one class module and rename it to clsMIDI
- Add the following code in form1
«b»Form1.frm«/b»
«code LangId=1»Dim objMIDI As New clsMIDI
Private Enum enumInstruments
....Read More |
Rating
|
|
|
|
Working with ADSI (Active Directory Service Interface)
|
Total Hit (7651) |
Active Directory Services Interfaces (ADSI) is a set of open interfaces that abstract the capabilities of directory services from different network providers to present a single view for accessing and managing network resources. Administrators and developers can use ADSI services to enumerate and ma
....Read More |
Rating
|
|
|
Working with Meta Files (EMF,WMF and APM)
|
Total Hit (12378) |
A metafile is a mechanism for storing a graphics device interface (GDI) "picture"—a series of GDI functions that are used to draw an image. A metafile consists of a series of records, each representing a GDI function. When the metafile is played back, each stored function is executed using its recor
....Read More |
Rating
|
|
|
How to show/hide taskbar, desktop icons and start button ?
|
Total Hit (16584) |
This sample code will show you how to use FindWindow api to get handle to various window by window title. If you have window handle then you can use APIs like ShowWindow, SetWindowPos and many more to perform various operations (e.g. hide/show, resize etc.) to that window.
«b»Step-By-Step Exampl
....Read More |
Rating
|
|
|
|
Applying Special Effects to a TreeView
|
Total Hit (1096) |
The treeview is a special beast ... compared to the listview, in my opinion, a lot more complicated to manipulate via API. Instead of referring to items as simple indices based on order, each treeview item has an item handle, and it is this that is used when manipulating treeview items (see the cod
....Read More |
Rating
|
|
|
ListView Demo 4 - Adding the Associated Icons
|
Total Hit (1234) |
By far the most complicated code yet, this page adds the code necessary to retrieve the Windows associated icon for a given file, assign it to an imagelist dynamically, and use it to display with the file in the listview. Among the features of the method detailed here is the reuse of an icon if it h
....Read More |
Rating
|
|
|
Changing the Dropdown Width of a Combo Box
|
Total Hit (1198) |
This routine demonstrates using the API to change the width of the dropdown portion of a combo box. The combo list width is manually set in the accompanying text box.
|
Rating
|
|
|
Forcing a local or remote NT system to reboot
|
Total Hit (2909) |
Under Windows NT, you can force a timed system shutdown on either the local machine or a remote network machine. This code tip shows how to do it. You can specifiy how long it will be before the machine will be shutdown in seconds (a zero value shuts down immediately), how remorseless the shutdown p
....Read More |
Rating
|
|
|
Create New GUIDs
|
Total Hit (2542) |
This sample, from Dion Wiggins (dionwiggins@hotmail.com) shows how to use the CoCreateGuid and StringFromGUID2 functions to create a GUID.
The code is compiled into an ActiveX DLL which gives the interesting possibility of using the code from an ASP page, or from other ActiveX-enabled scripting
....Read More |
Rating
|
|
|
Preventing Crashes at Shutdown
|
Total Hit (2138) |
Some versions of ComCtl32.DLL version 6.0 cause a crash at shutdown when you enable XP Visual Styles in an application. This particularly occurs when using VB User Controls.
This article provides two solutions to the problem.
|
Rating
|
|
|