Tips Index


Click for Get an RGB Colour from an OLE_COLOR

Get an RGB Colour from an OLE_COLOR

Sometimes you need to know the Red, Green and Blue values of a Visual Basic/COM OLE_COLOR, particularly if you are going to use the colour in an API function. This tip shows you how to correctly convert an OLE_COLOR type to a RGB value using the OleTranslateColor API call exposed by OLEPRO32.DLL. It works for all colours, whether they are RGB colours, system colours of the type &H80000000F (vbButtonFace) or palette-matching colours such as &H2EECC99.

  more...


Last Updated: 9 August 1998


Click for Forcing a local or remote NT system to reboot

Forcing a local or remote NT system to reboot

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 process should be (whether it allows any unsaved work to be saved) and whether the machine will be rebooted.

  more...


Last Updated: 9 August 1998


Click for Start a document based on its filename

Start a document based on its filename

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!

  more...


Last Updated: 1 August 1998


Click for Restrict Mouse Movement to an Area of the Desktop

Restrict Mouse Movement to an Area of the Desktop

This tip shows you how to ensure a cursor remains within a certain rectangle on the screen. Note that if the user uses Alt-Tab to switch to another application, the clipping cursor is cleared.

  more...


Last Updated: 1 August 1998


Click for Read the NumLock and CapsLock key states

Read the NumLock and CapsLock key states

This sample demonstrates how to determine the state of the NumLock and CapsLock key (plus any other key on the keyboard at the same time).

  more...


Last Updated: 1 August 1998


Click for Read A Custom Clipboard Format

Read A Custom Clipboard Format

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.

  more...


Last Updated: 1 August 1998


Click for Prevent a window from repainting

Prevent a window from repainting

This tip show show to prevent an area of a window from repainting. When you have a lot of items to add to a control, such as a ListBox or ListView, this can considerably speed up the process. On my system, it speeds up adding 10,000 items to a List Box by over 30%.

  more...


Last Updated: 1 August 1998


Click for Create a mask image (all black for the transparent colour otherwise white) from a bitmap

Create a mask image (all black for the transparent colour otherwise white) from a bitmap

This tip shows you how to create a mask image from a picture. Mask images are useful for emulating transparency, and for replacing colours in images. This comes about because they are black where you want to leave an image unaffected, and white otherwise. Because they are either on or off, you can use boolean operations while copying the mask image elsewhere.

  more...


Last Updated: 1 August 1998


Click for Get the state of a key at any time

Get the state of a key at any time

If you're trying to create an interactive app, or a VB game, whether its in DirectX or using GDI calls, then reading a key state asynchronously is considerably faster than waiting for KeyUp, KeyDown or KeyPress event on a form. Checking the key state this way can also be very useful when trying to check for shift states when responding to a WM_KEYDOWN event if you are doing sub-classing.

  more...


Last Updated: 1 August 1998


Click for Get the Desktop Device Context

Get the Desktop Device Context

This tip shows how to get a device context handle to the Desktop, which you can then use to draw directly onto the desktop. The sample code doesn't do very much, it just tests the desktop handle by writing some text on it in the top left hand corner.

  more...


Last Updated: 1 August 1998