Attribute VB_Name = "modSubCls" Option Explicit '============================================================================================================= ' ' modSubCls Module ' ---------------- ' ' Created By : Kevin Wilson ' http://www.TheVBZone.com ( The VB Zone ) ' http://www.TheVBZone.net ( The VB Zone .net ) ' ' Last Update : January 11, 2000 ' ' VB Versions : 5.0 / 6.0 ' ' Requires : SUBCLS.DLL - Subclassing DLL created by Kevin Wilson (Wilson Media) ' ' Description : This DLL makes sub-classing windows messanges in Visual Basic safer by taking it over and ' handling it outside of VB. This makes editing sub-classing code at run time within VB ' possible because it doesn't lock up the VB IDE. ' ' Example Use: ' ' Private Sub Form_Load() ' ' You must show the form to be subclassed first, or it will never be shown ' Me.Show ' ' Add a watch on the LEFT MOUSE BUTTON events ' AddMsgWatch WM_LBUTTONDBLCLK ' AddMsgWatch WM_LBUTTONDOWN ' AddMsgWatch WM_LBUTTONUP ' ' Subclass the form ' InstallSubClass Me.hWnd, False ' End Sub ' ' Private Sub Form_Unload(Cancel As Integer) ' ' Unsubclass the form ' UninstallSubClass ' End Sub ' '============================================================================================================= ' ' LEGAL: ' ' You are free to use this code as long as you keep the above heading information intact and unchanged. Credit ' given where credit is due. Also, it is not required, but it would be appreciated if you would mention ' somewhere in your compiled program that that your program makes use of code written and distributed by ' Kevin Wilson (www.TheVBZone.com). Feel free to link to this code via your web site or articles. ' ' You may NOT take this code and pass it off as your own. You may NOT distribute this code on your own server ' or web site. You may NOT take code created by Kevin Wilson (www.TheVBZone.com) and use it to create products, ' utilities, or applications that directly compete with products, utilities, and applications created by Kevin ' Wilson, TheVBZone.com, or Wilson Media. You may NOT take this code and sell it for profit without first ' obtaining the written consent of the author Kevin Wilson. ' ' These conditions are subject to change at the discretion of the owner Kevin Wilson at any time without ' warning or notice. Copyright© by Kevin Wilson. All rights reserved. ' '============================================================================================================= ' SUBCLS.DLL Exported Functions: '=============================== '_AddMsgWatch@4 '_ClearAllMsgWatches@0 '_ClearLastErr@0 '_ClearQuitMsg@0 '_GetHInstance@0 '_GetLastErr@0 '_GetMessageInfo@16 '_GetMsgWatchCount@0 '_GetMsgWatchIndex@4 '_GetMsgWatchValue@4 '_GetPreviousHWND@0 '_GetUnSubClsOnQuitMsg@0 '_MsgWatchExists@4 '_QuitMsgPosted@0 '_RemoveMsgWatch@8 '_SetLastErr@4 '_SetPreviousHWND@4 '_SetUnSubClsOnQuitMsg@4 ' SUBCLS.DLL Subclassing Procedures: '=================================== '_WindowProc@16 ' SUBCLS.DLL - SubClass Procedures Enumeration Public Enum SubClsProcedures WindowProc = 0 SendAsyncProc = 1 End Enum ' SUBCLS.DLL - SubClass Types Public Enum SubClsType WindowsMessages_WindowProc = 0 MessageCallback_SendAsyncProc = 1 End Enum ' SUBCLS.DLL - Error Code Constants Public Const ERRC_NoError = 0 ' No Error Public Const ERRC_MaxCodeMatchReached = 1 ' The maximum number of message watches (100) has been reached Public Const ERRC_WatchAlreadyExists = 2 ' The specified message to watch already exists Public Const ERRC_WatchDoesntExist = 3 ' A watch for the specified message has not been set Public Const ERRC_IndexOutOfBounds = 5 ' The specified watch index is out of bounds (0 to 100) ' Constants - Windows® Messages: '============================== ' ALL MESSAGES: Public Const WM_ALL = (-1) ' Specifies to report all Windows messages recieved ' Keyboard Input Messages: Public Const WM_ACTIVATE = &H6 Public Const WM_CHAR = &H102 Public Const WM_DEADCHAR = &H103 Public Const WM_GETHOTKEY = &H33 Public Const WM_HOTKEY = &H312 Public Const WM_KEYDOWN = &H100 Public Const WM_KEYUP = &H101 Public Const WM_KILLFOCUS = &H8 Public Const WM_SETFOCUS = &H7 Public Const WM_SETHOTKEY = &H32 Public Const WM_SYSCHAR = &H106 Public Const WM_SYSDEADCHAR = &H107 Public Const WM_SYSKEYDOWN = &H104 Public Const WM_SYSKEYUP = &H105 ' Keyboard Accelerator / Menu Related Messages: Public Const WM_COMMAND = &H111 Public Const WM_CONTEXTMENU = &H7B Public Const WM_DRAWITEM = &H2B Public Const WM_ENTERIDLE = &H121 Public Const WM_ENTERMENULOOP = &H211 Public Const WM_EXITMENULOOP = &H212 Public Const WM_INITMENU = &H116 Public Const WM_INITMENUPOPUP = &H117 Public Const WM_MEASUREITEM = &H2C Public Const WM_MENUCHAR = &H120 Public Const WM_MENUCOMMAND = &H126 Public Const WM_MENUDRAG = &H123 Public Const WM_MENUGETOBJECT = &H124 Public Const WM_MENURBUTTONUP = &H122 Public Const WM_MENUSELECT = &H11F Public Const WM_SYSCOMMAND = &H112 Public Const WM_UNINITMENUPOPUP = &H125 ' Mouse Input Messages: Public Const WM_CAPTURECHANGED = &H215 Public Const WM_LBUTTONDBLCLK = &H203 Public Const WM_LBUTTONDOWN = &H201 Public Const WM_LBUTTONUP = &H202 Public Const WM_MBUTTONDBLCLK = &H209 Public Const WM_MBUTTONDOWN = &H207 Public Const WM_MBUTTONUP = &H208 Public Const WM_MOUSEACTIVATE = &H21 Public Const WM_MOUSEMOVE = &H200 Public Const WM_MOUSEWHEEL = &H20A ' For Windows 95, use -> RegisterWindowMessage("MSWHEEL_ROLLMSG") Public Const WM_NCHITTEST = &H84 Public Const WM_NCLBUTTONDBLCLK = &HA3 Public Const WM_NCLBUTTONDOWN = &HA1 Public Const WM_NCLBUTTONUP = &HA2 Public Const WM_NCMBUTTONDBLCLK = &HA9 Public Const WM_NCMBUTTONDOWN = &HA7 Public Const WM_NCMBUTTONUP = &HA8 Public Const WM_NCMOUSEMOVE = &HA0 Public Const WM_NCRBUTTONDBLCLK = &HA6 Public Const WM_NCRBUTTONDOWN = &HA4 Public Const WM_NCRBUTTONUP = &HA5 Public Const WM_RBUTTONDBLCLK = &H206 Public Const WM_RBUTTONDOWN = &H204 Public Const WM_RBUTTONUP = &H205 ' Paint and Drawing Messages: Public Const WM_DISPLAYCHANGE = &H7E Public Const WM_ERASEBKGND = &H14 Public Const WM_ICONERASEBKGND = &H27 Public Const WM_NCPAINT = &H85 Public Const WM_PAINT = &HF Public Const WM_PAINTICON = &H26 Public Const WM_PRINT = &H317 Public Const WM_PRINTCLIENT = &H318 Public Const WM_SETREDRAW = &HB Public Const WM_SYNCPAINT = &H88 ' Windows Messages: Public Const WM_ACTIVATEAPP = &H1C Public Const WM_CANCELMODE = &H1F Public Const WM_CHILDACTIVATE = &H22 Public Const WM_CLOSE = &H10 Public Const WM_COMPACTING = &H41 Public Const WM_CREATE = &H1 Public Const WM_DESTROY = &H2 Public Const WM_ENABLE = &HA Public Const WM_ENTERSIZEMOVE = &H231 Public Const WM_EXITSIZEMOVE = &H232 Public Const WM_GETICON = &H7F Public Const WM_GETMINMAXINFO = &H24 Public Const WM_GETTEXT = &HD Public Const WM_GETTEXTLENGTH = &HE Public Const WM_INPUTLANGCHANGE = &H51 Public Const WM_INPUTLANGCHANGEREQUEST = &H50 Public Const WM_MOVE = &H3 Public Const WM_MOVING = &H216 Public Const WM_NCACTIVATE = &H86 Public Const WM_NCCALCSIZE = &H83 Public Const WM_NCCREATE = &H81 Public Const WM_NCDESTROY = &H82 Public Const WM_PARENTNOTIFY = &H210 Public Const WM_QUERYDRAGICON = &H37 Public Const WM_QUERYOPEN = &H13 Public Const WM_QUIT = &H12 Public Const WM_SETICON = &H80 Public Const WM_SETTEXT = &HC Public Const WM_SETTINGCHANGE = &H1A Public Const WM_SHOWWINDOW = &H18 Public Const WM_SIZE = &H5 Public Const WM_SIZING = &H214 Public Const WM_STYLECHANGING = &H7C Public Const WM_STYLECHANGED = &H7D Public Const WM_USERCHANGED = &H54 Public Const WM_WINDOWPOSCHANGED = &H47 Public Const WM_WINDOWPOSCHANGING = &H46 Public Const WM_WININICHANGE = &H1A ' Control Messages: Public Const WM_GETFONT = &H31 Public Const WM_SETFONT = &H30 ' Other Messages: Public Const WM_USER = &H400 Public Const WM_CAP_START = WM_USER Public Const WM_CAP_UNICODE_START = WM_USER + 100 Public Const WM_CAP_PAL_SAVEW = (WM_CAP_UNICODE_START + 81) Public Const WM_CAP_UNICODE_END = WM_CAP_PAL_SAVEW Public Const WM_ADSPROP_NOTIFY_APPLY = (WM_USER + 1104) ' PAGES SEND THIS TO THE NOTIFICATION OBJECT. Public Const WM_ADSPROP_NOTIFY_CHANGE = (WM_USER + 1103) ' USED TO SEND A CHANGE NOTIFICATION TO A PARENT SHEET Public Const WM_ADSPROP_NOTIFY_EXIT = (WM_USER + 1107) ' SENT ON PAGE RELEASE Public Const WM_ADSPROP_NOTIFY_FOREGROUND = (WM_USER + 1106) ' USED INTERNALLY BY THE NOTIFICATION OBJECT. Public Const WM_ADSPROP_NOTIFY_PAGEHWND = (WM_USER + 1102) ' WHERE WPARAM => PAGE'S HWND Public Const WM_ADSPROP_NOTIFY_PAGEINIT = (WM_USER + 1101) ' WHERE LPARAM IS THE PADSPROPINITPARAMS POINTER. Public Const WM_ADSPROP_NOTIFY_SETFOCUS = (WM_USER + 1105) ' USED INTERNALLY BY THE NOTIFICATION OBJECT. Public Const WM_AFXFIRST = &H360 Public Const WM_AFXLAST = &H37F Public Const WM_APP = &H8000 Public Const WM_APPCOMMAND = &H319 Public Const WM_ASKCBFORMATNAME = &H30C Public Const WM_CANCELJOURNAL = &H4B Public Const WM_CAP_ABORT = (WM_CAP_START + 69) Public Const WM_CAP_DLG_VIDEOCOMPRESSION = (WM_CAP_START + 46) Public Const WM_CAP_DLG_VIDEODISPLAY = (WM_CAP_START + 43) Public Const WM_CAP_DLG_VIDEOFORMAT = (WM_CAP_START + 41) Public Const WM_CAP_DLG_VIDEOSOURCE = (WM_CAP_START + 42) Public Const WM_CAP_DRIVER_CONNECT = (WM_CAP_START + 10) Public Const WM_CAP_DRIVER_DISCONNECT = (WM_CAP_START + 11) Public Const WM_CAP_DRIVER_GET_CAPS = (WM_CAP_START + 14) Public Const WM_CAP_DRIVER_GET_NAMEA = (WM_CAP_START + 12) Public Const WM_CAP_DRIVER_GET_NAME = WM_CAP_DRIVER_GET_NAMEA Public Const WM_CAP_DRIVER_GET_VERSIONA = (WM_CAP_START + 13) Public Const WM_CAP_DRIVER_GET_VERSION = WM_CAP_DRIVER_GET_VERSIONA Public Const WM_CAP_EDIT_COPY = (WM_CAP_START + 30) Public Const WM_CAP_END = WM_CAP_UNICODE_END Public Const WM_CAP_FILE_ALLOCATE = (WM_CAP_START + 22) Public Const WM_CAP_FILE_GET_CAPTURE_FILEA = (WM_CAP_START + 21) Public Const WM_CAP_FILE_GET_CAPTURE_FILE = WM_CAP_FILE_GET_CAPTURE_FILEA Public Const WM_CAP_FILE_SAVEASA = (WM_CAP_START + 23) Public Const WM_CAP_FILE_SAVEAS = WM_CAP_FILE_SAVEASA Public Const WM_CAP_FILE_SAVEDIBA = (WM_CAP_START + 25) Public Const WM_CAP_FILE_SAVEDIB = WM_CAP_FILE_SAVEDIBA Public Const WM_CAP_FILE_SET_CAPTURE_FILEA = (WM_CAP_START + 20) Public Const WM_CAP_FILE_SET_CAPTURE_FILE = WM_CAP_FILE_SET_CAPTURE_FILEA Public Const WM_CAP_FILE_SET_INFOCHUNK = (WM_CAP_START + 24) Public Const WM_CAP_GET_AUDIOFORMAT = (WM_CAP_START + 36) Public Const WM_CAP_GET_CAPSTREAMPTR = (WM_CAP_START + 1) Public Const WM_CAP_GET_MCI_DEVICEA = (WM_CAP_START + 67) Public Const WM_CAP_GET_MCI_DEVICE = WM_CAP_GET_MCI_DEVICEA Public Const WM_CAP_GET_SEQUENCE_SETUP = (WM_CAP_START + 65) Public Const WM_CAP_GET_STATUS = (WM_CAP_START + 54) Public Const WM_CAP_GET_USER_DATA = (WM_CAP_START + 8) Public Const WM_CAP_GET_VIDEOFORMAT = (WM_CAP_START + 44) Public Const WM_CAP_GRAB_FRAME = (WM_CAP_START + 60) Public Const WM_CAP_GRAB_FRAME_NOSTOP = (WM_CAP_START + 61) Public Const WM_CAP_PAL_AUTOCREATE = (WM_CAP_START + 83) Public Const WM_CAP_PAL_MANUALCREATE = (WM_CAP_START + 84) Public Const WM_CAP_PAL_OPENA = (WM_CAP_START + 80) Public Const WM_CAP_PAL_OPEN = WM_CAP_PAL_OPENA Public Const WM_CAP_PAL_PASTE = (WM_CAP_START + 82) Public Const WM_CAP_PAL_SAVEA = (WM_CAP_START + 81) Public Const WM_CAP_PAL_SAVE = WM_CAP_PAL_SAVEA Public Const WM_CAP_SEQUENCE = (WM_CAP_START + 62) Public Const WM_CAP_SEQUENCE_NOFILE = (WM_CAP_START + 63) Public Const WM_CAP_SET_AUDIOFORMAT = (WM_CAP_START + 35) Public Const WM_CAP_SET_CALLBACK_CAPCONTROL = (WM_CAP_START + 85) Public Const WM_CAP_SET_CALLBACK_ERRORA = (WM_CAP_START + 2) Public Const WM_CAP_SET_CALLBACK_ERROR = WM_CAP_SET_CALLBACK_ERRORA Public Const WM_CAP_SET_CALLBACK_FRAME = (WM_CAP_START + 5) Public Const WM_CAP_SET_CALLBACK_STATUSA = (WM_CAP_START + 3) Public Const WM_CAP_SET_CALLBACK_STATUS = WM_CAP_SET_CALLBACK_STATUSA Public Const WM_CAP_SET_CALLBACK_VIDEOSTREAM = (WM_CAP_START + 6) Public Const WM_CAP_SET_CALLBACK_WAVESTREAM = (WM_CAP_START + 7) Public Const WM_CAP_SET_CALLBACK_YIELD = (WM_CAP_START + 4) Public Const WM_CAP_SET_MCI_DEVICEA = (WM_CAP_START + 66) Public Const WM_CAP_SET_MCI_DEVICE = WM_CAP_SET_MCI_DEVICEA Public Const WM_CAP_SET_OVERLAY = (WM_CAP_START + 51) Public Const WM_CAP_SET_PREVIEW = (WM_CAP_START + 50) Public Const WM_CAP_SET_PREVIEWRATE = (WM_CAP_START + 52) Public Const WM_CAP_SET_SCALE = (WM_CAP_START + 53) Public Const WM_CAP_SET_SCROLL = (WM_CAP_START + 55) Public Const WM_CAP_SET_SEQUENCE_SETUP = (WM_CAP_START + 64) Public Const WM_CAP_SET_USER_DATA = (WM_CAP_START + 9) Public Const WM_CAP_SET_VIDEOFORMAT = (WM_CAP_START + 45) Public Const WM_CAP_SINGLE_FRAME = (WM_CAP_START + 72) Public Const WM_CAP_SINGLE_FRAME_CLOSE = (WM_CAP_START + 71) Public Const WM_CAP_SINGLE_FRAME_OPEN = (WM_CAP_START + 70) Public Const WM_CAP_STOP = (WM_CAP_START + 68) Public Const WM_CHANGECBCHAIN = &H30D Public Const WM_CHANGEUISTATE = &H127 Public Const WM_CHARTOITEM = &H2F Public Const WM_CHOOSEFONT_GETLOGFONT = (WM_USER + 1) Public Const WM_CHOOSEFONT_SETFLAGS = (WM_USER + 102) Public Const WM_CHOOSEFONT_SETLOGFONT = (WM_USER + 101) Public Const WM_CLEAR = &H303 Public Const WM_COMMNOTIFY = &H44 ' NO LONGER SUPORTED Public Const WM_COMPAREITEM = &H39 Public Const WM_CONVERTREQUEST = &H10A Public Const WM_CONVERTRESULT = &H10B Public Const WM_COPY = &H301 Public Const WM_COPYDATA = &H4A Public Const WM_CPL_LAUNCH = (WM_USER + 1000) Public Const WM_CPL_LAUNCHED = (WM_USER + 1001) Public Const WM_CTLCOLOR = &H19 Public Const WM_CTLCOLORBTN = &H135 Public Const WM_CTLCOLORDLG = &H136 Public Const WM_CTLCOLOREDIT = &H133 Public Const WM_CTLCOLORLISTBOX = &H134 Public Const WM_CTLCOLORMSGBOX = &H132 Public Const WM_CTLCOLORSCROLLBAR = &H137 Public Const WM_CTLCOLORSTATIC = &H138 Public Const WM_CUT = &H300 Public Const WM_DDE_FIRST = &H3E0 Public Const WM_DDE_ACK = (WM_DDE_FIRST + 4) Public Const WM_DDE_ADVISE = (WM_DDE_FIRST + 2) Public Const WM_DDE_DATA = (WM_DDE_FIRST + 5) Public Const WM_DDE_EXECUTE = (WM_DDE_FIRST + 8) Public Const WM_DDE_INITIATE = (WM_DDE_FIRST) Public Const WM_DDE_LAST = (WM_DDE_FIRST + 8) Public Const WM_DDE_POKE = (WM_DDE_FIRST + 7) Public Const WM_DDE_REQUEST = (WM_DDE_FIRST + 6) Public Const WM_DDE_TERMINATE = (WM_DDE_FIRST + 1) Public Const WM_DDE_UNADVISE = (WM_DDE_FIRST + 3) Public Const WM_DELETEITEM = &H2D Public Const WM_DESTROYCLIPBOARD = &H307 Public Const WM_DEVICECHANGE = &H219 Public Const WM_DEVMODECHANGE = &H1B Public Const WM_DRAWCLIPBOARD = &H308 Public Const WM_DROPFILES = &H233 Public Const WM_ENDSESSION = &H16 Public Const WM_FONTCHANGE = &H1D Public Const WM_FORWARDMSG = &H37F Public Const WM_GETDLGCODE = &H87 Public Const WM_GETOBJECT = &H3D Public Const WM_HANDHELDFIRST = &H358 Public Const WM_HANDHELDLAST = &H35F Public Const WM_HELP = &H53 Public Const WM_HSCROLL = &H114 Public Const WM_HSCROLLCLIPBOARD = &H30E Public Const WM_IME_CHAR = &H286 Public Const WM_IME_COMPOSITION = &H10F Public Const WM_IME_COMPOSITIONFULL = &H284 Public Const WM_IME_CONTROL = &H283 Public Const WM_IME_ENDCOMPOSITION = &H10E Public Const WM_IME_KEYDOWN = &H290 Public Const WM_IME_KEYLAST = &H10F Public Const WM_IME_KEYUP = &H291 Public Const WM_IME_NOTIFY = &H282 Public Const WM_IME_REPORT = &H280 Public Const WM_IME_REQUEST = &H288 Public Const WM_IME_SELECT = &H285 Public Const WM_IME_SETCONTEXT = &H281 Public Const WM_IME_STARTCOMPOSITION = &H10D Public Const WM_IMEKEYDOWN = &H290 Public Const WM_IMEKEYUP = &H291 Public Const WM_INITDIALOG = &H110 Public Const WM_INTERIM = &H10C Public Const WM_KEYFIRST = &H100 Public Const WM_KEYLAST = &H108 Public Const WM_MDIACTIVATE = &H222 Public Const WM_MDICASCADE = &H227 Public Const WM_MDICREATE = &H220 Public Const WM_MDIDESTROY = &H221 Public Const WM_MDIGETACTIVE = &H229 Public Const WM_MDIICONARRANGE = &H228 Public Const WM_MDIMAXIMIZE = &H225 Public Const WM_MDINEXT = &H224 Public Const WM_MDIREFRESHMENU = &H234 Public Const WM_MDIRESTORE = &H223 Public Const WM_MDISETMENU = &H230 Public Const WM_MDITILE = &H226 Public Const WM_MOUSEFIRST = &H200 Public Const WM_MOUSEHOVER = &H2A1 Public Const WM_MOUSELAST = &H20A Public Const WM_MOUSELEAVE = &H2A3 Public Const WM_NCMOUSEHOVER = &H2A0 Public Const WM_NCMOUSELEAVE = &H2A2 Public Const WM_NCXBUTTONDBLCLK = &HAD Public Const WM_NCXBUTTONDOWN = &HAB Public Const WM_NCXBUTTONUP = &HAC Public Const WM_NEXTDLGCTL = &H28 Public Const WM_NEXTMENU = &H213 Public Const WM_NOTIFY = &H4E Public Const WM_NOTIFYFORMAT = &H55 Public Const WM_NULL = &H0 Public Const WM_PAINTCLIPBOARD = &H309 Public Const WM_PALETTECHANGED = &H311 Public Const WM_PALETTEISCHANGING = &H310 Public Const WM_PASTE = &H302 Public Const WM_PENWINFIRST = &H380 Public Const WM_PENWINLAST = &H38F Public Const WM_POWER = &H48 Public Const WM_POWERBROADCAST = &H218 Public Const WM_PSD_ENVSTAMPRECT = (WM_USER + 5) Public Const WM_PSD_FULLPAGERECT = (WM_USER + 1) Public Const WM_PSD_GREEKTEXTRECT = (WM_USER + 4) Public Const WM_PSD_MARGINRECT = (WM_USER + 3) Public Const WM_PSD_MINMARGINRECT = (WM_USER + 2) Public Const WM_PSD_PAGESETUPDLG = (WM_USER) Public Const WM_PSD_YAFULLPAGERECT = (WM_USER + 6) Public Const WM_QUERYENDSESSION = &H11 Public Const WM_QUERYNEWPALETTE = &H30F Public Const WM_QUERYUISTATE = &H129 Public Const WM_QUEUESYNC = &H23 Public Const WM_RASDIALEVENT = &HCCCD Public Const WM_RENDERALLFORMATS = &H306 Public Const WM_RENDERFORMAT = &H305 Public Const WM_SETCURSOR = &H20 Public Const WM_SIZECLIPBOARD = &H30B Public Const WM_SPOOLERSTATUS = &H2A Public Const WM_SYSCOLORCHANGE = &H15 Public Const WM_TCARD = &H52 Public Const WM_TIMECHANGE = &H1E Public Const WM_TIMER = &H113 Public Const WM_UNDO = &H304 Public Const WM_UPDATEUISTATE = &H128 Public Const WM_VKEYTOITEM = &H2E Public Const WM_VSCROLL = &H115 Public Const WM_VSCROLLCLIPBOARD = &H30A Public Const WM_WNT_CONVERTREQUESTEX = &H109 ' WM_CONVERTREQUESTEX: 109 FOR NT, 108 FOR OT Public Const WM_XBUTTONDBLCLK = &H20D Public Const WM_XBUTTONDOWN = &H20B Public Const WM_XBUTTONUP = &H20C ' Constants - General Public Const MAX_PATH = 260 ' Constants - GetWindowLong / SetWindowLong Public Const GWL_WNDPROC = (-4) ' Sets a new address for the window procedure. Public Const GWL_HINSTANCE = (-6) ' Sets a new application instance handle. Public Const GWL_ID = (-12) ' Sets a new identifier of the window. Public Const GWL_STYLE = (-16) ' Sets a new window style. Public Const GWL_EXSTYLE = (-20) ' Sets a new extended window style. Public Const GWL_USERDATA = (-21) ' Sets the 32-bit value associated with the window. Each window has a corresponding 32-bit value intended for use by the application that created the window. Public Const DWL_DLGPROC = 0 ' Sets the new address of the dialog box procedure. Public Const DWL_MSGRESULT = 4 ' Sets the return value of a message processed in the dialog box procedure. Public Const DWL_USER = 8 ' Sets new extra information that is private to the application, such as handles or pointers. ' Constants - SendMessageCallback Public Const HWND_BROADCAST = &HFFFF ' Constants - FormatMessage.dwFlags Public Const FORMAT_MESSAGE_ALLOCATE_BUFFER = &H100 ' Specifies that the lpBuffer parameter is a pointer to a PVOID pointer, and that the nSize parameter specifies the minimum number of TCHARs to allocate for an output message buffer. The function allocates a buffer large enough to hold the formatted message, and places a pointer to the allocated buffer at the address specified by lpBuffer. The caller should use the LocalFree function to free the buffer when it is no longer needed. Public Const FORMAT_MESSAGE_IGNORE_INSERTS = &H200 ' Specifies that insert sequences in the message definition are to be ignored and passed through to the output buffer unchanged. This flag is useful for fetching a message for later formatting. If this flag is set, the Arguments parameter is ignored. Public Const FORMAT_MESSAGE_FROM_STRING = &H400 ' Specifies that lpSource is a pointer to a null-terminated message definition. The message definition may contain insert sequences, just as the message text in a message table resource may. Cannot be used with FORMAT_MESSAGE_FROM_HMODULE or FORMAT_MESSAGE_FROM_SYSTEM. Public Const FORMAT_MESSAGE_FROM_HMODULE = &H800 ' Specifies that lpSource is a module handle containing the message-table resource(s) to search. If this lpSource handle is NULL, the current process's application image file will be searched. Cannot be used with FORMAT_MESSAGE_FROM_STRING. Public Const FORMAT_MESSAGE_FROM_SYSTEM = &H1000 ' Specifies that the function should search the system message-table resource(s) for the requested message. If this flag is specified with FORMAT_MESSAGE_FROM_HMODULE, the function searches the system message table if the message is not found in the module specified by lpSource. Cannot be used with FORMAT_MESSAGE_FROM_STRING. If this flag is specified, an application can pass the result of the GetLastError function to retrieve the message text for a system-defined error. Public Const FORMAT_MESSAGE_ARGUMENT_ARRAY = &H2000 ' Specifies that the Arguments parameter is not a va_list structure, but instead is just a pointer to an array of values that represent the arguments. ' Public Variables Public StopMsgLoop As Boolean Public PreviousProc As Long Public PreviousHWND As Long ' Function Declarations - SUBCLS.DLL Public Declare Sub SC_ClearAllMsgWatches Lib "SUBCLS.DLL" Alias "_ClearAllMsgWatches@0" () Public Declare Sub SC_ClearLastErr Lib "SUBCLS.DLL" Alias "_ClearLastErr@0" () Public Declare Sub SC_ClearQuitMsg Lib "SUBCLS.DLL" Alias "_ClearQuitMsg@0" () Public Declare Sub SC_GetMessageInfo Lib "SUBCLS.DLL" Alias "_GetMessageInfo@16" (ByRef lpHWND As Long, ByRef puMsg As Long, ByRef lpWPARAM As Long, ByRef lpLPARAM As Long) Public Declare Sub SC_SetLastErr Lib "SUBCLS.DLL" Alias "_SetLastErr@4" (ByVal iErrNum As Long) Public Declare Sub SC_SetPreviousHWND Lib "SUBCLS.DLL" Alias "_SetPreviousHWND@4" (ByVal hWnd As Long) Public Declare Sub SC_SetUnSubClsOnQuitMsg Lib "SUBCLS.DLL" Alias "_SetUnSubClsOnQuitMsg@4" (ByVal NewValue As Long) ' Sets BOOL Public Declare Function SC_AddMsgWatch Lib "SUBCLS.DLL" Alias "_AddMsgWatch@4" (ByVal uMsg As Long) As Long ' Returns BOOL Public Declare Function SC_GetHInstance Lib "SUBCLS.DLL" Alias "_GetHInstance@0" () As Long Public Declare Function SC_GetLastErr Lib "SUBCLS.DLL" Alias "_GetLastErr@0" () As Long Public Declare Function SC_GetMsgWatchCount Lib "SUBCLS.DLL" Alias "_GetMsgWatchCount@0" () As Long Public Declare Function SC_GetMsgWatchIndex Lib "SUBCLS.DLL" Alias "_GetMsgWatchIndex@4" (ByVal uMsg As Long) As Long Public Declare Function SC_GetMsgWatchValue Lib "SUBCLS.DLL" Alias "_GetMsgWatchValue@4" (ByVal iIndex As Long) As Long Public Declare Function SC_GetPreviousHWND Lib "SUBCLS.DLL" Alias "_GetPreviousHWND@0" () As Long Public Declare Function SC_GetUnSubClsOnQuitMsg Lib "SUBCLS.DLL" Alias "_GetUnSubClsOnQuitMsg@0" () As Long Public Declare Function SC_MsgWatchExists Lib "SUBCLS.DLL" Alias "_MsgWatchExists@4" (ByVal uMsg As Long) As Long ' Returns BOOL Public Declare Function SC_QuitMsgPosted Lib "SUBCLS.DLL" Alias "_QuitMsgPosted@0" () As Long ' Returns BOOL Public Declare Function SC_RemoveMsgWatch Lib "SUBCLS.DLL" Alias "_RemoveMsgWatch@8" (ByVal uMsg As Long, ByVal iIndex As Long) As Long ' Returns BOOL ' Win32 API Declarations Public Declare Sub SetLastError Lib "KERNEL32" (ByVal dwErrCode As Long) Public Declare Function FormatMessage Lib "KERNEL32" Alias "FormatMessageA" (ByVal dwFlags As Long, ByRef lpSource As Any, ByVal dwMessageId As Long, ByVal dwLanguageId As Long, ByVal lpBuffer As String, ByVal nSize As Long, ByRef Arguments As Long) As Long Public Declare Function FreeLibrary Lib "KERNEL32" (ByVal hLibModule As Long) As Long ' Returns BOOL Public Declare Function IsWindow Lib "USER32" (ByVal hWnd As Long) As Long Public Declare Function LoadLibrary Lib "KERNEL32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long Public Declare Function GetInputState Lib "USER32" () As Long Public Declare Function GetLastError Lib "KERNEL32" () As Long Public Declare Function GetProcAddress Lib "KERNEL32" (ByVal hModule As Long, ByVal lpProcName As String) As Long Public Declare Function SetWindowLong Lib "USER32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Public Declare Function SendMessageCallback Lib "USER32" Alias "SendMessageCallbackA" (ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long, ByVal lpResultCallBack As Long, ByVal dwData As Long) As Long ' Returns BOOL Public Declare Function WaitMessage Lib "USER32" () As Long 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ' ' THIS IS WHERE THE MESSAGES RECIEVED BY THE "SUBCLS.DLL" HOOK PROCEDURES ARE REPORTED ' ' >>> PUT YOUR CODE WITHIN THIS SUB <<< ' '----------------------------------------------------------------------------------------------------------- ' Public Sub MessageEvent(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) On Error Resume Next Debug.Print "MSG : hWnd = " & CStr(hWnd) & ", uMsg = " & GetMsgSTR(uMsg) & ", wParam = " & CStr(wParam) & ", lParam = " & CStr(lParam) End Sub ' 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX '=========================================================================================================== ' AddMsgWatch ' ' Purpose : ' Clears all message watches. After calling this function, nothing will be reported until the "AddMsgWatch" ' function is called to specify one. ' ' Param Use ' ------------------------------------ ' uMsg This specifies which Windows® message to report when it is encountered. ' Refer to the list of declared message constants above : WM_* ' ' Return ' ------ ' If succeeded, returns TRUE ' If failed, returns FALSE ' '=========================================================================================================== Public Function AddMsgWatch(ByVal uMsg As Long) As Boolean ' Remove the WM_ALL message which reports all messages If SC_MsgWatchExists(WM_ALL) <> 0 Then SC_RemoveMsgWatch WM_ALL, 0 End If ' If the specified message already exists, exit function If SC_MsgWatchExists(uMsg) <> 0 Then AddMsgWatch = True Exit Function End If ' Attempt to add the message watch If SC_AddMsgWatch(uMsg) <> 0 Then AddMsgWatch = True ' An error occured - refer to the ERRC_* error constants for more details Else MsgBox "The following error occured while trying to add a watch for message '" & _ CStr(uMsg) & "' :" & Chr(13) & Chr(13) & "Error Code = " & CStr(SC_GetLastErr), _ vbOKOnly + vbExclamation, " Error" End If End Function '=========================================================================================================== ' ClearAllMsgWatches ' ' Purpose : ' Clears all message watches. After calling this function, nothing will be reported until the "AddMsgWatch" ' function is called to specify one. ' ' Param Use ' ------------------------------------ ' None ' ' Return ' ------ ' If succeeded, returns TRUE ' If failed, returns FALSE ' '=========================================================================================================== Public Function ClearAllMsgWatches() As Boolean SC_ClearAllMsgWatches If SC_AddMsgWatch(WM_ALL) <> 0 Then ClearAllMsgWatches = True End If End Function '=========================================================================================================== ' InstallSubClass ' ' Purpose : ' When called, this function subclasses the window specified by the "hWnd" parameter and starts the MsgLoop ' to start reporting any errors that are currently specified to report on. ' ' Param Use ' ------------------------------------ ' hWnd The number of the message to find the constant name for ' UseAlternateProc If this is set to TRUE, then the address specified in the "AlternateProcAddress" ' parameter is used to subclass the specified window. Otherwise, SUBCLS.DLL takes ' over the subclassing and messages are reported to the "MessageEvent" routine. ' AlternateProcAddress Optional. If the "UseAlternateProc" parameter is set to TRUE, then this parameter ' specifies the address of the routine to handle the subclassing. ' OnlyReportNewMessages Optional. If this parameter is set to TRUE (default), then only new Windows® ' messages are reported. This is HIGHLY recommended so that the "MessageEvent" ' routine does not get flooded with redundant message reports. If this is set to ' FALSE, then ALL recieved message reports will be posted to "MessageEvent" ' ' Return ' ------ ' If succeeded, returns TRUE ' If failed, returns FALSE ' '=========================================================================================================== Public Function InstallSubClass(ByVal hWnd As Long, _ ByVal UseAlternateProc As Boolean, _ Optional ByVal AlternateProcAddress As Long, _ Optional ByVal OnlyReportNewMessages As Boolean = True) As Boolean On Error Resume Next Dim NewProc As Long Dim ReturnValue As Long Dim ThreadMine As Long Dim ThreadYours As Long ' Make sure that the window handle is valid If hWnd = 0 Then Exit Function ElseIf (UseAlternateProc = True) And (AlternateProcAddress = 0) Then Exit Function End If ' Uninstall any existing sub-classes UninstallSubClass ' If user specified to use alternate sublcass procedure, use it instead (if it's valid) If UseAlternateProc = True Then NewProc = AlternateProcAddress ' User specified to use the subclass procedure within SUBCLS.DLL Else NewProc = GetWindowProcAddress If NewProc = 0 Then Exit Function End If End If ' Call the function that subclasses the specified window by changing it's Window Procedure address PreviousProc = SetWindowLong(hWnd, GWL_WNDPROC, NewProc) If PreviousProc = 0 Then ' Error GetLastErr_Msg GetLastError, "SetWindowLong", , True Exit Function Else PreviousHWND = hWnd StopMsgLoop = False InstallSubClass = True ' Start the message loop if using the DLL If UseAlternateProc = False Then ' Make sure the previous procedure is stored SC_SetPreviousHWND PreviousProc If SC_GetPreviousHWND = 0 Then UninstallSubClass End If ' Make sure the DLL unsubclasses on the WM_DESTROY or WM_QUIT messages If SC_GetUnSubClsOnQuitMsg = 0 Then SC_SetUnSubClsOnQuitMsg 1 End If MsgLoop OnlyReportNewMessages End If End If End Function '=========================================================================================================== ' RemoveMsgWatch ' ' Purpose : ' This routine removes the specified message, so that that message is no longer reported. To remove all ' messages quickly and easily, call the "ClearAllMsgWatches" function. ' ' For a list of Windows® messages, refer to the WM_* constant values declared above. ' ' Param Use ' ------------------------------------ ' uMsg Specifies which Windows® message to stop reporting on ' ' Return ' ------ ' If succeeds, returns TRUE ' If Fails, returns FALSE ' '=========================================================================================================== Public Function RemoveMsgWatch(ByVal uMsg As Long) As Boolean If SC_MsgWatchExists(uMsg) <> 0 Then SC_RemoveMsgWatch uMsg, 0 End If RemoveMsgWatch = True End Function '=========================================================================================================== ' UninstallSubClass ' ' Purpose : ' This routine stops any current subclassing that is in progress and exits the MsgLoop. This does NOT ' remove specified messages, it just stops reporting them. To remove messages, call the "RemoveMsgWatch" ' or "ClearAllMsgWatches" functions. ' ' Param Use ' ------------------------------------ ' None ' ' Return ' ------ ' If succeeds, returns TRUE ' If Fails, returns FALSE ' '=========================================================================================================== Public Function UninstallSubClass() As Boolean On Error Resume Next If PreviousProc = 0 Or IsWindow(PreviousHWND) = 0 Then PreviousHWND = 0 PreviousProc = 0 StopMsgLoop = True UninstallSubClass = True ElseIf PreviousProc <> -1 Then If SetWindowLong(PreviousHWND, GWL_WNDPROC, PreviousProc) = 0 Then GetLastErr_Msg GetLastError, "SetWindowLong", , True End If PreviousHWND = 0 PreviousProc = 0 StopMsgLoop = True UninstallSubClass = True End If End Function 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXX THE FOLLOWING SUBS/FUNCTIONS ARE ONLY USED WITHIN THIS MODULE XXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX '=========================================================================================================== ' MsgLoop ' ' Purpose : ' This is the main loop that continually goes out and checks for messages and returns them if there are any. ' If any messages are found, they are reported to the "MessageEvent" sub so the user can perform an action ' if a specific message is picked up. ' ' Param Use ' ------------------------------------ ' OnlyReportNewMessages If this parameter is set to FALSE (default), then only new messages are reported. ' This is recommended to prevent the MessageEvent sub from being flooded with ' redundant message reports. ' If this parameter is set to TRUE, then all specified messages are reported to the ' MessageEvent sub (unless you specify one or more messages to be reported, ALL ' messages are reported). ' ' Return ' ------ ' None ' '=========================================================================================================== Private Sub MsgLoop(Optional ByVal OnlyReportNewMessages As Boolean = False) On Error Resume Next Dim hWnd As Long Dim uMsg As Long Dim wParam As Long Dim lParam As Long Dim Previous_hWnd As Long Dim Previous_uMsg As Long Dim Previous_wParam As Long Dim Previous_lParam As Long Do ' Check if there are keyboard or mouse movements that need to be processed DoEvents ' Go into a continuous loop until the loop is stopped or the handle becomes invalid If StopMsgLoop = True Then GoTo ExitLoop If IsWindow(PreviousHWND) = 0 Then GoTo ExitLoop ' Get the parameters passed to the hook procedure in SUBCLS.DLL SC_GetMessageInfo hWnd, uMsg, wParam, lParam ' Report everyone called If OnlyReportNewMessages = False Then MessageEvent hWnd, uMsg, wParam, lParam Else ' Check if any of the parameters have changed, and if so, call the MessageEvent function with that info If (hWnd <> Previous_hWnd) Or (uMsg <> Previous_uMsg) Or (wParam <> Previous_wParam) Or (lParam <> Previous_lParam) Then Previous_hWnd = hWnd Previous_uMsg = uMsg Previous_wParam = wParam Previous_lParam = lParam MessageEvent hWnd, uMsg, wParam, lParam End If End If Loop ExitLoop: UninstallSubClass End Sub '=========================================================================================================== ' GetWindowProcAddress ' ' Purpose : ' Function that returns the address to the WindowProc procedure inside the SUBCLS.DLL ' ' Param Use ' ------------------------------------ ' None ' ' Return ' ------ ' Returns the address of the the SUBCLS.DLL library ' '=========================================================================================================== Private Function GetWindowProcAddress() As Long On Error GoTo ErrorTrap Dim hDLL As Long ' Get the handle to the library to load hDLL = LoadLibrary("SUBCLS.DLL") If hDLL = 0 Then Exit Function End If ' Return the address of the procedure specified GetWindowProcAddress = GetProcAddress(hDLL, "_WindowProc@16") If GetWindowProcAddress = 0 Then GetLastErr_Msg GetLastError, "GetProcAddress", , True End If ' Free up the dll FreeLibrary hDLL Exit Function ErrorTrap: If Err.Number = 0 Then ' No Error Resume Next ElseIf Err.Number = 20 Then ' Resume Without Error Resume Next Else ' Unknown Error MsgBox Err.Source & " encountered the following error:" & Chr(13) & Chr(13) & "Error Number = " & CStr(Err.Number) & Chr(13) & "Error Description = " & Err.Description, vbOKOnly + vbExclamation, " Error - " & Err.Description Err.Clear Err.Number = 0 End If End Function '=========================================================================================================== ' GetMsgSTR ' ' Purpose : ' This function returns the name of the constant that represents the value passed in the uMsg parameter. ' This function is meant for debugging or status information where the name of the constant would mean ' more to a user or programmer than a message number would. ' ' Param Use ' ------------------------------------ ' uMsg The number of the message to find the constant name for ' ' Return ' ------ ' Returns the name of the constant for the most common messages, and the message number for the less ' common ones. ' '=========================================================================================================== Public Function GetMsgSTR(ByVal uMsg As Long) As String Select Case uMsg Case WM_ACTIVATE: GetMsgSTR = "WM_ACTIVATE" Case WM_CHAR: GetMsgSTR = "WM_CHAR" Case WM_DEADCHAR: GetMsgSTR = "WM_DEADCHAR" Case WM_GETHOTKEY: GetMsgSTR = "WM_GETHOTKEY" Case WM_HOTKEY: GetMsgSTR = "WM_HOTKEY" Case WM_KEYDOWN: GetMsgSTR = "WM_KEYDOWN" Case WM_KEYUP: GetMsgSTR = "WM_KEYUP" Case WM_KILLFOCUS: GetMsgSTR = "WM_KILLFOCUS" Case WM_SETFOCUS: GetMsgSTR = "WM_SETFOCUS" Case WM_SETHOTKEY: GetMsgSTR = "WM_SETHOTKEY" Case WM_SYSCHAR: GetMsgSTR = "WM_SYSCHAR" Case WM_SYSDEADCHAR: GetMsgSTR = "WM_SYSDEADCHAR" Case WM_SYSKEYDOWN: GetMsgSTR = "WM_SYSKEYDOWN" Case WM_SYSKEYUP: GetMsgSTR = "WM_SYSKEYUP" Case WM_COMMAND: GetMsgSTR = "WM_COMMAND" Case WM_INITMENU: GetMsgSTR = "WM_INITMENU" Case WM_INITMENUPOPUP: GetMsgSTR = "WM_INITMENUPOPUP" Case WM_MENUCHAR: GetMsgSTR = "WM_MENUCHAR" Case WM_MENUSELECT: GetMsgSTR = "WM_MENUSELECT" Case WM_SYSCOMMAND: GetMsgSTR = "WM_SYSCOMMAND" Case WM_CAPTURECHANGED: GetMsgSTR = "WM_CAPTURECHANGED" Case WM_LBUTTONDBLCLK: GetMsgSTR = "WM_LBUTTONDBLCLK" Case WM_LBUTTONDOWN: GetMsgSTR = "WM_LBUTTONDOWN" Case WM_LBUTTONUP: GetMsgSTR = "WM_LBUTTONUP" Case WM_MBUTTONDBLCLK: GetMsgSTR = "WM_MBUTTONDBLCLK" Case WM_MBUTTONDOWN: GetMsgSTR = "WM_MBUTTONDOWN" Case WM_MBUTTONUP: GetMsgSTR = "WM_MBUTTONUP" Case WM_MOUSEACTIVATE: GetMsgSTR = "WM_MOUSEACTIVATE" Case WM_MOUSEMOVE: GetMsgSTR = "WM_MOUSEMOVE" Case WM_MOUSEWHEEL: GetMsgSTR = "WM_MOUSEWHEEL" Case WM_NCHITTEST: GetMsgSTR = "WM_NCHITTEST" Case WM_NCLBUTTONDBLCLK: GetMsgSTR = "WM_NCLBUTTONDBLCLK" Case WM_NCLBUTTONDOWN: GetMsgSTR = "WM_NCLBUTTONDOWN" Case WM_NCLBUTTONUP: GetMsgSTR = "WM_NCLBUTTONUP" Case WM_NCMBUTTONDBLCLK: GetMsgSTR = "WM_NCMBUTTONDBLCLK" Case WM_NCMBUTTONDOWN: GetMsgSTR = "WM_NCMBUTTONDOWN" Case WM_NCMBUTTONUP: GetMsgSTR = "WM_NCMBUTTONUP" Case WM_NCMOUSEMOVE: GetMsgSTR = "WM_NCMOUSEMOVE" Case WM_NCRBUTTONDBLCLK: GetMsgSTR = "WM_NCRBUTTONDBLCLK" Case WM_NCRBUTTONDOWN: GetMsgSTR = "WM_NCRBUTTONDOWN" Case WM_NCRBUTTONUP: GetMsgSTR = "WM_NCRBUTTONUP" Case WM_RBUTTONDBLCLK: GetMsgSTR = "WM_RBUTTONDBLCLK" Case WM_RBUTTONDOWN: GetMsgSTR = "WM_RBUTTONDOWN" Case WM_RBUTTONUP: GetMsgSTR = "WM_RBUTTONUP" Case WM_DISPLAYCHANGE: GetMsgSTR = "WM_DISPLAYCHANGE" Case WM_ERASEBKGND: GetMsgSTR = "WM_ERASEBKGND" Case WM_ICONERASEBKGND: GetMsgSTR = "WM_ICONERASEBKGND" Case WM_NCPAINT: GetMsgSTR = "WM_NCPAINT" Case WM_PAINT: GetMsgSTR = "WM_PAINT" Case WM_PAINTICON: GetMsgSTR = "WM_PAINTICON" Case WM_PRINT: GetMsgSTR = "WM_PRINT" Case WM_PRINTCLIENT: GetMsgSTR = "WM_PRINTCLIENT" Case WM_SETREDRAW: GetMsgSTR = "WM_SETREDRAW" Case WM_SYNCPAINT: GetMsgSTR = "WM_SYNCPAINT" Case WM_ACTIVATEAPP: GetMsgSTR = "WM_ACTIVATEAPP" Case WM_CANCELMODE: GetMsgSTR = "WM_CANCELMODE" Case WM_CHILDACTIVATE: GetMsgSTR = "WM_CHILDACTIVATE" Case WM_CLOSE: GetMsgSTR = "WM_CLOSE" Case WM_COMPACTING: GetMsgSTR = "WM_COMPACTING" Case WM_CREATE: GetMsgSTR = "WM_CREATE" Case WM_DESTROY: GetMsgSTR = "WM_DESTROY" Case WM_ENABLE: GetMsgSTR = "WM_ENABLE" Case WM_ENTERSIZEMOVE: GetMsgSTR = "WM_ENTERSIZEMOVE" Case WM_EXITSIZEMOVE: GetMsgSTR = "WM_EXITSIZEMOVE" Case WM_GETICON: GetMsgSTR = "WM_GETICON" Case WM_GETMINMAXINFO: GetMsgSTR = "WM_GETMINMAXINFO" Case WM_GETTEXT: GetMsgSTR = "WM_GETTEXT" Case WM_GETTEXTLENGTH: GetMsgSTR = "WM_GETTEXTLENGTH" Case WM_INPUTLANGCHANGE: GetMsgSTR = "WM_INPUTLANGCHANGE" Case WM_INPUTLANGCHANGEREQUEST: GetMsgSTR = "WM_INPUTLANGCHANGEREQUEST" Case WM_MOVE: GetMsgSTR = "WM_MOVE" Case WM_MOVING: GetMsgSTR = "WM_MOVING" Case WM_NCACTIVATE: GetMsgSTR = "WM_NCACTIVATE" Case WM_NCCALCSIZE: GetMsgSTR = "WM_NCCALCSIZE" Case WM_NCCREATE: GetMsgSTR = "WM_NCCREATE" Case WM_NCDESTROY: GetMsgSTR = "WM_NCDESTROY" Case WM_PARENTNOTIFY: GetMsgSTR = "WM_PARENTNOTIFY" Case WM_QUERYDRAGICON: GetMsgSTR = "WM_QUERYDRAGICON" Case WM_QUERYOPEN: GetMsgSTR = "WM_QUERYOPEN" Case WM_QUIT: GetMsgSTR = "WM_QUIT" Case WM_SETICON: GetMsgSTR = "WM_SETICON" Case WM_SETTEXT: GetMsgSTR = "WM_SETTEXT" Case WM_SETTINGCHANGE: GetMsgSTR = "WM_SETTINGCHANGE" Case WM_SHOWWINDOW: GetMsgSTR = "WM_SHOWWINDOW" Case WM_SIZE: GetMsgSTR = "WM_SIZE" Case WM_SIZING: GetMsgSTR = "WM_SIZING" Case WM_STYLECHANGING: GetMsgSTR = "WM_STYLECHANGING" Case WM_STYLECHANGED: GetMsgSTR = "WM_STYLECHANGED" Case WM_USERCHANGED: GetMsgSTR = "WM_USERCHANGED" Case WM_WINDOWPOSCHANGED: GetMsgSTR = "WM_WINDOWPOSCHANGED" Case WM_WINDOWPOSCHANGING: GetMsgSTR = "WM_WINDOWPOSCHANGING" Case WM_WININICHANGE: GetMsgSTR = "WM_WININICHANGE" Case WM_GETFONT: GetMsgSTR = "WM_GETFONT" Case WM_SETFONT: GetMsgSTR = "WM_SETFONT" Case WM_USER: GetMsgSTR = "WM_USER" Case WM_CAP_START: GetMsgSTR = "WM_CAP_START" Case WM_CAP_UNICODE_START: GetMsgSTR = "WM_CAP_UNICODE_START" Case WM_CAP_PAL_SAVEW: GetMsgSTR = "WM_CAP_PAL_SAVEW" Case WM_CAP_UNICODE_END: GetMsgSTR = "WM_CAP_UNICODE_END" Case WM_ADSPROP_NOTIFY_APPLY: GetMsgSTR = "WM_ADSPROP_NOTIFY_APPLY" Case WM_ADSPROP_NOTIFY_CHANGE: GetMsgSTR = "WM_ADSPROP_NOTIFY_CHANGE" Case WM_ADSPROP_NOTIFY_EXIT: GetMsgSTR = "WM_ADSPROP_NOTIFY_EXIT" Case WM_ADSPROP_NOTIFY_FOREGROUND: GetMsgSTR = "WM_ADSPROP_NOTIFY_FOREGROUND" Case WM_ADSPROP_NOTIFY_PAGEHWND: GetMsgSTR = "WM_ADSPROP_NOTIFY_PAGEHWND" Case WM_ADSPROP_NOTIFY_PAGEINIT: GetMsgSTR = "WM_ADSPROP_NOTIFY_PAGEINIT" Case WM_ADSPROP_NOTIFY_SETFOCUS: GetMsgSTR = "WM_ADSPROP_NOTIFY_SETFOCUS" Case WM_AFXFIRST: GetMsgSTR = "WM_AFXFIRST" Case WM_AFXLAST: GetMsgSTR = "WM_AFXLAST" Case WM_APP: GetMsgSTR = "WM_APP" Case WM_APPCOMMAND: GetMsgSTR = "WM_APPCOMMAND" Case WM_ASKCBFORMATNAME: GetMsgSTR = "WM_ASKCBFORMATNAME" Case WM_CANCELJOURNAL: GetMsgSTR = "WM_CANCELJOURNAL" Case WM_CAP_ABORT: GetMsgSTR = "WM_CAP_ABORT" Case WM_CAP_DLG_VIDEOCOMPRESSION: GetMsgSTR = "WM_CAP_DLG_VIDEOCOMPRESSION" Case WM_CAP_DLG_VIDEODISPLAY: GetMsgSTR = "WM_CAP_DLG_VIDEODISPLAY" Case WM_CAP_DLG_VIDEOFORMAT: GetMsgSTR = "WM_CAP_DLG_VIDEOFORMAT" Case WM_CAP_DLG_VIDEOSOURCE: GetMsgSTR = "WM_CAP_DLG_VIDEOSOURCE" Case WM_CAP_DRIVER_CONNECT: GetMsgSTR = "WM_CAP_DRIVER_CONNECT" Case WM_CAP_DRIVER_DISCONNECT: GetMsgSTR = "WM_CAP_DRIVER_DISCONNECT" Case WM_CAP_DRIVER_GET_CAPS: GetMsgSTR = "WM_CAP_DRIVER_GET_CAPS" Case WM_CAP_DRIVER_GET_NAMEA: GetMsgSTR = "WM_CAP_DRIVER_GET_NAMEA" Case WM_CAP_DRIVER_GET_NAME: GetMsgSTR = "WM_CAP_DRIVER_GET_NAME" Case WM_CAP_DRIVER_GET_VERSIONA: GetMsgSTR = "WM_CAP_DRIVER_GET_VERSIONA" Case WM_CAP_DRIVER_GET_VERSION: GetMsgSTR = "WM_CAP_DRIVER_GET_VERSION" Case WM_CAP_EDIT_COPY: GetMsgSTR = "WM_CAP_EDIT_COPY" Case WM_CAP_END: GetMsgSTR = "WM_CAP_END" Case WM_CAP_FILE_ALLOCATE: GetMsgSTR = "WM_CAP_FILE_ALLOCATE" Case WM_CAP_FILE_GET_CAPTURE_FILEA: GetMsgSTR = "WM_CAP_FILE_GET_CAPTURE_FILEA" Case WM_CAP_FILE_GET_CAPTURE_FILE: GetMsgSTR = "WM_CAP_FILE_GET_CAPTURE_FILE" Case WM_CAP_FILE_SAVEASA: GetMsgSTR = "WM_CAP_FILE_SAVEASA" Case WM_CAP_FILE_SAVEAS: GetMsgSTR = "WM_CAP_FILE_SAVEAS" Case WM_CAP_FILE_SAVEDIBA: GetMsgSTR = "WM_CAP_FILE_SAVEDIBA" Case WM_CAP_FILE_SAVEDIB: GetMsgSTR = "WM_CAP_FILE_SAVEDIB" Case WM_CAP_FILE_SET_CAPTURE_FILEA: GetMsgSTR = "WM_CAP_FILE_SET_CAPTURE_FILEA" Case WM_CAP_FILE_SET_CAPTURE_FILE: GetMsgSTR = "WM_CAP_FILE_SET_CAPTURE_FILE" Case WM_CAP_FILE_SET_INFOCHUNK: GetMsgSTR = "WM_CAP_FILE_SET_INFOCHUNK" Case WM_CAP_GET_AUDIOFORMAT: GetMsgSTR = "WM_CAP_GET_AUDIOFORMAT" Case WM_CAP_GET_CAPSTREAMPTR: GetMsgSTR = "WM_CAP_GET_CAPSTREAMPTR" Case WM_CAP_GET_MCI_DEVICEA: GetMsgSTR = "WM_CAP_GET_MCI_DEVICEA" Case WM_CAP_GET_MCI_DEVICE: GetMsgSTR = "WM_CAP_GET_MCI_DEVICE" Case WM_CAP_GET_SEQUENCE_SETUP: GetMsgSTR = "WM_CAP_GET_SEQUENCE_SETUP" Case WM_CAP_GET_STATUS: GetMsgSTR = "WM_CAP_GET_STATUS" Case WM_CAP_GET_USER_DATA: GetMsgSTR = "WM_CAP_GET_USER_DATA" Case WM_CAP_GET_VIDEOFORMAT: GetMsgSTR = "WM_CAP_GET_VIDEOFORMAT" Case WM_CAP_GRAB_FRAME: GetMsgSTR = "WM_CAP_GRAB_FRAME" Case WM_CAP_GRAB_FRAME_NOSTOP: GetMsgSTR = "WM_CAP_GRAB_FRAME_NOSTOP" Case WM_CAP_PAL_AUTOCREATE: GetMsgSTR = "WM_CAP_PAL_AUTOCREATE" Case WM_CAP_PAL_MANUALCREATE: GetMsgSTR = "WM_CAP_PAL_MANUALCREATE" Case WM_CAP_PAL_OPENA: GetMsgSTR = "WM_CAP_PAL_OPENA" Case WM_CAP_PAL_OPEN: GetMsgSTR = "WM_CAP_PAL_OPEN" Case WM_CAP_PAL_PASTE: GetMsgSTR = "WM_CAP_PAL_PASTE" Case WM_CAP_PAL_SAVEA: GetMsgSTR = "WM_CAP_PAL_SAVEA" Case WM_CAP_PAL_SAVE: GetMsgSTR = "WM_CAP_PAL_SAVE" Case WM_CAP_SEQUENCE: GetMsgSTR = "WM_CAP_SEQUENCE" Case WM_CAP_SEQUENCE_NOFILE: GetMsgSTR = "WM_CAP_SEQUENCE_NOFILE" Case WM_CAP_SET_AUDIOFORMAT: GetMsgSTR = "WM_CAP_SET_AUDIOFORMAT" Case WM_CAP_SET_CALLBACK_CAPCONTROL: GetMsgSTR = "WM_CAP_SET_CALLBACK_CAPCONTROL" Case WM_CAP_SET_CALLBACK_ERRORA: GetMsgSTR = "WM_CAP_SET_CALLBACK_ERRORA" Case WM_CAP_SET_CALLBACK_ERROR: GetMsgSTR = "WM_CAP_SET_CALLBACK_ERROR" Case WM_CAP_SET_CALLBACK_FRAME: GetMsgSTR = "WM_CAP_SET_CALLBACK_FRAME" Case WM_CAP_SET_CALLBACK_STATUSA: GetMsgSTR = "WM_CAP_SET_CALLBACK_STATUSA" Case WM_CAP_SET_CALLBACK_STATUS: GetMsgSTR = "WM_CAP_SET_CALLBACK_STATUS" Case WM_CAP_SET_CALLBACK_VIDEOSTREAM: GetMsgSTR = "WM_CAP_SET_CALLBACK_VIDEOSTREAM" Case WM_CAP_SET_CALLBACK_WAVESTREAM: GetMsgSTR = "WM_CAP_SET_CALLBACK_WAVESTREAM" Case WM_CAP_SET_CALLBACK_YIELD: GetMsgSTR = "WM_CAP_SET_CALLBACK_YIELD" Case WM_CAP_SET_MCI_DEVICEA: GetMsgSTR = "WM_CAP_SET_MCI_DEVICEA" Case WM_CAP_SET_MCI_DEVICE: GetMsgSTR = "WM_CAP_SET_MCI_DEVICE" Case WM_CAP_SET_OVERLAY: GetMsgSTR = "WM_CAP_SET_OVERLAY" Case WM_CAP_SET_PREVIEW: GetMsgSTR = "WM_CAP_SET_PREVIEW" Case WM_CAP_SET_PREVIEWRATE: GetMsgSTR = "WM_CAP_SET_PREVIEWRATE" Case WM_CAP_SET_SCALE: GetMsgSTR = "WM_CAP_SET_SCALE" Case WM_CAP_SET_SCROLL: GetMsgSTR = "WM_CAP_SET_SCROLL" Case WM_CAP_SET_SEQUENCE_SETUP: GetMsgSTR = "WM_CAP_SET_SEQUENCE_SETUP" Case WM_CAP_SET_USER_DATA: GetMsgSTR = "WM_CAP_SET_USER_DATA" Case WM_CAP_SET_VIDEOFORMAT: GetMsgSTR = "WM_CAP_SET_VIDEOFORMAT" Case WM_CAP_SINGLE_FRAME: GetMsgSTR = "WM_CAP_SINGLE_FRAME" Case WM_CAP_SINGLE_FRAME_CLOSE: GetMsgSTR = "WM_CAP_SINGLE_FRAME_CLOSE" Case WM_CAP_SINGLE_FRAME_OPEN: GetMsgSTR = "WM_CAP_SINGLE_FRAME_OPEN" Case WM_CAP_STOP: GetMsgSTR = "WM_CAP_STOP" Case WM_CHANGECBCHAIN: GetMsgSTR = "WM_CHANGECBCHAIN" Case WM_CHANGEUISTATE: GetMsgSTR = "WM_CHANGEUISTATE" Case WM_CHARTOITEM: GetMsgSTR = "WM_CHARTOITEM" Case WM_CHOOSEFONT_GETLOGFONT: GetMsgSTR = "WM_CHOOSEFONT_GETLOGFONT" Case WM_CHOOSEFONT_SETFLAGS: GetMsgSTR = "WM_CHOOSEFONT_SETFLAGS" Case WM_CHOOSEFONT_SETLOGFONT: GetMsgSTR = "WM_CHOOSEFONT_SETLOGFONT" Case WM_CLEAR: GetMsgSTR = "WM_CLEAR" Case WM_COMMNOTIFY: GetMsgSTR = "WM_COMMNOTIFY" Case WM_COMPAREITEM: GetMsgSTR = "WM_COMPAREITEM" Case WM_CONTEXTMENU: GetMsgSTR = "WM_CONTEXTMENU" Case WM_CONVERTREQUEST: GetMsgSTR = "WM_CONVERTREQUEST" Case WM_CONVERTRESULT: GetMsgSTR = "WM_CONVERTRESULT" Case WM_COPY: GetMsgSTR = "WM_COPY" Case WM_COPYDATA: GetMsgSTR = "WM_COPYDATA" Case WM_CPL_LAUNCH: GetMsgSTR = "WM_CPL_LAUNCH" Case WM_CPL_LAUNCHED: GetMsgSTR = "WM_CPL_LAUNCHED" Case WM_CTLCOLOR: GetMsgSTR = "WM_CTLCOLOR" Case WM_CTLCOLORBTN: GetMsgSTR = "WM_CTLCOLORBTN" Case WM_CTLCOLORDLG: GetMsgSTR = "WM_CTLCOLORDLG" Case WM_CTLCOLOREDIT: GetMsgSTR = "WM_CTLCOLOREDIT" Case WM_CTLCOLORLISTBOX: GetMsgSTR = "WM_CTLCOLORLISTBOX" Case WM_CTLCOLORMSGBOX: GetMsgSTR = "WM_CTLCOLORMSGBOX" Case WM_CTLCOLORSCROLLBAR: GetMsgSTR = "WM_CTLCOLORSCROLLBAR" Case WM_CTLCOLORSTATIC: GetMsgSTR = "WM_CTLCOLORSTATIC" Case WM_CUT: GetMsgSTR = "WM_CUT" Case WM_DDE_FIRST: GetMsgSTR = "WM_DDE_FIRST" Case WM_DDE_ACK: GetMsgSTR = "WM_DDE_ACK" Case WM_DDE_ADVISE: GetMsgSTR = "WM_DDE_ADVISE" Case WM_DDE_DATA: GetMsgSTR = "WM_DDE_DATA" Case WM_DDE_EXECUTE: GetMsgSTR = "WM_DDE_EXECUTE" Case WM_DDE_INITIATE: GetMsgSTR = "WM_DDE_INITIATE" Case WM_DDE_LAST: GetMsgSTR = "WM_DDE_LAST" Case WM_DDE_POKE: GetMsgSTR = "WM_DDE_POKE" Case WM_DDE_REQUEST: GetMsgSTR = "WM_DDE_REQUEST" Case WM_DDE_TERMINATE: GetMsgSTR = "WM_DDE_TERMINATE" Case WM_DDE_UNADVISE: GetMsgSTR = "WM_DDE_UNADVISE" Case WM_DELETEITEM: GetMsgSTR = "WM_DELETEITEM" Case WM_DESTROYCLIPBOARD: GetMsgSTR = "WM_DESTROYCLIPBOARD" Case WM_DEVICECHANGE: GetMsgSTR = "WM_DEVICECHANGE" Case WM_DEVMODECHANGE: GetMsgSTR = "WM_DEVMODECHANGE" Case WM_DRAWCLIPBOARD: GetMsgSTR = "WM_DRAWCLIPBOARD" Case WM_DRAWITEM: GetMsgSTR = "WM_DRAWITEM" Case WM_DROPFILES: GetMsgSTR = "WM_DROPFILES" Case WM_ENDSESSION: GetMsgSTR = "WM_ENDSESSION" Case WM_ENTERIDLE: GetMsgSTR = "WM_ENTERIDLE" Case WM_ENTERMENULOOP: GetMsgSTR = "WM_ENTERMENULOOP" Case WM_EXITMENULOOP: GetMsgSTR = "WM_EXITMENULOOP" Case WM_FONTCHANGE: GetMsgSTR = "WM_FONTCHANGE" Case WM_FORWARDMSG: GetMsgSTR = "WM_FORWARDMSG" Case WM_GETDLGCODE: GetMsgSTR = "WM_GETDLGCODE" Case WM_GETOBJECT: GetMsgSTR = "WM_GETOBJECT" Case WM_HANDHELDFIRST: GetMsgSTR = "WM_HANDHELDFIRST" Case WM_HANDHELDLAST: GetMsgSTR = "WM_HANDHELDLAST" Case WM_HELP: GetMsgSTR = "WM_HELP" Case WM_HSCROLL: GetMsgSTR = "WM_HSCROLL" Case WM_HSCROLLCLIPBOARD: GetMsgSTR = "WM_HSCROLLCLIPBOARD" Case WM_IME_CHAR: GetMsgSTR = "WM_IME_CHAR" Case WM_IME_COMPOSITION: GetMsgSTR = "WM_IME_COMPOSITION" Case WM_IME_COMPOSITIONFULL: GetMsgSTR = "WM_IME_COMPOSITIONFULL" Case WM_IME_CONTROL: GetMsgSTR = "WM_IME_CONTROL" Case WM_IME_ENDCOMPOSITION: GetMsgSTR = "WM_IME_ENDCOMPOSITION" Case WM_IME_KEYDOWN: GetMsgSTR = "WM_IME_KEYDOWN" Case WM_IME_KEYLAST: GetMsgSTR = "WM_IME_KEYLAST" Case WM_IME_KEYUP: GetMsgSTR = "WM_IME_KEYUP" Case WM_IME_NOTIFY: GetMsgSTR = "WM_IME_NOTIFY" Case WM_IME_REPORT: GetMsgSTR = "WM_IME_REPORT" Case WM_IME_REQUEST: GetMsgSTR = "WM_IME_REQUEST" Case WM_IME_SELECT: GetMsgSTR = "WM_IME_SELECT" Case WM_IME_SETCONTEXT: GetMsgSTR = "WM_IME_SETCONTEXT" Case WM_IME_STARTCOMPOSITION: GetMsgSTR = "WM_IME_STARTCOMPOSITION" Case WM_IMEKEYDOWN: GetMsgSTR = "WM_IMEKEYDOWN" Case WM_IMEKEYUP: GetMsgSTR = "WM_IMEKEYUP" Case WM_INITDIALOG: GetMsgSTR = "WM_INITDIALOG" Case WM_INTERIM: GetMsgSTR = "WM_INTERIM" Case WM_KEYFIRST: GetMsgSTR = "WM_KEYFIRST" Case WM_KEYLAST: GetMsgSTR = "WM_KEYLAST" Case WM_MDIACTIVATE: GetMsgSTR = "WM_MDIACTIVATE" Case WM_MDICASCADE: GetMsgSTR = "WM_MDICASCADE" Case WM_MDICREATE: GetMsgSTR = "WM_MDICREATE" Case WM_MDIDESTROY: GetMsgSTR = "WM_MDIDESTROY" Case WM_MDIGETACTIVE: GetMsgSTR = "WM_MDIGETACTIVE" Case WM_MDIICONARRANGE: GetMsgSTR = "WM_MDIICONARRANGE" Case WM_MDIMAXIMIZE: GetMsgSTR = "WM_MDIMAXIMIZE" Case WM_MDINEXT: GetMsgSTR = "WM_MDINEXT" Case WM_MDIREFRESHMENU: GetMsgSTR = "WM_MDIREFRESHMENU" Case WM_MDIRESTORE: GetMsgSTR = "WM_MDIRESTORE" Case WM_MDISETMENU: GetMsgSTR = "WM_MDISETMENU" Case WM_MDITILE: GetMsgSTR = "WM_MDITILE" Case WM_MEASUREITEM: GetMsgSTR = "WM_MEASUREITEM" Case WM_MENUCOMMAND: GetMsgSTR = "WM_MENUCOMMAND" Case WM_MENUDRAG: GetMsgSTR = "WM_MENUDRAG" Case WM_MENUGETOBJECT: GetMsgSTR = "WM_MENUGETOBJECT" Case WM_MENURBUTTONUP: GetMsgSTR = "WM_MENURBUTTONUP" Case WM_MOUSEFIRST: GetMsgSTR = "WM_MOUSEFIRST" Case WM_MOUSEHOVER: GetMsgSTR = "WM_MOUSEHOVER" Case WM_MOUSELAST: GetMsgSTR = "WM_MOUSELAST" Case WM_MOUSELEAVE: GetMsgSTR = "WM_MOUSELEAVE" Case WM_NCMOUSEHOVER: GetMsgSTR = "WM_NCMOUSEHOVER" Case WM_NCMOUSELEAVE: GetMsgSTR = "WM_NCMOUSELEAVE" Case WM_NCXBUTTONDBLCLK: GetMsgSTR = "WM_NCXBUTTONDBLCLK" Case WM_NCXBUTTONDOWN: GetMsgSTR = "WM_NCXBUTTONDOWN" Case WM_NCXBUTTONUP: GetMsgSTR = "WM_NCXBUTTONUP" Case WM_NEXTDLGCTL: GetMsgSTR = "WM_NEXTDLGCTL" Case WM_NEXTMENU: GetMsgSTR = "WM_NEXTMENU" Case WM_NOTIFY: GetMsgSTR = "WM_NOTIFY" Case WM_NOTIFYFORMAT: GetMsgSTR = "WM_NOTIFYFORMAT" Case WM_NULL: GetMsgSTR = "WM_NULL" Case WM_PAINTCLIPBOARD: GetMsgSTR = "WM_PAINTCLIPBOARD" Case WM_PALETTECHANGED: GetMsgSTR = "WM_PALETTECHANGED" Case WM_PALETTEISCHANGING: GetMsgSTR = "WM_PALETTEISCHANGING" Case WM_PASTE: GetMsgSTR = "WM_PASTE" Case WM_PENWINFIRST: GetMsgSTR = "WM_PENWINFIRST" Case WM_PENWINLAST: GetMsgSTR = "WM_PENWINLAST" Case WM_POWER: GetMsgSTR = "WM_POWER" Case WM_POWERBROADCAST: GetMsgSTR = "WM_POWERBROADCAST" Case WM_PSD_ENVSTAMPRECT: GetMsgSTR = "WM_PSD_ENVSTAMPRECT" Case WM_PSD_FULLPAGERECT: GetMsgSTR = "WM_PSD_FULLPAGERECT" Case WM_PSD_GREEKTEXTRECT: GetMsgSTR = "WM_PSD_GREEKTEXTRECT" Case WM_PSD_MARGINRECT: GetMsgSTR = "WM_PSD_MARGINRECT" Case WM_PSD_MINMARGINRECT: GetMsgSTR = "WM_PSD_MINMARGINRECT" Case WM_PSD_PAGESETUPDLG: GetMsgSTR = "WM_PSD_PAGESETUPDLG" Case WM_PSD_YAFULLPAGERECT: GetMsgSTR = "WM_PSD_YAFULLPAGERECT" Case WM_QUERYENDSESSION: GetMsgSTR = "WM_QUERYENDSESSION" Case WM_QUERYNEWPALETTE: GetMsgSTR = "WM_QUERYNEWPALETTE" Case WM_QUERYUISTATE: GetMsgSTR = "WM_QUERYUISTATE" Case WM_QUEUESYNC: GetMsgSTR = "WM_QUEUESYNC" Case WM_RASDIALEVENT: GetMsgSTR = "WM_RASDIALEVENT" Case WM_RENDERALLFORMATS: GetMsgSTR = "WM_RENDERALLFORMATS" Case WM_RENDERFORMAT: GetMsgSTR = "WM_RENDERFORMAT" Case WM_SETCURSOR: GetMsgSTR = "WM_SETCURSOR" Case WM_SIZECLIPBOARD: GetMsgSTR = "WM_SIZECLIPBOARD" Case WM_SPOOLERSTATUS: GetMsgSTR = "WM_SPOOLERSTATUS" Case WM_SYSCOLORCHANGE: GetMsgSTR = "WM_SYSCOLORCHANGE" Case WM_TCARD: GetMsgSTR = "WM_TCARD" Case WM_TIMECHANGE: GetMsgSTR = "WM_TIMECHANGE" Case WM_TIMER: GetMsgSTR = "WM_TIMER" Case WM_UNDO: GetMsgSTR = "WM_UNDO" Case WM_UNINITMENUPOPUP: GetMsgSTR = "WM_UNINITMENUPOPUP" Case WM_UPDATEUISTATE: GetMsgSTR = "WM_UPDATEUISTATE" Case WM_VKEYTOITEM: GetMsgSTR = "WM_VKEYTOITEM" Case WM_VSCROLL: GetMsgSTR = "WM_VSCROLL" Case WM_VSCROLLCLIPBOARD: GetMsgSTR = "WM_VSCROLLCLIPBOARD" Case WM_WNT_CONVERTREQUESTEX: GetMsgSTR = "WM_WNT_CONVERTREQUESTEX" Case WM_XBUTTONDBLCLK: GetMsgSTR = "WM_XBUTTONDBLCLK" Case WM_XBUTTONDOWN: GetMsgSTR = "WM_XBUTTONDOWN" Case WM_XBUTTONUP: GetMsgSTR = "WM_XBUTTONUP" Case Else: GetMsgSTR = "&H" & CStr(Hex(uMsg)) End Select End Function '=========================================================================================================== ' GetLastErr_Msg ' ' Purpose : ' Function that gets the last error caused by either SUBCLS.DLL or the Windows API. This only works with ' functions that use the GetLastError function to return an error code. Not all Windows API's do. ' ' If no error has occured, no message is displayed. ' ' Param Use ' ------------------------------------ ' ErrorNumber Optional. Error number to display. If this is set to zero, then the ' SC_GetLastErr then GetLastError API's are called to see if any errors occured. ' If no error occured, the function exits. ' LastAPICalled Optional. If the "ShowErrors" parameter is set to TRUE, this is used to display ' an error dialog and tell the user which API caused the problem. ' Return_ErrDesc Optional. This returns the description of the last error that occured. ' ShowErrors Optional. If this parameter is set to TRUE, an error dialog is displayed with the ' error number and description for the user to see. ' ' Return ' ------ ' If no error occured, no message is displayed & function returns FALSE. ' If an error occured, an error message is displayed & the function returns TRUE. ' '=========================================================================================================== Private Function GetLastErr_Msg(Optional ByVal ErrorNumber As Long, _ Optional ByVal LastAPICalled As String = "last", _ Optional ByRef Return_ErrDesc As String, _ Optional ByVal ShowErrors As Boolean = False) As Boolean On Error Resume Next Dim ErrMsg As String ' Clear the return value first Return_ErrDesc = "" ' Check if the user specified an error to check If ErrorNumber = 0 Then ' Check if an error occured in the SUBCLS.DLL ErrorNumber = SC_GetLastErr If ErrorNumber = ERRC_NoError Then ' Check if a Windows® error has occrued ErrorNumber = GetLastError If ErrorNumber = 0 Then ' No errors have occured... so exit Exit Function End If Else ' Return that an error occured GetLastErr_Msg = True ' Return the error description Return_ErrDesc = FindErrDesc_SC(ErrorNumber) ' Display the error message If ShowErrors = True Then MsgBox "An error was encountered while calling the " & LastAPICalled & " function in the SUBCLS.DLL library." & Chr(13) & "Below is the error information:" & Chr(13) & Chr(13) & "Error Number = " & CStr(ErrorNumber) & Chr(13) & "Error Description = " & Return_ErrDesc, vbOKOnly + vbExclamation, " SUBCLS.DLL Error" End If ' Set the error to zero so it is not reported again SC_ClearLastErr Exit Function End If End If ' Allocate a buffer for the error description ErrMsg = String(MAX_PATH, 0) ' Get the error description FormatMessage FORMAT_MESSAGE_FROM_SYSTEM, ByVal 0&, ErrorNumber, 0, ErrMsg, MAX_PATH, 0 ErrMsg = Left(ErrMsg, InStr(ErrMsg, Chr(0)) - 1) Return_ErrDesc = ErrMsg If Right(Return_ErrDesc, Len(vbCrLf)) = vbCrLf Then Return_ErrDesc = Left(Return_ErrDesc, Len(Return_ErrDesc) - Len(vbCrLf)) End If ' Display the error message If ShowErrors = True Then MsgBox "An error was encountered while calling the " & LastAPICalled & " Windows API function." & Chr(13) & "Below is the error information:" & Chr(13) & Chr(13) & "Error Number = " & CStr(ErrorNumber) & Chr(13) & "Error Description = " & ErrMsg, vbOKOnly + vbExclamation, " Windows API Error" End If GetLastErr_Msg = True ' Set the last error to 0 (no error) so next time through it doesn't report the same error twice SetLastError 0 End Function '=========================================================================================================== ' FindErrDesc_SC ' ' Purpose : ' Returns a description of the specified SUBCLS.DLL error code. ' ' Param Use ' ------------------------------------ ' ErrorNumber Specifies which error (defined above) should be described ' ' Return ' ------ ' A String is returned describing the specified error number ' '=========================================================================================================== Private Function FindErrDesc_SC(ByVal ErrorNumber As Long) As String Select Case ErrorNumber Case ERRC_NoError ' 0 FindErrDesc_SC = "No Error" Case ERRC_MaxCodeMatchReached ' 1 FindErrDesc_SC = "The maximum number of message watches (100) has been reached" Case ERRC_WatchAlreadyExists ' 2 FindErrDesc_SC = "The specified message to watch already exists" Case ERRC_WatchDoesntExist ' 3 FindErrDesc_SC = "A watch for the specified message has not been set" Case ERRC_IndexOutOfBounds ' 5 FindErrDesc_SC = "The specified watch index is out of bounds (0 to 100)" Case Else FindErrDesc_SC = "Unknown Or Undefined Error" End Select End Function 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXX SUBCLS.DLL EXPORTED FUNCTION DOCUMENTATION XXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX '=========================================================================================================== ' ClearAllMsgWatches ' ' Clears out all existing code watches ' ' Param Use ' ------------------------------------ ' None ' '=========================================================================================================== ' __declspec(dllexport) __stdcall void ClearAllMsgWatches () '----------------------------------------------------------------------------------------------------------- ' Public Declare Sub SC_ClearAllMsgWatches Lib "SUBCLS.DLL" Alias "_ClearAllMsgWatches@0" () '=========================================================================================================== '=========================================================================================================== ' ClearLastErr ' ' Sets the last error number to ERRC_NoError (No Error) ' ' Param Use ' ------------------------------------ ' None ' '=========================================================================================================== ' __declspec(dllexport) __stdcall void ClearLastErr () '----------------------------------------------------------------------------------------------------------- ' Public Declare Sub SC_ClearLastErr Lib "SUBCLS.DLL" Alias "_ClearLastErr@0" () '=========================================================================================================== '=========================================================================================================== ' ClearQuitMsg ' ' Function that sets the indicator back to the default - FALSE (0) ' ' Param Use ' ------------------------------------ ' None ' '=========================================================================================================== ' __declspec(dllexport) __stdcall void ClearQuitMsg () '----------------------------------------------------------------------------------------------------------- ' Public Declare Sub SC_ClearQuitMsg Lib "SUBCLS.DLL" Alias "_ClearQuitMsg@0" () '=========================================================================================================== '=========================================================================================================== ' GetMessageInfo ' ' This function returns the information for the last CALLBACK function called if the uMsg ' parameter of that CALLBACK function matches one of the set code watches. This function ' should be called in a LOOP to continually retrieve the codes sent to the specified ' CALLBACK function. ' ' NOTE : The values are returned via the parameters passed to this function ' ' Param Use ' ------------------------------------ ' lpHWND Returns the hWnd retrieved from the last CALLBACK function that recieved a ' message being watched. ' puMsg Returns the nCode retrieved from the last CALLBACK function that recieved a ' message being watched. ' lpWPARAM Returns the wParam retrieved from the last CALLBACK function that recieved a ' message being watched. ' lpLPARAM Returns the lParam retrieved from the last CALLBACK function that recieved a ' message being watched. ' '=========================================================================================================== ' __declspec(dllexport) __stdcall void GetMessageInfo (LPHANDLE *lpHWND, PUINT *puMsg, LONG_PTR *lpWPARAM, LONG_PTR *lpLPARAM) '----------------------------------------------------------------------------------------------------------- ' Public Declare Sub SC_GetMessageInfo Lib "SUBCLS.DLL" Alias "_GetMessageInfo@16" (ByRef lpHWND As Long, ByRef puMsg As Long, ByRef lpWPARAM As Long, ByRef lpLPARAM As Long) '=========================================================================================================== '=========================================================================================================== ' SetLastErr ' ' Sets the last error number ' ' Param Use ' ------------------------------------ ' iErrNum Specifies the error number to set to ' '=========================================================================================================== ' __declspec(dllexport) __stdcall void SetLastErr (int iErrNum) '----------------------------------------------------------------------------------------------------------- ' Public Declare Sub SC_SetLastErr Lib "SUBCLS.DLL" Alias "_SetLastErr@4" (ByVal iErrNum As Long) '=========================================================================================================== '=========================================================================================================== ' SetPreviousHWND ' ' Sets the handle to the previous windows procedure. If this value is not zero (0), then the ' "WindowProc" callback function uses this value to call the "CallWindowProc" Win32 API. ' Otherwise the "DefWindowProc" Win32 API is called. ' ' Param Use ' ------------------------------------ ' hWnd Specifies the handle of the previous window to call in the WindowProc ' '=========================================================================================================== ' __declspec(dllexport) __stdcall void SetPreviousHWND (WNDPROC hWnd) '----------------------------------------------------------------------------------------------------------- ' Public Declare Sub SC_SetPreviousHWND Lib "SUBCLS.DLL" Alias "_SetPreviousHWND@4" (ByVal hWnd As Long) '=========================================================================================================== '=========================================================================================================== ' SetUnSubClsOnQuitMsg ' ' If this is set to TRUE, then when a WM_DESTROY Or WM_QUIT message is recieved, ' this library stops any subclassing that is in progress. ' ' Param Use ' ------------------------------------ ' NewValue TRUE (1) / FALSE (0) ' '=========================================================================================================== ' __declspec(dllexport) __stdcall void SetUnSubClsOnQuitMsg (BOOL NewValue) '----------------------------------------------------------------------------------------------------------- ' Public Declare Sub SC_SetUnSubClsOnQuitMsg Lib "SUBCLS.DLL" Alias "_SetUnSubClsOnQuitMsg@4" (ByVal NewValue As Long) ' Sets BOOL '=========================================================================================================== '=========================================================================================================== ' AddMsgWatch ' ' Searches all the currently defined code watches and if the specified watch ' does not yet exist, it adds the specified code to the list of codes ' to watch. ' ' Returns TRUE (1) if it successfully adds the code to the list of watches ' Returns FALSE (0) if it failed to add the code ' Call GetLastErr to get more information on the error that occured ' ' Param Use ' ------------------------------------ ' uMsg Specifies the message watch to add ' '=========================================================================================================== ' __declspec(dllexport) __stdcall BOOL AddMsgWatch (UINT uMsg) '----------------------------------------------------------------------------------------------------------- ' Public Declare Function SC_AddMsgWatch Lib "SUBCLS.DLL" Alias "_AddMsgWatch@4" (ByVal uMsg As Long) As Long ' Returns BOOL '=========================================================================================================== '=========================================================================================================== ' GetHInstance ' ' Function that returns a handle to the current DLL instance ' ' Param Use ' ------------------------------------ ' None ' '=========================================================================================================== ' __declspec(dllexport) __stdcall HINSTANCE GetHInstance () '----------------------------------------------------------------------------------------------------------- ' Public Declare Function SC_GetHInstance Lib "SUBCLS.DLL" Alias "_GetHInstance@0" () As Long '=========================================================================================================== '=========================================================================================================== ' GetLastErr ' ' Returns the error constant that represents the error that was encountered in the last ' function called. See the ERRC_* constants. ' ' Param Use ' ------------------------------------ ' None ' '=========================================================================================================== ' __declspec(dllexport) __stdcall int GetLastErr () '----------------------------------------------------------------------------------------------------------- ' Public Declare Function SC_GetLastErr Lib "SUBCLS.DLL" Alias "_GetLastErr@0" () As Long '=========================================================================================================== '=========================================================================================================== ' GetMsgWatchCount ' ' Function that returns how many valid code watches are currently in place ' ' Param Use ' ------------------------------------ ' None ' '=========================================================================================================== ' __declspec(dllexport) __stdcall int GetMsgWatchCount () '----------------------------------------------------------------------------------------------------------- ' Public Declare Function SC_GetMsgWatchCount Lib "SUBCLS.DLL" Alias "_GetMsgWatchCount@0" () As Long '=========================================================================================================== '=========================================================================================================== ' GetMsgWatchIndex ' ' Function that searches all of the currently defined code watches and if it ' finds a match to the specified code, it returns the index to that code ' ' Returns the code index (0 to 100) if a match is found ' Returns -1 if a match is not found ' ' Param Use ' ------------------------------------ ' uMsg Message watch to get the index from ' '=========================================================================================================== ' __declspec(dllexport) __stdcall int GetMsgWatchIndex (UINT uMsg) '----------------------------------------------------------------------------------------------------------- ' Public Declare Function SC_GetMsgWatchIndex Lib "SUBCLS.DLL" Alias "_GetMsgWatchIndex@4" (ByVal uMsg As Long) As Long '=========================================================================================================== '=========================================================================================================== ' GetMsgWatchValue ' ' Function that returns the value of the message watch specified by the index passed ' ' Returns the code value if found ' Returns zero (0) if the code is not found ' ' Param Use ' ------------------------------------ ' iIndex Specifies the index of the message watch ' '=========================================================================================================== ' __declspec(dllexport) __stdcall UINT GetMsgWatchValue (int iIndex) '----------------------------------------------------------------------------------------------------------- ' Public Declare Function SC_GetMsgWatchValue Lib "SUBCLS.DLL" Alias "_GetMsgWatchValue@4" (ByVal iIndex As Long) As Long '=========================================================================================================== '=========================================================================================================== ' GetPreviousHWND ' ' Returns the handle to the previous message handling procedure if subclassing is currently being used. ' ' Param Use ' ------------------------------------ ' None ' '=========================================================================================================== ' __declspec(dllexport) __stdcall WNDPROC GetPreviousHWND () '----------------------------------------------------------------------------------------------------------- ' Public Declare Function SC_GetPreviousHWND Lib "SUBCLS.DLL" Alias "_GetPreviousHWND@0" () As Long '=========================================================================================================== '=========================================================================================================== ' GetUnSubClsOnQuitMsg ' ' This returns whether the user specified to stop any subclassing if a WM_DESTROY or WM_QUIT ' message is recieved. ' ' Param Use ' ------------------------------------ ' None ' '=========================================================================================================== ' __declspec(dllexport) __stdcall BOOL GetUnSubClsOnQuitMsg () '----------------------------------------------------------------------------------------------------------- ' Public Declare Function SC_GetUnSubClsOnQuitMsg Lib "SUBCLS.DLL" Alias "_GetUnSubClsOnQuitMsg@0" () As Long '=========================================================================================================== '=========================================================================================================== ' MsgWatchExists ' ' Function that searches for the specified code watch and if it exists, ' ' Returns TRUE (1) if code watch exists ' Returns FALSE (0) if code watch doesn't exist ' ' Param Use ' ------------------------------------ ' uMsg Specifies the message watch to check ' '=========================================================================================================== ' __declspec(dllexport) __stdcall BOOL MsgWatchExists (UINT uMsg) '----------------------------------------------------------------------------------------------------------- ' Public Declare Function SC_MsgWatchExists Lib "SUBCLS.DLL" Alias "_MsgWatchExists@4" (ByVal uMsg As Long) As Long ' Returns BOOL '=========================================================================================================== '=========================================================================================================== ' QuitMsgPosted ' ' Returns TRUE (1) if the WM_DESTROY or WM_QUIT message are recieved. This can be used to determine if ' the window you are trying to subclass has been closed by the user, or forced down by Windows®. ' ' Param Use ' ------------------------------------ ' None ' '=========================================================================================================== ' __declspec(dllexport) __stdcall BOOL QuitMsgPosted () '----------------------------------------------------------------------------------------------------------- ' Public Declare Function SC_QuitMsgPosted Lib "SUBCLS.DLL" Alias "_QuitMsgPosted@0" () As Long ' Returns BOOL '=========================================================================================================== '=========================================================================================================== ' RemoveMsgWatch ' ' Function that removes the specified code watch. Code watch can be specified by ' the code, or by the index of the code watch. The specified uMsg is searched first ' and removed. If the uMsg isn't specified, the iIndex is used to remove the specified ' code watch. ' ' Returns TRUE (1) if successfully removes the specified watch ' Returns FALSE (0) if failed to remove the specified watch ' Call GetLastErr to get more information on the error that occured ' ' Param Use ' ------------------------------------ ' uMsg Optional. Specifies the message watch to remove. If this is ' not specified, you must specify the index in the iIndex parameter ' iIndex Optional. Specifies the index of the message watch to remove. ' If this is not specified, you must specify the message in the ' uMsg parameter. ' '=========================================================================================================== ' __declspec(dllexport) __stdcall BOOL RemoveMsgWatch (UINT uMsg, int iIndex) '----------------------------------------------------------------------------------------------------------- ' Public Declare Function SC_RemoveMsgWatch Lib "SUBCLS.DLL" Alias "_RemoveMsgWatch@8" (ByVal uMsg As Long, ByVal iIndex As Long) As Long ' Returns BOOL '=========================================================================================================== '=========================================================================================================== ' WindowProc ' ' The WindowProc function is an application-defined function that processes messages sent to a ' window. The WNDPROC type defines a pointer to this callback function. WindowProc is a ' placeholder for the application-defined function name. ' ' Param Use ' ------------------------------------ ' hWnd Handle to window ' uMsg Message identifier ' wParam First message parameter ' lParam Second message parameter ' '=========================================================================================================== ' __declspec(dllexport) __stdcall LRESULT CALLBACK WindowProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) '----------------------------------------------------------------------------------------------------------- ' Public Function WindowProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam) As Long ' ' < Your code goes here > ' End Function '===========================================================================================================