Mercurial > dwindows
comparison 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 |
comparison
equal
deleted
inserted
replaced
38:538db2a48bac | 39:3aa9ef0b3996 |
---|---|
291 char tmpbuf[100]; | 291 char tmpbuf[100]; |
292 | 292 |
293 if(!handle) | 293 if(!handle) |
294 return 0; | 294 return 0; |
295 | 295 |
296 if(!IsWindowEnabled(handle)) | |
297 return 0; | |
298 | |
296 GetClassName(handle, tmpbuf, 99); | 299 GetClassName(handle, tmpbuf, 99); |
297 | 300 |
298 /* These are the window classes which can | 301 /* These are the window classes which can |
299 * obtain input focus. | 302 * obtain input focus. |
300 */ | 303 */ |
312 { | 315 { |
313 char tmpbuf[100] = ""; | 316 char tmpbuf[100] = ""; |
314 | 317 |
315 GetClassName(handle, tmpbuf, 99); | 318 GetClassName(handle, tmpbuf, 99); |
316 if(strnicmp(tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS))==0) /* Spinner */ | 319 if(strnicmp(tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS))==0) /* Spinner */ |
320 { | |
321 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA); | |
322 | |
323 if(cinfo && cinfo->buddy) | |
324 return cinfo->buddy; | |
325 } | |
326 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0) /* Combobox */ | |
317 { | 327 { |
318 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA); | 328 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA); |
319 | 329 |
320 if(cinfo && cinfo->buddy) | 330 if(cinfo && cinfo->buddy) |
321 return cinfo->buddy; | 331 return cinfo->buddy; |
1514 _wndproc(hWnd, msg, mp1, mp2); | 1524 _wndproc(hWnd, msg, mp1, mp2); |
1515 break; | 1525 break; |
1516 case WM_CHAR: | 1526 case WM_CHAR: |
1517 if(LOWORD(mp1) == '\t') | 1527 if(LOWORD(mp1) == '\t') |
1518 { | 1528 { |
1519 if(cinfo->buddy) | 1529 if(cinfo->combo) |
1530 _shift_focus(cinfo->combo); | |
1531 else if(cinfo->buddy) | |
1520 _shift_focus(cinfo->buddy); | 1532 _shift_focus(cinfo->buddy); |
1521 else | 1533 else |
1522 _shift_focus(hWnd); | 1534 _shift_focus(hWnd); |
1523 return FALSE; | 1535 return FALSE; |
1524 } | 1536 } |
1525 /* Tell the spinner control that a keypress has | 1537 /* Tell the spinner control that a keypress has |
1526 * occured and to update it's internal value. | 1538 * occured and to update it's internal value. |
1527 */ | 1539 */ |
1528 if(cinfo->buddy) | 1540 if(cinfo->buddy && !cinfo->combo) |
1529 SendMessage(cinfo->buddy, WM_USER+10, 0, 0); | 1541 SendMessage(cinfo->buddy, WM_USER+10, 0, 0); |
1530 break; | 1542 break; |
1531 case WM_USER+10: | 1543 case WM_USER+10: |
1532 { | 1544 { |
1533 if(cinfo->buddy) | 1545 if(cinfo->buddy) |
2530 * Parameters: | 2542 * Parameters: |
2531 * handle: The window handle to make visible. | 2543 * handle: The window handle to make visible. |
2532 */ | 2544 */ |
2533 int dw_window_show(HWND handle) | 2545 int dw_window_show(HWND handle) |
2534 { | 2546 { |
2535 int rc = ShowWindow(handle, SW_SHOW); | 2547 int rc = ShowWindow(handle, SW_SHOW); |
2536 SetFocus(handle); | 2548 SetFocus(handle); |
2537 _initial_focus(handle); | 2549 _initial_focus(handle); |
2538 return rc; | 2550 return rc; |
2539 } | 2551 } |
2540 | 2552 |
3275 SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo); | 3287 SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo); |
3276 dw_window_set_font(tmp, DefaultFont); | 3288 dw_window_set_font(tmp, DefaultFont); |
3277 return tmp; | 3289 return tmp; |
3278 } | 3290 } |
3279 | 3291 |
3292 BOOL CALLBACK _subclass_child(HWND handle, LPARAM lp) | |
3293 { | |
3294 ColorInfo *cinfo = (ColorInfo *)lp; | |
3295 | |
3296 if(cinfo) | |
3297 { | |
3298 cinfo->buddy = handle; | |
3299 cinfo->pOldProc = (WNDPROC)SubclassWindow(handle, _colorwndproc); | |
3300 SetWindowLong(handle, GWL_USERDATA, (ULONG)cinfo); | |
3301 } | |
3302 return FALSE; | |
3303 } | |
3304 | |
3280 /* | 3305 /* |
3281 * Create a new Combobox window (widget) to be packed. | 3306 * Create a new Combobox window (widget) to be packed. |
3282 * Parameters: | 3307 * Parameters: |
3283 * text: The default text to be in the combpbox widget. | 3308 * text: The default text to be in the combpbox widget. |
3284 * id: An ID to be used with WinWindowFromID() or 0L. | 3309 * id: An ID to be used with WinWindowFromID() or 0L. |
3291 0,0,2000,1000, | 3316 0,0,2000,1000, |
3292 DW_HWND_OBJECT, | 3317 DW_HWND_OBJECT, |
3293 (HMENU)id, | 3318 (HMENU)id, |
3294 NULL, | 3319 NULL, |
3295 NULL); | 3320 NULL); |
3296 ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo)); | 3321 ColorInfo *cinfo = (ColorInfo *)calloc(1, sizeof(ColorInfo)); |
3297 | 3322 |
3298 if(!cinfo) | 3323 if(!cinfo) |
3299 { | 3324 { |
3300 DestroyWindow(tmp); | 3325 DestroyWindow(tmp); |
3301 return NULL; | 3326 return NULL; |
3302 } | 3327 } |
3303 | 3328 |
3304 cinfo->cinfo.fore = -1; | 3329 cinfo->fore = -1; |
3305 cinfo->cinfo.back = -1; | 3330 cinfo->back = -1; |
3306 cinfo->pOldProc = (WNDPROC)SubclassWindow(tmp, _containerwndproc); | 3331 cinfo->combo = tmp; |
3332 EnumChildWindows(tmp, _subclass_child, (LPARAM)cinfo); | |
3307 | 3333 |
3308 SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo); | 3334 SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo); |
3309 dw_window_set_font(tmp, DefaultFont); | 3335 dw_window_set_font(tmp, DefaultFont); |
3310 return tmp; | 3336 return tmp; |
3311 } | 3337 } |
4276 memcpy(&tmpbuf[startpoint], buffer, strlen(buffer)); | 4302 memcpy(&tmpbuf[startpoint], buffer, strlen(buffer)); |
4277 | 4303 |
4278 SetWindowText(handle, tmpbuf); | 4304 SetWindowText(handle, tmpbuf); |
4279 | 4305 |
4280 free(tmpbuf); | 4306 free(tmpbuf); |
4281 return startpoint+strlen(buffer); | 4307 return startpoint+strlen(buffer) - 1; |
4282 } | 4308 } |
4283 | 4309 |
4284 /* | 4310 /* |
4285 * Grabs text from an MLE box. | 4311 * Grabs text from an MLE box. |
4286 * Parameters: | 4312 * Parameters: |