Tips Index


Click for Preventing Logoff or Shutdown

Preventing Logoff or Shutdown

Sometimes if an application is performing a long operation you do not want the user to log-off or shutdown the system until it is complete. An example is when burning a CD, as the CD burn will be terminated and the disc potentially ruined. This sample demonstrates how to respond to the WM_QUERYENDSESSION message to prevent this from occurring.

  more...


Last Updated: 2 June 2004


Click for Mapping NT Device Names to Drive Letters and vice-versa

Mapping NT Device Names to Drive Letters and vice-versa

This tip demonstrates how you convert between MS-DOS style drive letters and NT-style device names. This can be useful if you're working with an API that exposes an NT device name, such as IMAPI for CD Burning.

  more...


Last Updated: 2 June 2004


Click for Creating a new GDI Bitmap from a VB Picture or DC

Creating a new GDI Bitmap from a VB Picture or DC

If you're creating some code which works with VB but draws with the more powerful GDI functions, it's often very handy to be able to create a new bitmap handle from a VB StdPicture object or from an area of a DC. This article demonstrates how to do this with a few lines of GDI code.

  more...


Last Updated: 15 February 2004


Click for Generating Random Boolean Sequences Using Cellular Automata

Generating Random Boolean Sequences Using Cellular Automata

This tip demonstrates how to generate a sequence of random boolean numbers using a cellular automata technique described in Stephen Wolfram's book "A New Kind Of Science". Unlike many other linear congruential generators, the output of this method has been shown to be free of repetition and statistically random.

  more...


Last Updated: 23 October 2003


Click for SendKeys using the API

SendKeys using the API

VB provides the SendKeys command which is supposed to create key events in the focus control. However, in practice SendKeys sometimes doesn't work correctly, it is missing some keys and doesn't offer much flexibility in controlling the sequence of key strokes that gets sent. This article demonstrates using the Win32 keybd_event API call to circumvent these limitations.

  more...


Last Updated: 5 September 2003


Click for Responding to AppCommands

Responding to AppCommands

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 in a VB application.

  more...


Last Updated: 5 September 2003


Click for Change The Width of Items in a Listbox

Change The Width of Items in a Listbox

Normally in a VB ListBox, if a ListItem is too long to fit, it is clipped by the display. This tip demonstrates how to modify a ListBox so it displays a longer items with a horizontal scroll bar.

  more...


Last Updated: 5 September 2003


Click for Working with Multiple Monitors

Working with Multiple Monitors

Windows 98/2000 systems and above provide support for multiple monitors. This is a great thing except that it messes up old programs which attempt to do things like centre Windows or otherwise restrict their position to the visible area of the screen. This tip provides some simple code to allow you to work with multiple monitors.

  more...


Last Updated: 27 June 2003


Click for Providing a proper VB Application Icon, Including Large Icons and 32-Bit Alpha Images

Providing a proper VB Application Icon, Including Large Icons and 32-Bit Alpha Images

If you set your application's icon using the built-in facilities of VB, you will find there's a few things that go wrong. 48x48 icons are not supported; neither are 32-bit colour depth icons. In addition, you can't provide an application icon which includes multiple colour depths and sizes so it will render correctly regardless of the capabilities of the system on which it is run. This tip demonstrates how to fix the problem by using a resource and a few API calls.

  more...


Last Updated: 27 June 2003


Click for Detecting Mouse XButton Clicks

Detecting Mouse XButton Clicks

Recently I discovered that my mouse had two strange buttons on the left-hand side (until then I'd thought that the mouse's case just wasn't very well put together). Turns out these are the 'X Buttons' and can be used for moving backwards and forwards in Explorer and IE. This sample demonstrates how you can intercept clicks on these buttons to provide the same functionality in a VB application.

  more...


Last Updated: 27 June 2003