# RouteWinMsgToPanelCallback

int RouteWinMsgToPanelCallback (int panelHandle, unsigned int messageNumber);

## Purpose

CVI does not provide callback events corresponding to all of the low–level Windows events that a top–level CVI panel receives.

To receive low–level Windows messages, you can call this function to route any number of Windows messages to your panel callback function.

### Example

When the panel receives the Windows message you specify, it calls the panel callback with an event value of EVENT_WINDOWS_MSG. The eventData1 parameter contains a pointer to the following structure which describes the Windows message:

typedef struct

{
unsigned int uMsg; // Windows message code
unsigned int wParam;
long lParam;
long result;
} InterceptedWindowsMsg;

### Example

int PanelCallback(int panel, int event, void *callbackData, int eventData1, int eventData2)
{
switch (event)

{
case EVENT_WINDOWS_MSG:

{
InterceptedWindowsMsg *msg;
msg = (InterceptedWindowsMsg *)eventData1;
// Check for application activate via a Windows message
// because the top level panel does not get the CVI
// EVENT_GOT_FOCUS event if one of its child panels
// has the focus when it is activated
if ((msg->uMsg == WM_ACTIVATEAPP) && msg->wParam)

{
// application was activated, put your code here
}

}

break;
}
return 0;

}

Note that if your panel callback does not return 0 in response to the EVENT_WINDOWS_MSG event, the panel does not process the Windows message further. Instead, it returns to the system the value you place in the result field of the InterceptedWindowsMsg structure. If you return 0 from your panel callback, you do not need to set the result field of this structure.

You can call UnrouteWinMsgToPanelCallback to stop routing a Windows message to your panel callback.

Note that this function "subclasses" the underlying system window that the CVI panel uses. Be aware of the following subclassing issues:

- Only top level panels own a system window.
- If CVI must recreate the window, the "subclassing" is lost and must be repeated. CVI must recreate the window to change certain top level panel attributes such as ATTR_TITLEBAR_VISIBLE.
- If more than one software component subclass the same window using different methods, you must ensure that the components unsubclass the window in the reverse order that they subclass the window. When you unroute the last message with UnrouteWinMsgToPanelCallback, you unsubclass the subclassing that this function performs.
- If another component uses a different method to subclass the window for this panel after you call this function, the UnrouteWinMsgToPanelCallback cannot unroute messages unless this later subclassing is first removed.
- This function sets the GWL_USERDATA system window property. Thus this function might not be compatible with a different subclassing function that also sets this property.
- In your programs, you should not mix the routing functions with the message callback functions in the Windows Messaging parent class, as they use different window 'subclassing' mechanisms.

## Parameters

Input
Name | Type | Description
panelHandle | integer | The specifier for a particular top–level panel that is currently in memory. This handle will have been returned by the LoadPanel, NewPanel, or DuplicatePanel function.
messageNumber | unsigned integer | Pass the Windows message you want to receive in your panel callback function. Example: WM_ACTIVATEAPP

## Return Value

Name | Type | Description
status | integer | The status code that the function returns. 0 indicates success. A negative value indicates an error. This function may return a Programmer's Toolbox or UI Library error code. Call GetGeneralErrorString to obtain a text description of the error.