Alberto Bricio
Alberto Bricio

Reputation: 432

Change style of CSpinButtonCtrl

I have tried to change orientation property of CSpinButtonCtrl in C++ MFC.

By default I have specified orientation property as vertical, nevertheless when I try to change property style to horizontal (UDS_HORZ) during execution, it doesn't work...

Sample code

CRect rect;
CWnd *pWnd;

pWnd = GetDlgItem(IDC_SPIN_GRAD_CONTRAST);
pWnd->GetWindowRect(&rect);
((CSpinButtonCtrl*)pWnd)->Create(WS_VISIBLE | UDS_HORZ, rect, pWnd->GetParent(), IDC_SPIN_GRAD_CONTRAST);

It creates a horizontal spin button control.

What I pretend to do is find any way to change the style without changing position and behaviour of the control previously created

I will appreciate any kind of help.

Upvotes: 0

Views: 274

Answers (1)

xMRi
xMRi

Reputation: 15375

Some styles of controls can only be used when you create the control.

AFAIK you have to recreate the control.

On the other hand I looked into the source code of the CMFCSpinButtonCtrl. Using this allows dynamically changing the orientation. Make sure that you force to redraw the control.

PS: Changing this at runtime seams to be a strange scenario for me.

Upvotes: 3

Related Questions