....... |
Using Windows API in VB Tutorial The Window Procedure |
||
Windows does not know anything about events. These are shipped in VB to hide the actual way Windows informs your window that something is happening with him. VB gently serves as a interpreter and translates the Windows language into Vb's. But the reality is different and you will soon face it. Imagine you want to know when the user highlights your menu item (not press, just highlight). VB does not provide such event, but you've seen how other programs display some text in the statusbar as you browse their menus. If they can, why you don't. OK, here is the rough reality. Each window has a special procedure called a window procedure. It is actually a callback function. This function is sent a message any time something happens with you window. Thus a message (WM_COMMAND) is sent when the use highlights a menu item. Why then I can't see this message? This is because VB creates the window procedure instead of you. When Windows sends a message, this procedure dispatches it to a certain event and converts its parameters into some easier to use parameters of the event. But, in some cases this procedures just ignores some messages and you can't receive the actual input. If you really need to get this message, you must subclass your window, which discussed in another topic. Here is the declaration of a callback window procedure: Function WindowProc(ByVal Hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long The first parameter specifies the window handle, wMsg is a message identifier (like WM_COMMAND or WM_MOUSEMOVE), wParam and lParam are 32-bit values which meaning depends on the type of message sent. |
|||