Sign in to follow this  

UDM_SETRANGE problems.

This topic is 4780 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to get an updown control working properly with it's buddy window. The relevant section of code is as follows:
LRESULT CALLBACK RemoteEditDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	static HWND updownHwnd, portHwnd = NULL;
	NMUPDOWN *lpud = new NMUPDOWN;
	NMHDR *nmHdr = new NMHDR;
	TCHAR port[10];
	static int current = 0;
	int next = 0;
	switch(message)
	{
	case WM_INITDIALOG:
		CreateWindow(WC_IPADDRESS, NULL, WS_CHILD | WS_VISIBLE, 90, 37, 125, 25, hDlg,
			NULL, hInst, NULL);
		updownHwnd = CreateWindow(UPDOWN_CLASS, NULL, WS_CHILD | WS_VISIBLE | UDS_WRAP, 
			280, 37, 75, 25, hDlg, NULL, hInst, NULL);
		portHwnd = GetDlgItem(hDlg, IDC_PORT);
		SendMessage(updownHwnd, UDM_SETBUDDY, (WPARAM)portHwnd, 0);
		SendMessage(updownHwnd, UDM_SETRANGE, 0, (LPARAM) MAKELONG ((short)65535,(short)1));
		return TRUE;
		
	case WM_NOTIFY:
		nmHdr = (LPNMHDR)lParam;
		switch(nmHdr->code){
			case UDN_DELTAPOS:
				lpud = (LPNMUPDOWN)lParam;
				current = lpud->iPos;
				if(lpud->iDelta > lpud->iPos)
					current++;
				else
					current--;
				SendMessage(updownHwnd, UDM_SETPOS, 0, (LPARAM)current);
				wsprintf(port, "%d", current);
				SetDlgItemText(hDlg, IDC_PORT, (LPCTSTR)port);
				return 0;
		}
		break;

	case WM_COMMAND:
		if(LOWORD(wParam) == IDCANCEL)
			EndDialog(hDlg, LOWORD(wParam));
		break;
	}
	return FALSE;
}
[\source]

The up arrow is the only one that works and it changes from -1 to -2. The down arrow outputs a 0. If anyone can point out my mistake i'd appreciate it. Thanx!

Share this post


Link to post
Share on other sites

This topic is 4780 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this