HeaderPane
Main
Hide
Share Link
Print

UserData

Defines the combo box control's application-specific value.

C

SFTBOX_DWORD_PTR WINAPI SftBox_GetUserData(HWND hwndCtl);
void WINAPI SftBox_SetUserData(HWND hwndCtl, SFTBOX_DWORD_PTR dwd);

C++

SFTBOX_DWORD_PTR CSftBox::GetUserData() const;
void CSftBox::SetUserData(SFTBOX_DWORD_PTR dwd);

Parameters

hwndCtl

The window handle of the combo box control.

dwd

The application-specific value to be saved for the combo box.

Returns

GetUserData returns the application-specific value last saved using SetUserData.

Comments

The GetUserData and SetUserData functions define the combo box control's application-specific value.

The value is saved for the combo box as a whole. It is not used by the combo box and can be used by an application for any purpose, for example to save a pointer to an application-defined structure. The value is of type SFTBOX_DWORD_PTR, so it can hold a pointer in 32-bit and 64-bit applications.

An application-specific value for an individual item can be saved using SetItemData.

Examples

C View entire sample code

    return lstrcmpi(lpszString2, lpszString1);
}

static void SortByColumn(HWND hwndBox)
{
    // The sort column and direction of each control are kept in its user data,
    // matching the sort indicator the control shows in the column title.
    int column = SftBox_GetHeaderButton(hwndBox);
    SFTBOX_DWORD_PTR state = SftBox_GetUserData(hwndBox);
    int lastColumn = (int) LOWORD(state) - 1;
    BOOL fDescending = HIWORD(state) != 0;

    if (column < 0)
        return;
    fDescending = (column == lastColumn) ? !fDescending : FALSE;
    SftBox_SortItems(hwndBox, -1, column, fDescending ? SortDescending : SortAscending);

C++ View entire sample code

    m_City.AddString(_T("Tampa"));
}

void CMainDlg::SortByColumn(CSftBox& box)
{
    // The sort column and direction of each control are kept in its user data,
    // matching the sort indicator the control shows in the column title.
    int column = box.GetHeaderButton();
    SFTBOX_DWORD_PTR state = box.GetUserData();
    int lastColumn = (int) LOWORD(state) - 1;
    BOOL fDescending = HIWORD(state) != 0;

    if (column < 0)
        return;
    fDescending = (column == lastColumn) ? !fDescending : FALSE;
    box.SortItems(-1, column, fDescending ? SortDescending : SortAscending);

See Also C/C++ API | Categories | Notifications


Last Updated 11/21/2026 - (email)
© 2026 Softel vdm, Inc.