|
|
|
Working with Resource file
|
Total Hit (6036) |
Resource file is embedded into you compiled exe, dll, ocx etc. You can store Icon, Cursor, AVI, GIF, Bitmap word document or any thing you want. VB provides few function to access application resource but these functions (LoadResData, LoadResPicture and LoadResString) not enough if you want more fle
....Read More |
Rating
|
|
|
|
How to add your own menu item in System menu ?
|
Total Hit (4761) |
This sample code will show you
- How to add a new menuitem in the system menu using InsertMenuItem API
- How to respond to the events generated by new menuitem with the subclassing technique
- How to get/set item state using GetMenuState and SetMenuItemInfo APIs
- How to remove menuitem from
....Read More |
Rating
|
|
|
How to send a specific windows message to all windows ?
|
Total Hit (3435) |
Many times we need to send a specific message to other applications or windows itself to notify regarding some event. Windows provides a function called BroadcastSystemMessage. The BroadcastSystemMessage function sends a message to the specified recipients. The recipients can be applications, instal
....Read More |
Rating
|
|
|
|
|
|
|
|
RandomString - Generate a random string using a mask
|
Total Hit (2350) |
«Code LangId=1»' generate a random string
'
' the mask can contain the following special chars
' ? : any ASCII character (1-127)
' # : a digit
' A : an alphabetic char
' N : an alphanumeric char
' H : an hex char
' all other chars are taken literally
' Example: a random-ge
....Read More |
Rating
|
|
|
|
Rnd2 - A random value in a range
|
Total Hit (1577) |
«Code LangId=1»
' A random number in the range (low, high)
Function Rnd2(low As Single, high As Single) As Single
Rnd2 = Rnd * (high - low) + low
End Function
«/Code»
|
Rating
|
|
|
Generating IDL code to overcome binary compatibility issues
|
Total Hit (3571) |
Among the different COM details that VB hides to the programmers, one of the most problematic one is that it doesn't let you take control on interface GUIDs. Binary compatibility settings in VB try to make you follow COM rules (as a fact breaking such rules with the interface forward mechanism it si
....Read More |
Rating
|
|
|
Get the exit code of a process
|
Total Hit (4198) |
In a few cases, in particular when running MsDos batch files from within a VB application, you may want to determine the ERRORLEVEL set by an external application. You can't do it with a plain Shell statement, but the job becomes easy with the support of the GetProcessExitCode API function:
«Code
....Read More |
Rating
|
|
|
Hide the application in the Task List dialog
|
Total Hit (3373) |
As you know, when you press CTRL+ALT+CANC the Task List window appears. This dialog allows you to see all the running processes and also to terminate them. If you don't want that your application be closed, you can prevent the application from being displayed in the Task List dialog, by using the Re
....Read More |
Rating
|
|
|
Play a MIDI file
|
Total Hit (4475) |
If you want to play a MIDI file from VB you have to use MCI functions. 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
....Read More |
Rating
|
|
|
Copy a directory tree
|
Total Hit (3042) |
Creating a VB routine that copies a whole directory tree can be a time-consuming job, but fortunately you don't have to do it. In fact, you can quickly create an entire folder, including all its subfolders, using the CopyFolder method of the FileSystemObject object, that is exposed by the Microsoft
....Read More |
Rating
|
|
|
Use Sleep API to add pauses to your programs
|
Total Hit (4043) |
Don't use an empty For...Next loop to add pauses to your programs; instead, use the Sleep API function, that releases the CPU and lets other apps in the system effectively multitask:
«Code LangId=1»
Declare Sub Sleep Lib "kernel32" (ByVal milliseconds As Long)
' pause for 5 seconds
Sleep 5000
....Read More |
Rating
|
|
|
Evaluate the integer equal or higher than a given value
|
Total Hit (2847) |
The VBA language offers the Int() function, which returns the integer equal or lower than a given value, but lacks a similar function that returns the integer equal or higher than a given value. You can remedy with the following function:
«Code LangId=1»
' Returns the integer equal or higher tha
....Read More |
Rating
|
|
|
Compact and Repair Access MDB.
|
Total Hit (2955) |
Following code requires Microsoft DAO 3.6 reference.
To add this reference goto Project->Reference
example:
«Code LangId=1»
Call DBCompact("OLt.mdb", "tmpOLT.mdb", , , ";pwd=mypwd")
«/Code»
|
Rating
|
|
|
DNS Inside Out (DNS Client sample application)
|
Total Hit (2578) |
Today we are going to find out what is going on behind the scenes when our application calls such Winsock API functions as gethostbyname and gethostbyaddr. In other words, we’ll explore the communication session model between a client application and a DNS server. Afterwards, you’ll be able to devel
....Read More |
Rating
|
|
|
Displaying Modal Form Activity on a Parent Form VB Progress Bar
|
Total Hit (1259) |
This is simple code that demonstrates how to use a normal VB progress bar on a parent form (SDI or MDI) to track the activity being performed in another form, even when that form is modal.
The demo also shows how to call SetParent to embed the progress bar inside the status bar panel.
....Read More |
Rating
|
|
|
How to Determine Re-Ordered Column Positions in a ListView
|
Total Hit (1455) |
Sending the listview extended style message LVS_EX_HEADERDRAGDROP enables repositioning/reordering of a ListView's main and subitem columns.
However, this does not alter the index of the columns to match their new physical locations. VB remains unaware that repositioning has taken place (since it
....Read More |
Rating
|
|
|
Detect when a Combo Box Drops Down or Closes Up
|
Total Hit (1999) |
This tip demonstrates how to detect a Combo Box drop down or close up by using subclassing. You will need to have installed and registered the Subclassing and Timer Assistant, available from this site at Subclassing without the crashes to run this sample.
....Read More |
Rating
|
|
|
Responding to AppCommands
|
Total Hit (1776) |
The WM_APPCOMMAND message was added to Windows 2000 and ME to provide a mechanism to send the events from extended keys on newer keyboards to applications on the system. Extended keys are things like the back, forward and search button. This tip demonstrates how to intercept events from these keys i
....Read More |
Rating
|
|
|
ComCtl32.DLL HotKey Control
|
Total Hit (800) |
The hotkey control is one of the controls provided as part of COMCTL32.DLL, but, being of somewhat limited utility, has never found its way into Visual Basic's controls. If you need one, however, it does the job really well.
When it has focus, you can press CTRL, ALT and SHIFT key combinations,
....Read More |
Rating
|
|
|
Custom Drag-Drop Images Using ImageLists
|
Total Hit (2269) |
The standard VB drag-drop functionality provides a cursor to indicate that a drag-drop function is in progress. This article demonstrates how to add an image of the object being dragged to the drag-drop control, in the same way that Explorer does using the ImageList APIs.
....Read More |
Rating
|
|
|
Drawing Borders and Edges using the API DrawEdge Function
|
Total Hit (2242) |
The DrawEdge function is a useful function provided by the Win32 API. It can draw a variety of the edge styles used to draw buttons, frames and borders around controls and forms. The source code for this article shows you how to:
Use the DrawEdge to achieve a variety of edge styles.
Evaluate the
....Read More |
Rating
|
|