CBCTLMSG function

Purpose

In a Callback Function, return the numeric value of a notification message parameter sent to the callback from a control.

Syntax

CtlMsg& = CBCTLMSG

Remarks

When a user clicks on a button, types into a text box, or generally interacts with any control in a dialog, Windows sends a message to the callback for the control (or the dialog if the control does not have a callback).

CBCTLMSG will return the numeric value of the notification message if CBMSG = %WM_COMMAND. For other values of CBMSG, CBCTLMSG will return message-dependent values.

In other words, CBCTLMSG can only return a valid notification message value if CBMSG indicates that the message includes a notification message. That is, when CBMSG = %WM_COMMAND, CBCTLMSG will contain a notification message value sent by the originating control. For example, CBCTLMSG = %BN_CLICKED when the user clicks a button.

If we consider a conventional callback procedure:

FUNCTION DlgCallback(BYVAL hDlg???, BYVAL wMsg&, BYVAL wParam&, BYVAL lParam&) _

  EXPORT AS LONG

The notification message is sent to the callback as the high-order word of the wParam& parameter. Therefore, CBCTLMSG is functionally equivalent to HI(WORD, wParam&) in a conventional Callback Function, and equivalent to HI(WORD, CBWPARAM) in a DDT Callback Function.

Restrictions 

This function is only valid inside a Callback Function.

See also

Dynamic Dialog Tools, CBCTL, CBHNDL, CBLPARAM, CBMSG, CBWPARAM

Example

CALLBACK FUNCTION ButtonCallback() AS LONG

  SELECT CASE CBMSG

    CASE %WM_COMMAND

      IF CBCTL = %ID_OK AND CBCTLMSG = %BN_CLICKED THEN

        MSGBOX "Button was clicked!", %MB_TASKMODAL

        FUNCTION = 1

        EXIT FUNCTION

      END IF

    END SELECT

END FUNCTION