RouteWinMsgToPanelCallback
int RouteWinMsgToPanelCallback (int panelHandle, unsigned int messageNumber);
Purpose
LabWindows/CVI does not provide callback events corresponding to all of the low–level Windows events that a top–level LabWindows/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.
When the panel receives the Windows message you specify, it calls the panel callback with an event value of EVENT_WINDOWS_MSG.
Example Code
int PanelCallback(int panel, int event, void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_WINDOWS_MSG:
{
InterceptedWindowsMsg msg;
GetRoutedWinMsgParams (panel, &msg);
// 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;
}
When you receive the EVENT_WINDOWS_MSG event, call GetRoutedWinMsgParams to obtain the data associated with the message. If your panel callback does not return 0 in response to the event, the panel does not process the Windows message further. Instead, it returns to the system the value that you set by calling the SetRoutedWinMsgResult function. If you return 0 from your panel callback, you do not need to specify a result.
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 LabWindows/CVI panel uses. Be aware of the following subclassing issues:
- Only top level panels own a system window.
- If LabWindows/CVI must recreate the window, the subclassing is lost and must be repeated. LabWindows/CVI must recreate the window to change certain top level panel attributes such as ATTR_TITLEBAR_VISIBLE.
- If more than one software component subclasses 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, do not mix the routing functions with the message callback functions in the Windows Messaging parent class, as they use different window subclassing mechanisms.
(Linux) This function is not supported.
Parameters
Input | ||
Name | Type | Description |
panelHandle | int | 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 int | Pass the Windows message you want to receive in your panel callback function. Example: WM_ACTIVATEAPP |
Return Value
Name | Type | Description |
status | int | 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. |
Additional Information
Library: Programmer's Toolbox
Include file: toolbox\toolbox.h
LabWindows/CVI compatibility: LabWindows/CVI 7.0 and later