Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Chapter 12: Dialog-Based Windows Visual C++ and MFC Fundamentals


If you are programmatically creating the control, to align its text to the right, set or add
the WS_EX_RIGHT extended style. Here is an example:

void CSecondDlg::OnThirdControl()
{
// TODO: Add your control notification handler code here
CWnd *CanTab = new CWnd;

CanTab->CreateEx(WS_EX_RIGHT, "BUTTON", "&Apply",
WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, );
}

The extended left text alignment is defined as:

#define WS_EX_RIGHT 0x00001000L

Practical Learning: Right-Aligning Text



  1. Set the Caption of the Custom control to Leo and change its ExStyle value to
    0x00001000

  2. Test the application

  3. Return to MSVC


11.5.4..Extended Borders................................................................................


Besides the border features of the dwStyle argument of the Create() member function, the
CreateEx() method provides other border drawings to apply to a control.

Static Borders: To give a 3-D appearance to a control, especially one that does not
receive input from the user (such as a static control), you can apply a static edge to it. To
do this, at design time, set the Static Edge property to True. At run time, you can set or
add the WS_EX_STATICEDGE extended style. Here is an example:

BOOL CBordersDlg::OnInitDialog()
{
Free download pdf