ID Number: Q66944
3.00 3.10
WINDOWS
Summary:
The SendDlgItemMessage function is equivalent to obtaining the
handle of a dialog control using the GetDlgItem function and then
calling the SendMessage function with that handle. The
SendDlgItemMessage function therefore takes slightly longer to
execute than the SendMessage function for the same message, because
an extra call to the GetDlgItem function is required each time the
SendDlgItemMessage function is called.
The GetDlgItem function searches through all controls in a given
dialog box to find one that matches the given ID value. If there are
many controls in a dialog box, the GetDlgItem function can be quite
slow.
If an application needs to send more than one message to a dialog
control at one time, it is more efficient to call the GetDlgItem
function once, using the returned handle in subsequent SendMessage
calls. This saves Windows from searching through all the controls
each time a message is sent. The SendMessage function should also be
used when your application retains handles to controls that receive
messages.
However, if your application needs to send one message to many
controls, such as sending WM_SETFONT messages to all the controls in a
dialog, then the SendDlgItemMessage function will save code in the
application because a call to the GetDlgItem function is not made for
each control.
Note that if the message sent to a control may result in a lengthy
operation (such as sending the LB_DIR message to a list box), then the
overhead in the GetDlgItem call is negligible. Either the
SendDlgItemMessage or SendMessage can be used, whichever is more
convenient.
Additional reference words: 3.00 3.10 3.x send mess dlgitem