Message Hook Control v1.0 ReadMe.


Contents

Message Hook control overview

Message Hook control v1.0 an ActiveX control that allows handling window messages sent to any windowed control or window (form). It is especially useful in MS Visual Basic v4.0 where there is no way to handle messages but those exposed by OLE controls or forms. Although in the versions 5 and 6 You can write callback functions and, thus, it is possible to implement window subclassing in VB but it is rather complicated, whereas Message Hook control lets to get it in a very simple way. Message Hook control lets You specify a target window and messages (Windows message IDs) , which are desired to be handled. It is also possible to define a way when the message must be handled - before, after or without being processed by default window procedure.

Features

Installatoin

Unzip MsgHook.zip file into a folder and run "regsvr32 MsgHook.dll" from command prompt (Run... item from Start menu). This will register this ActiveX control.

User Guide

It is very simple to use Message Hook control.

  1. At design time, put Message Hook control on the form which messages You want be able to process. If You want to handle messages of a control put the Message Hook control an the form containing this control. Set Enabled property to true to enable mesage handling.
  2. In You code, define message contants with windows message IDs You want to handle. In VB, for example, define such a constant in a module:
	Public Const WM_GETMINMAXINFO = &H24
  1. Set hWnd property to a valid window handle. In VB, for example, if You are going to handle form's messages, write in Sub Form_Load:
	MsgHook1.hWnd = hWnd

If You want to process a control's messages set hWnd property of the Message Hook control to the control's hWnd property. Generally, You can set hWnd property to any valid window handle.

  1. Add message IDs You wish to handle. You can add as many message as You need but You can not add the same message more than once.
	MsgHook1.AddMessage WM_GETMINMAXINFO, mshEatMessage
  1. Use Message event procedure of the Message Hook control to handle the message.
	Private Sub MsgHook1_Message(ByVal MsgId As Long,
			ByVal wParam As Long, ByVal lParam As Long,
			ByVal MsgProcessing As Integer, MsgResult As Long)
		Select Case MsgId
    		Case WM_GETMINMAXINFO:
        		'Event handling code goes here
			
		End Select
	End Sub

You can set MsgResult parameter if You wish to define a value to be returned by windows procedure. This parameter is set by default windows procedure if the message is postprocessed, is 1 if the message is eaten, and You can change this value. If the message is preprocessed then the returned value likely will be modified by the default window procedure called after Your handler.

Message Hook Reference

Properties

Methods

Events

 

Enums

MessageProcessingEnums:

 

Examples

There are three examples for VB 4 that show how this control may be used. These examles are also successfully tested with VB 6.0. Please feel free to copy and paste the code from these examples.

MinMax

This sample uses Message Hook control to conrrol form's minimal and manimal dimensions by processing WM_GETMINMAXINFO message. Try to resize the form.

SysMenu

This sample uses Message Hook control to modify form's system menu (Control Box) and handle its messages. Check "About" item from the system menu.

SysTray

This sample uses Message Hook control to create a taskbar tray notification area icon and handle all mouse events.

Licensing and Distributing

Message Hook ActiveX Control v1.0 is a freeware. It may be used and distributed freely as a part of any software and separately, as long as there is acknowledgment to author, author's name (Alex Wainstein) is mentioned and e-mail address (alexw@netvision.net.il) is provided. When distributed for development purposes, original ReadMe.htm (this file) and License.txt as well as the original examples must be provided.

Disclaimer

THIS SOFTWARE AND THE ACCOMPANYING FILES ARE DISTRIBUTED "AS IS" AND WITHOUT WARRANTIES AS TO PERFORMANCE OF MERCHANTABILITY OR ANY OTHER WARRANTIES WHETHER EXPRESSED OR IMPLIED. Because this product is a freeware no technical support or troubleshooting is guaranteed, no responsibility for any damage that may be caused by the use of this software. No bug fix is guaranteed. You use this software on Your own risk!

Bug and problem reports

Please send to alexw@netvision.net.il

Contact Information

Alex Wainstein,

e-mail: alexw@netvision.net.il


Last updated: 22-Nov-1998