Article ID: 140883
Article Last Modified on 7/13/2004
//=================== CIRCLE1 ==================
// CIRCLE.C
// An example of subclassing a Visual Basic Form
//==============================================
#define NOCOMM
#include <windows.h>
#include <vbapi.h>
#include "circle.h"
//declare the subclass procedure
LONG FAR PASCAL _export SbClsProc(HWND,USHORT,USHORT,LONG);
//far pointer to the default procedure
FARPROC lpfnOldProc = (FARPROC) NULL ;
//get the controls parent handle(form1)
HWND hParent ;
//----------------------------------------------------------
// Circle Control Procedure
//----------------------------------------------------------
LONG FAR PASCAL _export CircleCtlProc (HCTL hctl, HWND hwnd,
USHORT msg, USHORT wp, LONG lp)
{
LONG lResult ;
switch (msg)
{
case WM_CREATE:
switch (VBGetMode())
{
//this will only be processed during run mode
case MODE_RUN:
{
hParent = GetParent (hwnd) ;
//get the address instance to normal proc
lpfnOldProc = (FARPROC) GetWindowLong
(hParent, GWL_WNDPROC) ;
//reset the address instance to the new proc
SetWindowLong (hParent,
GWL_WNDPROC, (LONG) SbClsProc) ;
}
break ;
}
break ;
}
// call the default VB proc
lResult = VBDefControlProc(hctl, hwnd, msg, wp, lp);
return lResult;
}
LONG FAR PASCAL _export SbClsProc (HWND hwnd, USHORT msg,
USHORT wp, LONG lp)
{
switch (msg)
{
case WM_SIZE:
{
//place size event here for example...
}
break;
case WM_DESTROY:
SetWindowLong (hwnd, GWL_WNDPROC,
(LONG) lpfnOldProc) ;
break ;
}
// call CircleCtlProc to process any other messages
return (CallWindowProc(lpfnOldProc, hwnd, msg, wp, lp));
}
;==========================================================
;Circle.def - module definition file for CIRCLE3.VBX control
;==========================================================
LIBRARY CIRCLE
EXETYPE WINDOWS
DESCRIPTION 'Visual Basic Circle Custom Control'
CODE MOVEABLE
DATA MOVEABLE SINGLE
HEAPSIZE 1024
EXPORTS
WEP @1 RESIDENTNAME
SbClsProc @2
;------------------------------------------------------
Keywords: kbhowto kb16bitonly KB140883