# RegisterWinMsgCallback

int RegisterWinMsgCallback (WinMsgCallbackPtr callbackFunction, char messageIdentifier[], void *callbackData, int dataSize, int *callbackID, int deleteWhenProgramStops);

## Purpose

Registers a callback function that LabWindows/CVI calls when your application receives a specific Windows message. RegisterWinMsgCallback returns the actual number of the Windows message.

Linux This function is not supported.

You can call the Windows SDK PostMessage function from a DLL or another application to send the Windows message to LabWindows/CVI. The window handle that you pass to PostMessage determines the thread in which the callback function is invoked.

To send a message to a particular thread, pass the window handle that GetCVIWindowHandle returns when you call it from that thread.

To send a message to another thread, you must have created at least one top-level panel in that thread. Pass the window handle for that panel to the PostMessage function. You can obtain the window handle for the top-level panel by calling GetPanelAttribute with the ATTR_SYSTEM_WINDOW_HANDLE attribute.

## Parameters

Input
Name | Type | Description
callbackFunction | WinMsgCallbackPtr | Name of the user function that LabWindows/CVI calls whenever it receives the Windows message number returned by RegisterWinMsgCallback. To send this message to LabWindows/CVI, call the Windows API function PostMessage from a DLL or another application. This event function of type WinMsgCallbackPtr takes the following form: void CVICALLBACK EventFunctionName (WinMsgWParam wParam, WinMsgLParam lParam, void *callbackData); The event function receives the wParam and lParam parameters that were passed to PostMessage. The lParam parameter is always an unsigned long integer. The wParam parameter is an unsigned 32-bit integer. callbackData is the same callbackData pointer that you pass to RegisterWinMsgCallback or a pointer to a copy of the data the original pointer pointed to.
messageIdentifier | string | A user-specified string that allows two processes to use the same Windows message number. If you pass zero (0) for the messageIdentifier, RegisterWinMsgCallback returns a unique Windows message number. Subsequent calls to RegisterWinMsgCallback, or the Windows API function RegisterWindowMessage, do not return the same messageNumber until you call UnRegisterWinMsgCallback with the callbackId that RegisterWinMsgCallback also returns. If you pass a string for the messageIdentifier, any subsequent call to RegisterWinMsgCallback, or the Windows API function RegisterWindowMessage, that uses the same messageIdentifier string returns the same messageNumber.
callbackData | void * | Pointer to data that you define. This pointer or a pointer to a copy of the data is passed to the event function. If dataSize is zero, the callbackData pointer is the same pointer that callbackFunction receives. If dataSize is greater than zero, this function copies the data pointed to by the callbackData pointer, and the callbackFunction receives a pointer to the copy as its callbackData parameter.
dataSize | integer | If dataSize is zero, the callbackData pointer is the same pointer that callbackFunction receives. If dataSize is greater than zero, this function copies the data pointed to by the callbackData pointer, and the callbackFunction receives a pointer to the copy as its callbackData parameter.
deleteWhenProgram Stops | integer | If 0, the callback function remains installed when your program terminates. If nonzero, LabWindows/CVI automatically calls UnRegisterWinMsgCallback when your program terminates.
Output
Name | Type | Description
callbackID | integer | ID that you pass to UnRegisterWinMsgCallback to disable the callback function.

## Return Value

Name | Type | Description
messageNumber | integer | Message number that Windows assigns. Zero indicates that the function failed. To send the message you registered through RegisterWinMsgCallback to LabWindows/CVI, pass the messageNumber this function returns to the Windows API function PostMessage.