Question

I am trying to make a simple spin control and edit box in WTL &/ winapi. and this does not work properly, because I only see 0 as initial value and the arrows don t work, code here:

HWND spin = GetDlgItem(IDC_SPIN1);
HWND edit = GetDlgItem(IDC_RANDOM_EDIT);
::SendMessage(spin, UDM_SETBUDDY, (WPARAM)edit, 0); //set buddy
::SendMessage(spin, UDM_SETRANGE, MAKELPARAM(0,100), 0); //interval

::SendMessage(spin, UDM_SETBASE, 10, 0); //initial position
Was it helpful?

Solution

You have your wparam and lparam reversed. You also have the low and high words reversed.

::SendMessage(spin, UDM_SETRANGE, 0, MAKELPARAM(100,0)); //interval

See the definitions of UDM_SETRANGE and MAKELPARAM.

OTHER TIPS

In WTL you have wrapper class CUpDownCtrl for up-down control. So it goes as simple as this:

CUpDownCtrl Control = ... // e.g. GetDlgItem(IDC_MYCONTROL);
INT nMinValue = 0, nMaxValue = 100;
Control.SetRange(nMinValue, nMaxValue);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top