HeaderPane
Main
Hide
Share Link
Print

HorizontalOffset

Defines the current horizontal offset (in pixels) of the displayed area.

C

int WINAPI SftBox_GetHorizontalOffset(HWND hwndCtl);
BOOL WINAPI SftBox_SetHorizontalOffset(HWND hwndCtl, int offset);

C++

int CSftBox::GetHorizontalOffset() const;
BOOL CSftBox::SetHorizontalOffset(int offset);

Parameters

hwndCtl

The window handle of the combo box control.

offset

The new offset (in pixels) of the displayed area. If this parameter is greater than the largest possible offset, the value is adjusted to scroll to the rightmost position possible. -1 can be specified to scroll to the rightmost position possible. Values less than -1 are not valid.

Returns

GetHorizontalOffset returns the current offset (in pixels) of the displayed area.

SetHorizontalOffset returns TRUE if the function was successful, otherwise FALSE is returned.

Comments

The GetHorizontalOffset and SetHorizontalOffset functions define the current horizontal offset (in pixels) of the displayed area.

The displayable area can be wider than the dropdown portion of the combo box control (see SetHorizontalExtent). If the displayable area is wider, the dropdown portion can be scrolled horizontally if the combo box has a horizontal scroll bar (WS_HSCROLL window style). The current offset determines the amount of horizontal scrolling. The current offset of the displayed area can be set by the application using SetHorizontalOffset.

The dropdown portion can only be scrolled horizontally if the displayable area is wider than the dropdown portion.

The horizontal offset of the dropdown portion is also used for the static portion of the combo box control.

The SFTBOXN_OFFSETCHANGE notification is sent to the parent window when the horizontal offset changes because the combo box is scrolled horizontally. It is not sent when the offset is changed using SetHorizontalOffset.

Examples

C View entire sample code

                if (SftBox_GetHeaderButton(hwndCtl) == 0) {
                    m_fFontsDescending = !m_fFontsDescending;
                    SortFonts();
                    SetSortIndicator(hwndCtl, m_fFontsDescending);
                }
                break;
            case SFTBOXN_SELENDOK:
            case SFTBOXN_SELENDCANCEL:
                SftBox_SetHorizontalOffset(hwndCtl, 0);
                break;
            }
            break;

        case IDC_FONTSTYLE:             // FONT STYLE
            if (code == SFTBOXN_SELCHANGE)
                PaintSample(hwndDlg, GetDlgItem(hwndDlg, IDC_SAMPLE));

C++ View entire sample code

        m_fFontsDescending = !m_fFontsDescending;
        SortFonts();
        SetSortIndicator(m_Fonts, m_fFontsDescending);
    }
}

void CMainDlg::OnFontsSelEnd()
{
    m_Fonts.SetHorizontalOffset(0);
}

void CMainDlg::OnStyleSelChange()
{
    PaintSample();
}

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


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