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:

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.