Skip to main content
gamedev.net
🔒 Locked

UDM_SETRANGE problems.

Started by tdk_ratboy Nov 13, 2004 at 7:21 PM 0 replies 1.3k views
Original Post
tdk_ratboy
tdk_ratboy
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!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.