|
Setting the off-line mode
|
Total Hit (3885) |
You can programmatically set the Internet Explorer off-line mode with the InternetSetOption API, as this code snippet demonstrates:
«Code LangId=1»
Const INTERNET_OPTION_CONNECTED_STATE = 50
Const INTERNET_STATE_CONNECTED = 1
Const INTERNET_STATE_DISCONNECTED = 2
Const INTERNET_STATE_DISCONNE
....Read More |
Rating
|
|
|
Resolve an internet host address
|
Total Hit (2839) |
The System.Net.Dns class exposes a few static methods that let you resolve an internet domain name - such as www.vb2themax.com - into a 4-part numeric IP address, also known as dotted-quad notation.
The Resolve static method takes a string and returns an IPHostEntry object; you can learn the actu
....Read More |
Rating
|
|
|
Retrieving special system paths
|
Total Hit (2716) |
The GetFolderPath method of the Environment class lets you retrieve the path of several important system directories. For example, here's how you determine the path of the Desktop directory for the current user:
«Code LangId=2»
Console.WriteLine(Environment.GetFolderPath _
(Environment.Spec
....Read More |
Rating
|
|
|
Wait for a process to terminate
|
Total Hit (3613) |
You can use the VB.NET Shell command (in the Microsoft.VisualBasic namespace) to run an external process and wait for its termination, but you can get better control if you work directly with the Process class in the System.Diagnostics namespace. You can start a process with the Start static method
....Read More |
Rating
|
|
|
Write a console utility to kill a process
|
Total Hit (3026) |
The System.Diagnostics.Process class exposes two methods that let you kill a process: CloseMainWindow should be used with processes that have a graphical interface, whereas the Kill method should be used for apps without a user interface (or those whose main window is disable and can't process the W
....Read More |
Rating
|
|
|
Write a console utility to list processes
|
Total Hit (4155) |
The Process class provides all you need to create a command-line utility that lists all the processes running on the system and all the related information. This utility is therefore similar to the Windows Task Manager, except you can run it from the command prompt. All processes are sorted alphabet
....Read More |
Rating
|
|
|
Control what happens when an unhandled exception occurs
|
Total Hit (3077) |
By default, when an unhandled exception occurs in a managed application, a dialog box appears that asks you whether you want to debug the application with one of the debuggers that are listed in a listbox. (Notice that Windows Forms applications display a different dialog box.)
The behavior of th
....Read More |
Rating
|
|
|
Control the mouse speed under Windows 98 / 2000
|
Total Hit (3607) |
Under Windows 98 and 2000 you can control the speed of the mouse. The mouse speed determines how far the pointer will move based on the distance the mouse moves. The pvParam parameter must point to an integer that receives a value which ranges between 1 (slowest) and 20 (fastest). A value of 10 is t
....Read More |
Rating
|
|
|
Correctly restore mouse cursor
|
Total Hit (3394) |
When you write lengthy procedures, it is a good habit to change the mouse cursor to an hourglass, and restore it to the original shape when the procedure exits. However, this cursor tracking may be rather difficult when the procedure has multiple exit points, or when it can exit abruptly because of
....Read More |
Rating
|
|
|
Determine the number of mouse buttons
|
Total Hit (3219) |
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
|
|
|
Hide and show the mouse cursor
|
Total Hit (3220) |
At times you may want to temporarily hide the mouse cursor, for example in order to reduce flickering. To do so you just need the ShowCursor API function:
«Code LangId=1»
Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
' hide the mouse
ShowCursor False
' do
....Read More |
Rating
|
|
|
Intercepting MouseEnter and MouseExit events without subclassing
|
Total Hit (4014) |
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
|
|
|
Swap the mouse buttons' behavior and meaning
|
Total Hit (4147) |
You can programmatically swap the meaning of the left and right mouse buttons, to account for your left-handed users. All you need is a call to the SystemParameterInfo API function
«Code LangId=1»
Private Declare Function SystemParametersInfo Lib "user32" Alias _
"SystemParametersInfoA" (By
....Read More |
Rating
|
|
|
The status of mouse buttons
|
Total Hit (3390) |
Visual Basic lets you test the state of mouse buttons only inside a MouseDown, MouseMove, or MouseUp event procedure. To determine the current state of mouse buttons you can use one of the following functions:
«Code LangId=1»
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As
....Read More |
Rating
|
|
|
The status of shift keys
|
Total Hit (2947) |
Visual Basic lets you test the state of the Shift, Alt and Ctrl keys only within the KeyUp, KeyDown and all the mouse-related event procedures. If you want to test the state of these keys from within another routine, you can resort to the following functions:
«Code LangId=1»
Private Declare Fun
....Read More |
Rating
|
|
|
Clipping the mouse to a rectangle area
|
Total Hit (2158) |
The Clip property of the Cursor is the rectangle within which the mouse cursor is confined, or its value is Nothing if the mouse can move over the entire screen. This rectangle is in screen coordinates, so you must do some conversions if you want to confine the mouse to an object on the form:
«Co
....Read More |
Rating
|
|
|
Get Mouse Position Anywhere, Anytime
|
Total Hit (4147) |
Some control events provide the mouse pointer's current position within the control's client area; others provide only the screen coordinates of the mouse pointer (the same as returned by Cursor.Position). Is there a function that tells you where the mouse is positioned within a specific control? We
....Read More |
Rating
|
|
|
Mouse clipping with the Cursor class
|
Total Hit (2197) |
The Clip property of the System.Windows.Forms.Cursor class represents the rectangle within which the mouse cursor is confined, or Nothing if the mouse can move over the entire screen. This rectangle is in screen coordinates, so you must do some conversions if you want to confine the mouse to an obje
....Read More |
Rating
|
|
|
Retrieving the state of the Shift, Alt and Ctrl keys, at any time
|
Total Hit (2592) |
You can know the state of the Shift, Alt and Control keys at any time, not just from inside a Keyxxx event. The shared property Control.ModifierKeys returns a bit coded value that identifies which of those keys are pressed, and you can use the And bit operator if a specific key is pressed. The follo
....Read More |
Rating
|
|
|
Showing help
|
Total Hit (2762) |
The System.Windows.Forms.Help class encapsulates the HTML Help 1.0 engine and lets you display the index, the search page, or a specific topic in an HTML file in HTML Help format or a compiled help file (.chm) authored with the HTML Help Workshop or some third party tool.
This class exposes two
....Read More |
Rating
|
|
|
Check for a valid URL
|
Total Hit (4029) |
Before posting an Internet request you should check that the user has entered a valid Internet address. You can do this with a parsing routine, or use the following routine based on the IE5 library:
«Code LangId=1»
Private Declare Function IsValidURL Lib "urlmon" (ByVal pBC As Long, _
url A
....Read More |
Rating
|
|
|
Check whether RAS is installed
|
Total Hit (3191) |
When you work with RAS APIs, you should have to make sure if RAS library is installed on the system. A simple way is to verify the existence of the Rasapi32.dll file in the windows system directory; the same thing can be obtained with a call to the InternetGetConnectedState API, as the following cod
....Read More |
Rating
|
|
|
Check whether the user is working off-line
|
Total Hit (3474) |
Internet Explorer offers the possibility to simulate an Internet connection with the off-line mode. If you want to know if off-line mode is on or off you can use InternetQueryOption API.
«Code LangId=1»
Const INTERNET_OPTION_CONNECTED_STATE = 50
Const INTERNET_STATE_DISCONNECTED_BY_USER = &H10
....Read More |
Rating
|
|
|
Create an Internet shortcut
|
Total Hit (2832) |
Unlike regular LNK shortcut, which contain data in binary file, Internet shortcut files are just text files in this format:
[InternetShortcut]
URL=www.domain.com
Thus it is simple to programmatically create an Internet shortcut that, when double-clicked, will load the default browser and hav
....Read More |
Rating
|
|
|
Download a file with one API call
|
Total Hit (3718) |
If you have Internet Explorer 5 or later version, you can use an API call to download a file from the Internet withouth displaying any message box.
«Code LangId=1»
Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
"URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As Strin
....Read More |
Rating
|
|
|
Get the local IP address using the Internet Transfer Control
|
Total Hit (2586) |
The easiest way to retrieve the IP address assigned to the local machine during an Internet session is by means of the LocalIP property of the Internet Transfer Control:
«Code LangId=1»
MsgBox "IP address= " & Winsock1.LocalIp
«/Code»
Note that getting the same information through API calls
....Read More |
Rating
|
|
|
Launch the default browser on a given URL
|
Total Hit (4064) |
The following routine launches the default browser and loads the specified URL in it. The argument doesn't have to include the HTTP:// prefix. If the operation is successful it returns True.
«Code LangId=1»
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(B
....Read More |
Rating
|
|
|
Open the default program for sending email messages
|
Total Hit (2613) |
The ShellExecute API function recognizes email addresses if they are prefixed by the "mailto:" prefix, and correctly run the default program for sending email messages (e.g. Outlook). This lets you open a window for sending an email and automatically fill the address field. Here's a wrapper routine
....Read More |
Rating
|
|
|
Open the Internet Connection dialog
|
Total Hit (3775) |
The dialog you see when you start an Internet connection is implemented in the RNAUI.DLL file, and the specific function is called RnaDial. To open this dialog from your application you can call this function through the rundll32.exe application (located in Windows directory) specifying the name of
....Read More |
Rating
|
|
|
Put buffering and Response.Flush to good use
|
Total Hit (2456) |
IIS5 enables buffering by default, therefore all the output from your ASP is actually sent to the browser only when the page completes its processing. In many cases this approach improves the overall processing speed, and indirectly makes for a more scalable site. However, buffering has two minor de
....Read More |
Rating
|
|