|
Show ChooseFont dialogbox using API
|
Total Hit (5475) |
You can use ChooseFont API to show Font selection common dialogbox. This API will eliminate the need of Common Dialog ActiveX control which comes with Visual Basic.
«b»Step-By-Step Example«/b»
- Create a standard exe project
- Add one commandbutton on the form1
- Add the following code in fo
....Read More |
Rating
|
|
|
How to monitor Printer Queue using printer API
|
Total Hit (19479) |
This article will show you how you can use OpenPrinter, EnumJobs and ClosePrinter API to monitor selected printer's queue.
To implement Quick Demo perform the following steps
- Create a standard exe project
- Add module1
- Place 1 commandbutton, 1 textbox, 1 combobox 1 timer and 1 ListView
....Read More |
Rating
|
|
|
|
|
|
|
|
Centering a Window with a Taskbar Visual
|
Total Hit (3108) |
«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
|
|
|
|
GetPrimeNumbers - Evaluate the first N prime numbers
|
Total Hit (1582) |
«Code LangId=1»' Returns an array with the first N prime numbers
'
' Note: you can easily convert this routine to VB4 and VB5 by
' returning the result array through an argument instead of
' the return value
Function GetPrimeNumbers(numberOfPrimes As Long) As Long()
Dim found As Long
....Read More |
Rating
|
|
|
Intercepting MouseEnter and MouseExit events without subclassing
|
Total Hit (3926) |
Visual Basic raises the MouseMove event when the mouse cursor is within a control, so it's easy to know when the cursor "enters" a control. However, determining when the mouse leaves the control is more difficult.
You can solve this problem by monitoring the first time the control raises the Mous
....Read More |
Rating
|
|
|
Open MS-DOS prompt from any directory in Explorer
|
Total Hit (2631) |
By adding a couple Registry keys you can add a commond to the context menu that appear when you right-click a directory when inside Windows Explorer. The new command lets you open the MS-DOS prompt and navigate to that directory with just one mouse click:
«Code LangId=1»
---------------------
....Read More |
Rating
|
|
|
Remove the Close command from the system menu
|
Total Hit (3167) |
If you want to prevent the user from closing a form by using Alt+F4 or by clicking on the "X" button in the upper-right corner you just need to write some code in the form's QueryUnload event procedure:
«Code LangId=1»
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
....Read More |
Rating
|
|
|
Cut, copy, and paste using API functions
|
Total Hit (4663) |
Copying and pasting text and images programmatically isn't difficult at all, using the methods of the Clipboard object. However, implementing a generic Edit menu that copies and pastes the highlighted contents of whatever control is the selected control is often cumberson. For example, depending on
....Read More |
Rating
|
|
|
Ensure that a TextBox caret is visible
|
Total Hit (3059) |
Setting a multiline TextBox's SelStart property doesn't ensure that the insertion point (the caret) is visible. You can achieve this by sending the control an appropriate message:
|
Rating
|
|
|
Beware of slashes when formatting dates
|
Total Hit (2872) |
You probably use the Format function to format date, for example:
«Code LangId=1»
? Format(Now, "mm/dd/yyyy") ' => 08/01/2001
? Format(Now, "mm+dd+yyyy") ' => 08+01+2001
«/Code»
It seems that this is everything you need to know, right? However, the story is quite different
....Read More |
Rating
|
|
|
Sorting on multiple keys
|
Total Hit (2276) |
Frequently you need to sort arrays of records using multiple keys. This may be required since one single key does not uniquely identify a record (e.g. you may need both LastName and FirstName to select a given employee in a large company where people with same name work), or it may be necessary for
....Read More |
Rating
|
|
|
Tip: How to display all environment variables
|
Total Hit (2449) |
«code LangId=1»Private Declare Function GetEnvironmentStrings Lib "kernel32" Alias "GetEnvironmentStringsA" () As Long
Private Declare Function FreeEnvironmentStrings Lib "kernel32" Alias "FreeEnvironmentStringsA" (ByVal lpsz As String) As Long
Private Declare Function lstrlen Lib "kernel32" Alias
....Read More |
Rating
|
|
|
Floating Point Numbers Validation
|
Total Hit (1989) |
«Code LangId=1»Private Sub Form_Load()
Text1.Text = Empty
End Sub
' USAGE
'Create a form a text box
Private Sub Text1_KeyPress(KeyAscii As Integer)
' Precision is 2 in this case
' Send the Precision Value same in both the Functions
Call ValidateNum(Text1, 2, KeyAscii)
End
....Read More |
Rating
|
|
|
Implementing a Distributed Algorithm in Visual Basic
|
Total Hit (2157) |
An illustrative algorithm is implemented in Visual Basic, emphasizing all the four fundamental aspects of distributed computing systems: resource sharing, computation speedup, reliability, and communication. Winsock control is used to provide effective communication and resource sharing between the
....Read More |
Rating
|
|
|
Extending the functionality of the VB ListView controls
|
Total Hit (2107) |
The "ListView" control in both Comctl32.ocx and Mscomctl.ocx is simply a wrapper that superclasses (encapsulates) the real "listview" common control in Comctl32.dll. This allows the real listview common control messages and definitions to be used to override almost every aspect of the VB ListView co
....Read More |
Rating
|
|
|
|
Adding Checkboxes to a Treeview via API
|
Total Hit (1408) |
Recent newsgroup postings have asked how to mimic the Advanced Options page displayed in Internet Explorer 4. Initially I thought of using the listview with checks and indents, but after someone suggested that the items on the page were collapsible, I investigated the treeview styles. Sure enough, a
....Read More |
Rating
|
|
|
Autosizing ListView Columns via API
|
Total Hit (1690) |
The ListView control in both VB5 and VB6 implementations supports SendMessage with the LVSCW_AUTOSIZE and LVSCW_AUTOSIZE_USEHEADER messages to cause the ListView to adjust its column widths to maximize data display. This page shows how to use these messages to resize the columns to fit the longest c
....Read More |
Rating
|
|
|
Filling a Combo with Files, Directories and Drives
|
Total Hit (1100) |
This routine demonstrates using SendMessage to populate a combo box with any combination of files, directories and drives. Although this demo uses the wildcard *.*, the method is valid for any mask.
|
Rating
|
|
|
Tutorial : Sound & Games
|
Total Hit (1641) |
These tutorials are were originally developed as part of a VB Game Programming for beginners book Soren and I were working on. For a variety of reasons the book idea never came to fruition and so we decided to post the material that is finished as a series of tutorials in the hopes that you would fi
....Read More |
Rating
|
|
|
Start a document based on its filename
|
Total Hit (1211) |
Starting any document file based on its file name only is very simple in Windows using the ShellExecute function. This tip shows how simple it is - you only really need one declare and one line of code!
|
Rating
|
|
|
Read A Custom Clipboard Format
|
Total Hit (2657) |
VB limits you to getting information in just the standard clipboard formats. However, a number of applications paste information in other formats, for example Rich Text Format, HTML format and so forth. This tip shows you how to read the data for a custom format from the clipboard as a string.
....Read More |
Rating
|
|
|
Drawing Buttons, Option Boxes and Check Boxes In Your Own Style
|
Total Hit (2211) |
If you set the Style property for VB's CommandButton, OptionBox or CheckBox controls to Graphical, VB turns the control into an Owner-Draw control. By default VB allows you to associate three pictures with these controls. However, if you've ever tried this you will know that the button draws like a
....Read More |
Rating
|
|
|
Enumerating Windows Using the API
|
Total Hit (1870) |
Prior to VB5, it was impossible to use the enumeration methods provided in the Windows API without relying on a proprietary custom control. This was a problem if you wanted to find out all the Windows showing on the system, because the only reliable methods you can use to do this are through enumera
....Read More |
Rating
|
|