PSN_QUERYINITIALFOCUS notification code

Sent by a property sheet to provide a property sheet page an opportunity to specify which dialog box control should receive the initial focus. This notification code is sent in the form of a WM_NOTIFY message.


PSN_QUERYINITIALFOCUS

    lppsn = (LPPSHNOTIFY) lParam; 

Parameters

lParam

Pointer to a PSHNOTIFY structure. Cast the lParam member of this structure to an HWND type, to retrieve the handle of the control that will be given focus by default. The structure contains an NMHDR structure as its first member, hdr. The hwndFrom member of this NMHDR structure contains the handle to the property sheet.

Return value

To specify which control should receive focus, return the control's handle. Otherwise, return zero and focus will go to the default control. To set the return value, the dialog box procedure must call the SetWindowLong function with a DWL_MSGRESULT value and return TRUE.

Remarks

An application must not call the SetFocus function while handling this notification code. Return the handle of the control that should receive focus, and the property sheet manager will handle the focus change.

The PSN_QUERYINITIALFOCUS notification code is not sent if the property sheet manager determines that no control on the page should receive focus.

This code fragment implements a simple handler for PSN_QUERYINITIALFOCUS. It requests that initial focus be given to the Location control (IDC_LOCATION).

case PSN_QUERYINITIALFOCUS :
    SetWindowLong(hDlg,DWL_MSGRESULT, (LPARAM)GetDlgItem(hDlg, IDC_LOCATION));
    return TRUE;
...
Note  This notification code is not supported when using the Aero wizard style (PSH_AEROWIZARD).
 

Requirements

Minimum supported client

Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

Header

Prsht.h

 

 

Show: