The HANDLE_CMD macro procedure, typically placed in the BEGIN EVENTS ... END EVENTS loop, is used with the CMDHANDLER macro, to provide a module based alternative for System-Defined WM_COMMAND Message handling in BCX.
Syntax 1:HANDLE_CMD(CMD_ID AS USHORT, Procedure, [Number AS LONG]) Parameters:
|
HANDLE_CMD(IDM_NEW, OnNewClick, 0)
translates to
IF Msg = WM_COMMAND AND CBCTL = IDM_NEW THEN OnNewClick(hWnd, wParam, lParam, 0) END IF
🔗 For a thorough demo of HANDLE_CMD macro, please see the example in the BCX_FRAMEWND section.
The HANDLE_CMD ... INLINE macro procedure, typically placed in the BEGIN EVENTS ... END EVENTS loop, is used for System-Defined Message handling in BCX. The INLINE form of the macro is much simpler to use if you only have a single line of code. If you have more code then use the form described above in Syntax 1.
Syntax 2:HANDLE_CMD CMD_ID1 INLINE "SendMessage(hWnd, CMD_ID2, 0, 0) : EXIT FUNCTION" Parameters:
|
HANDLE_CMD CMD_ID1 INLINE "SendMessage(hWnd, CMD_ID2, 0, 0) : EXIT FUNCTION"
is translated to an intermediate BCX code
IF Msg = WM_COMMAND AND CBCTL = CMD_ID1 THEN SendMessage(hWnd, CMD_ID2, 0, 0) EXIT FUNCTION END IF
before translation to C code.
A CMDHANDLER macro procedure module is built to process the message from the HANDLE_CMD function.
Syntax:CMDHANDLER InstanceName() ' your code goes here LReturn = SendMessage(hWnd, CMD_ID, 0, 0) END HANDLER Parameters:
|
CMDHANDLER OnNewClick() ' your code goes here LReturn = SendMessage(hWnd, IDM_NEW, 0, 0) END HANDLER
is translated to an intermediate BCX code
FUNCTION OnNewClick (hWnd, wParam, lParam, LReturn) AS LRESULT ' your code goes here LReturn = SendMessage(hWnd, IDM_NEW, 0, 0) FUNCTION = LReturn END FUNCTION
before translation to C code.
🔗 For a thorough demo of CMDHANDLER ... END HANDLER please see the example in the BCX_FRAMEWND section.