HeaderPane
Main
Hide

SftButton/DLL 3.0 - Button Control

Share Link
Print

Create

Create a SftButton control as a child window of an existing CWnd parent. Used to add a button programmatically rather than through a dialog template.

C++

BOOL CSftButton::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
BOOL CSftButton::Create(LPCTSTR lpszCaption, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);

Parameters

lpszCaption

Initial button caption. Available on the second overload only - sent to the control as the WM_CREATE window text. Equivalent to creating without a caption and then calling SetWindowText. Use a single ampersand (&) to mark an accelerator key; use && to render a literal ampersand.

dwStyle

Window styles. WS_CHILD is required. WS_VISIBLE shows the button immediately; WS_TABSTOP makes it part of the tab order. SftButton does not define any custom window styles - all control-specific configuration goes through SFTBUTTON_CONTROL.

rect

Initial position and size of the button in the parent's client coordinates.

pParentWnd

Pointer to the parent CWnd. Must be non-NULL.

nID

Control identifier. Used as the wParam of WM_COMMAND notifications and to find the control with GetDlgItem.

Return Value

TRUE if the window was created, FALSE on failure (typically because RegisterApp has not been called).

Comments

Both overloads are thin wrappers around CWnd::Create with the SFTBUTTON_CLASS window class. CSftButton::RegisterApp must have been called for the calling process before the first Create.

Most applications create buttons through dialog resources rather than Create - see Creating a Dialog Resource. Programmatic Create is most useful when the button count or layout is computed at run time.

See Also RegisterApp | SFTBUTTON_CLASS | Creating a Dialog Resource | Using C++/MFC


Last Updated 05/09/2026 - (email)
© 2026 Softel vdm, Inc.