diff win/dw.c @ 39:3aa9ef0b3996

Added focus fixes and set-focus fixes on all three platforms.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 19 Oct 2001 14:16:50 +0000
parents 360bc6a5f1c9
children 88c9c7410c22
line wrap: on
line diff
--- a/win/dw.c	Wed Oct 17 19:22:39 2001 +0000
+++ b/win/dw.c	Fri Oct 19 14:16:50 2001 +0000
@@ -293,6 +293,9 @@
 	if(!handle)
 		return 0;
 
+	if(!IsWindowEnabled(handle))
+		return 0;
+
 	GetClassName(handle, tmpbuf, 99);
 
 	/* These are the window classes which can
@@ -320,6 +323,13 @@
 		if(cinfo && cinfo->buddy)
 			return cinfo->buddy;
 	}
+	if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0) /* Combobox */
+	{
+		ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA);
+
+		if(cinfo && cinfo->buddy)
+			return cinfo->buddy;
+	}
 	return handle;
 }
 
@@ -1516,7 +1526,9 @@
 		case WM_CHAR:
 			if(LOWORD(mp1) == '\t')
 			{
-				if(cinfo->buddy)
+				if(cinfo->combo)
+					_shift_focus(cinfo->combo);
+				else if(cinfo->buddy)
 					_shift_focus(cinfo->buddy);
 				else
 					_shift_focus(hWnd);
@@ -1525,7 +1537,7 @@
 			/* Tell the spinner control that a keypress has
 			 * occured and to update it's internal value.
 			 */
-			if(cinfo->buddy)
+			if(cinfo->buddy && !cinfo->combo)
 				SendMessage(cinfo->buddy, WM_USER+10, 0, 0);
 			break;
 		case WM_USER+10:
@@ -2532,7 +2544,7 @@
  */
 int dw_window_show(HWND handle)
 {
-    int rc = ShowWindow(handle, SW_SHOW);
+	int rc = ShowWindow(handle, SW_SHOW);
 	SetFocus(handle);
 	_initial_focus(handle);
 	return rc;
@@ -3277,6 +3289,19 @@
 	return tmp;
 }
 
+BOOL CALLBACK _subclass_child(HWND handle, LPARAM lp)
+{
+	ColorInfo *cinfo = (ColorInfo *)lp;
+
+	if(cinfo)
+	{
+		cinfo->buddy = handle;
+		cinfo->pOldProc = (WNDPROC)SubclassWindow(handle, _colorwndproc);
+		SetWindowLong(handle, GWL_USERDATA, (ULONG)cinfo);
+	}
+	return FALSE;
+}
+
 /*
  * Create a new Combobox window (widget) to be packed.
  * Parameters:
@@ -3293,7 +3318,7 @@
 							(HMENU)id,
 							NULL,
 							NULL);
-	ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo));
+	ColorInfo *cinfo = (ColorInfo *)calloc(1, sizeof(ColorInfo));
 
 	if(!cinfo)
 	{
@@ -3301,9 +3326,10 @@
 		return NULL;
 	}
 
-	cinfo->cinfo.fore = -1;
-	cinfo->cinfo.back = -1;
-	cinfo->pOldProc = (WNDPROC)SubclassWindow(tmp, _containerwndproc);
+	cinfo->fore = -1;
+	cinfo->back = -1;
+	cinfo->combo = tmp;
+	EnumChildWindows(tmp, _subclass_child, (LPARAM)cinfo);
 
 	SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo);
 	dw_window_set_font(tmp, DefaultFont);
@@ -4278,7 +4304,7 @@
 	SetWindowText(handle, tmpbuf);
 
 	free(tmpbuf);
-	return startpoint+strlen(buffer);
+	return startpoint+strlen(buffer) - 1;
 }
 
 /*