comparison os2/dw.c @ 34:b03b24bb95f8

Added dw_window_default() to set the default focus widget in a dialog. Also some fixes for containers on OS/2.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 03 Sep 2001 23:30:43 +0000
parents 72675de7d229
children 360bc6a5f1c9
comparison
equal deleted inserted replaced
33:72675de7d229 34:b03b24bb95f8
148 } 148 }
149 return 0L; 149 return 0L;
150 } 150 }
151 #endif 151 #endif
152 152
153 /* This function changes the owner of buttons in to the
154 * dynamicwindows handle to fix a problem in notebooks.
155 */
156 void _fix_button_owner(HWND handle, HWND dw)
157 {
158 HENUM henum;
159 HWND child;
160
161 henum = WinBeginEnumWindows(handle);
162 while((child = WinGetNextWindow(henum)) != NULLHANDLE)
163 {
164 char tmpbuf[100];
165
166 WinQueryClassName(child, 99, tmpbuf);
167
168 if(strncmp(tmpbuf, "#3", 3)==0 && dw) /* Button */
169 WinSetOwner(child, dw);
170 else if(strncmp(tmpbuf, "dynamicwindows", 14) == 0)
171 dw = child;
172
173 _fix_button_owner(child, dw);
174 }
175 WinEndEnumWindows(henum);
176 return;
177 }
178
153 /* This function removes and handlers on windows and frees 179 /* This function removes and handlers on windows and frees
154 * the user memory allocated to it. 180 * the user memory allocated to it.
155 */ 181 */
156 void _free_window_memory(HWND handle) 182 void _free_window_memory(HWND handle)
157 { 183 {
192 WinQueryClassName(handle, 99, tmpbuf); 218 WinQueryClassName(handle, 99, tmpbuf);
193 219
194 /* These are the window classes which can 220 /* These are the window classes which can
195 * obtain input focus. 221 * obtain input focus.
196 */ 222 */
197 if(strncmp(tmpbuf, "#2", 2)==0 || /* Entryfield */ 223 if(strncmp(tmpbuf, "#2", 3)==0 || /* Entryfield */
198 strncmp(tmpbuf, "#3", 2)==0 || /* Button */ 224 strncmp(tmpbuf, "#3", 3)==0 || /* Button */
199 strncmp(tmpbuf, "#6", 2)==0 || /* Combobox */ 225 strncmp(tmpbuf, "#6", 3)==0 || /* Combobox */
200 strncmp(tmpbuf, "#7", 2)==0 || /* List box */ 226 strncmp(tmpbuf, "#7", 3)==0 || /* List box */
201 strncmp(tmpbuf, "#10", 3)==0 || /* MLE */ 227 strncmp(tmpbuf, "#10", 3)==0 || /* MLE */
202 strncmp(tmpbuf, "#32", 3)==0 || /* Spinbutton */ 228 strncmp(tmpbuf, "#32", 3)==0 || /* Spinbutton */
203 strncmp(tmpbuf, "#37", 3)== 0) /* Container */ 229 strncmp(tmpbuf, "#37", 3)== 0) /* Container */
204 return 1; 230 return 1;
205 return 0; 231 return 0;
206 } 232 }
207 233
208 int _focus_check_box(Box *box, HWND handle, int start) 234 int _focus_check_box(Box *box, HWND handle, int start, HWND defaultitem)
209 { 235 {
210 int z; 236 int z;
211 static HWND lasthwnd, firsthwnd; 237 static HWND lasthwnd, firsthwnd;
212 static int finish_searching; 238 static int finish_searching;
213 239
240 { 266 {
241 if(box->items[z].type == TYPEBOX) 267 if(box->items[z].type == TYPEBOX)
242 { 268 {
243 Box *thisbox = WinQueryWindowPtr(box->items[z].hwnd, QWP_USER); 269 Box *thisbox = WinQueryWindowPtr(box->items[z].hwnd, QWP_USER);
244 270
245 if(thisbox && _focus_check_box(thisbox, handle, start == 3 ? 3 : 0)) 271 if(thisbox && _focus_check_box(thisbox, handle, start == 3 ? 3 : 0, defaultitem))
246 return 1; 272 return 1;
247 } 273 }
248 else 274 else
249 { 275 {
250 if(box->items[z].hwnd == handle) 276 if(box->items[z].hwnd == handle)
267 /* Start is 3 when we are looking for the 293 /* Start is 3 when we are looking for the
268 * first valid item in the layout. 294 * first valid item in the layout.
269 */ 295 */
270 if(start == 3) 296 if(start == 3)
271 { 297 {
272 WinSetFocus(HWND_DESKTOP, box->items[z].hwnd); 298 if(!defaultitem || (defaultitem && defaultitem == box->items[z].hwnd))
273 return 1; 299 {
300 WinSetFocus(HWND_DESKTOP, box->items[z].hwnd);
301 return 1;
302 }
274 } 303 }
275 304
276 if(!firsthwnd) 305 if(!firsthwnd)
277 firsthwnd = box->items[z].hwnd; 306 firsthwnd = box->items[z].hwnd;
278 307
291 320
292 if(page) 321 if(page)
293 { 322 {
294 notebox = (Box *)WinQueryWindowPtr(page, QWP_USER); 323 notebox = (Box *)WinQueryWindowPtr(page, QWP_USER);
295 324
296 if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0)) 325 if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0, defaultitem))
297 return 1; 326 return 1;
298 } 327 }
299 } 328 }
300 } 329 }
301 } 330 }
307 { 336 {
308 if(box->items[z].type == TYPEBOX) 337 if(box->items[z].type == TYPEBOX)
309 { 338 {
310 Box *thisbox = WinQueryWindowPtr(box->items[z].hwnd, QWP_USER); 339 Box *thisbox = WinQueryWindowPtr(box->items[z].hwnd, QWP_USER);
311 340
312 if(thisbox && _focus_check_box(thisbox, handle, start == 3 ? 3 : 0)) 341 if(thisbox && _focus_check_box(thisbox, handle, start == 3 ? 3 : 0, defaultitem))
313 return 1; 342 return 1;
314 } 343 }
315 else 344 else
316 { 345 {
317 if(box->items[z].hwnd == handle) 346 if(box->items[z].hwnd == handle)
334 /* Start is 3 when we are looking for the 363 /* Start is 3 when we are looking for the
335 * first valid item in the layout. 364 * first valid item in the layout.
336 */ 365 */
337 if(start == 3) 366 if(start == 3)
338 { 367 {
339 WinSetFocus(HWND_DESKTOP, box->items[z].hwnd); 368 if(!defaultitem || (defaultitem && defaultitem == box->items[z].hwnd))
340 return 1; 369 {
370 WinSetFocus(HWND_DESKTOP, box->items[z].hwnd);
371 return 1;
372 }
341 } 373 }
342 374
343 if(!firsthwnd) 375 if(!firsthwnd)
344 firsthwnd = box->items[z].hwnd; 376 firsthwnd = box->items[z].hwnd;
345 377
358 390
359 if(page) 391 if(page)
360 { 392 {
361 notebox = (Box *)WinQueryWindowPtr(page, QWP_USER); 393 notebox = (Box *)WinQueryWindowPtr(page, QWP_USER);
362 394
363 if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0)) 395 if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0, defaultitem))
364 return 1; 396 return 1;
365 } 397 }
366 } 398 }
367 } 399 }
368 } 400 }
383 if(box) 415 if(box)
384 thisbox = WinQueryWindowPtr(box, QWP_USER); 416 thisbox = WinQueryWindowPtr(box, QWP_USER);
385 417
386 if(thisbox) 418 if(thisbox)
387 { 419 {
388 _focus_check_box(thisbox, handle, 3); 420 _focus_check_box(thisbox, handle, 3, thisbox->defaultitem);
389 } 421 }
390 } 422 }
391 423
392 /* This function finds the current widget in the 424 /* This function finds the current widget in the
393 * layout and moves the current focus to the next item. 425 * layout and moves the current focus to the next item.
409 else 441 else
410 thisbox = WinQueryWindowPtr(lastbox, QWP_USER); 442 thisbox = WinQueryWindowPtr(lastbox, QWP_USER);
411 443
412 if(thisbox) 444 if(thisbox)
413 { 445 {
414 if(_focus_check_box(thisbox, handle, 1) == 0) 446 if(_focus_check_box(thisbox, handle, 1, 0) == 0)
415 _focus_check_box(thisbox, handle, 2); 447 _focus_check_box(thisbox, handle, 2, 0);
416 } 448 }
417 } 449 }
418 450
419 /* ResetWindow: 451 /* ResetWindow:
420 * Resizes window to the exact same size to trigger 452 * Resizes window to the exact same size to trigger
867 if(thisbox->items[z].hsize != SIZEEXPAND) 899 if(thisbox->items[z].hsize != SIZEEXPAND)
868 vectorx = 0; 900 vectorx = 0;
869 901
870 WinQueryClassName(handle, 99, tmpbuf); 902 WinQueryClassName(handle, 99, tmpbuf);
871 903
872 if(strncmp(tmpbuf, "#2", 2)==0) 904 if(strncmp(tmpbuf, "#2", 3)==0)
873 { 905 {
874 /* Make the combobox big enough to drop down. :) */ 906 /* Make the combobox big enough to drop down. :) */
875 WinSetWindowPos(handle, HWND_TOP, currentx + pad, (currenty + pad) - 100, 907 WinSetWindowPos(handle, HWND_TOP, currentx + pad, (currenty + pad) - 100,
876 width + vectorx, (height + vectory) + 100, SWP_MOVE | SWP_SIZE | SWP_ZORDER); 908 width + vectorx, (height + vectory) + 100, SWP_MOVE | SWP_SIZE | SWP_ZORDER);
877 } 909 }
878 else if(strncmp(tmpbuf, "#6", 2)==0) 910 else if(strncmp(tmpbuf, "#6", 3)==0)
879 { 911 {
880 /* Entryfields on OS/2 have a thick border that isn't on Windows and GTK */ 912 /* Entryfields on OS/2 have a thick border that isn't on Windows and GTK */
881 WinSetWindowPos(handle, HWND_TOP, (currentx + pad) + 3, (currenty + pad) + 3, 913 WinSetWindowPos(handle, HWND_TOP, (currentx + pad) + 3, (currenty + pad) + 3,
882 (width + vectorx) - 6, (height + vectory) - 6, SWP_MOVE | SWP_SIZE | SWP_ZORDER); 914 (width + vectorx) - 6, (height + vectory) - 6, SWP_MOVE | SWP_SIZE | SWP_ZORDER);
883 } 915 }
913 return 0; 945 return 0;
914 } 946 }
915 947
916 void _do_resize(Box *thisbox, int x, int y) 948 void _do_resize(Box *thisbox, int x, int y)
917 { 949 {
918 if(x != 0 && y != 0) { 950 if(x != 0 && y != 0)
951 {
919 if(thisbox) 952 if(thisbox)
920 { 953 {
921 int usedx = 0, usedy = 0, usedpadx = 0, usedpady = 0, depth = 0; 954 int usedx = 0, usedy = 0, usedpadx = 0, usedpady = 0, depth = 0;
922 955
923 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 1, &usedpadx, &usedpady); 956 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 1, &usedpadx, &usedpady);
1522 1555
1523 dw_listbox_query_text(tmp->window, index, buf1, 500); 1556 dw_listbox_query_text(tmp->window, index, buf1, 500);
1524 1557
1525 WinQueryClassName(tmp->window, 99, classbuf); 1558 WinQueryClassName(tmp->window, 99, classbuf);
1526 1559
1527 if(id && strncmp(classbuf, "#2", 2)==0) 1560 if(id && strncmp(classbuf, "#2", 3)==0)
1528 { 1561 {
1529 char *buf2; 1562 char *buf2;
1530 1563
1531 buf2 = dw_window_get_text(tmp->window); 1564 buf2 = dw_window_get_text(tmp->window);
1532 1565
1683 mybox->flags = 0; 1716 mybox->flags = 0;
1684 1717
1685 if(mybox && (swp->fl & SWP_MAXIMIZE)) 1718 if(mybox && (swp->fl & SWP_MAXIMIZE))
1686 { 1719 {
1687 int z; 1720 int z;
1721 SWP swp2;
1722
1723 WinQueryWindowPos(swp->hwnd, &swp2);
1724
1725 if(swp2.cx == swp->cx && swp2.cy == swp->cy)
1726 return FALSE;
1688 1727
1689 mybox->flags = 0; 1728 mybox->flags = 0;
1690 1729
1691 /* Hide the window when recalculating to reduce 1730 /* Hide the window when recalculating to reduce
1692 * CPU load. 1731 * CPU load.
2505 { 2544 {
2506 int rc = WinSetWindowPos(handle, NULLHANDLE, 0, 0, 0, 0, SWP_SHOW); 2545 int rc = WinSetWindowPos(handle, NULLHANDLE, 0, 0, 0, 0, SWP_SHOW);
2507 HSWITCH hswitch; 2546 HSWITCH hswitch;
2508 SWCNTRL swcntrl; 2547 SWCNTRL swcntrl;
2509 2548
2549 _fix_button_owner(handle, 0);
2510 WinSetFocus(HWND_DESKTOP, handle); 2550 WinSetFocus(HWND_DESKTOP, handle);
2511 _initial_focus(handle); 2551 _initial_focus(handle);
2512 2552
2513 /* If this window has a switch list entry make sure it is visible */ 2553 /* If this window has a switch list entry make sure it is visible */
2514 hswitch = WinQuerySwitchHandle(handle, 0); 2554 hswitch = WinQuerySwitchHandle(handle, 0);
3594 HWND found; 3634 HWND found;
3595 3635
3596 WinQueryClassName(child, 99, tmpbuf); 3636 WinQueryClassName(child, 99, tmpbuf);
3597 3637
3598 /* If the child is a box (frame) then recurse into it */ 3638 /* If the child is a box (frame) then recurse into it */
3599 if(strncmp(tmpbuf, "#1", 2)==0) 3639 if(strncmp(tmpbuf, "#1", 3)==0)
3600 if((found = dw_window_from_id(child, id)) != NULLHANDLE) 3640 if((found = dw_window_from_id(child, id)) != NULLHANDLE)
3601 return found; 3641 return found;
3602 3642
3603 if(windowid && windowid == id) 3643 if(windowid && windowid == id)
3604 { 3644 {
3678 tmpitem[z] = thisitem[z]; 3718 tmpitem[z] = thisitem[z];
3679 } 3719 }
3680 3720
3681 WinQueryClassName(item, 99, tmpbuf); 3721 WinQueryClassName(item, 99, tmpbuf);
3682 3722
3683 if(strncmp(tmpbuf, "#1", 2)==0) 3723 if(strncmp(tmpbuf, "#1", 3)==0)
3684 tmpitem[thisbox->count].type = TYPEBOX; 3724 tmpitem[thisbox->count].type = TYPEBOX;
3685 else 3725 else
3686 tmpitem[thisbox->count].type = TYPEITEM; 3726 tmpitem[thisbox->count].type = TYPEITEM;
3687 3727
3688 tmpitem[thisbox->count].hwnd = item; 3728 tmpitem[thisbox->count].hwnd = item;
3706 3746
3707 thisbox->count++; 3747 thisbox->count++;
3708 3748
3709 /* Don't set the ownership if it's an entryfield or combobox */ 3749 /* Don't set the ownership if it's an entryfield or combobox */
3710 WinQueryClassName(item, 99, tmpbuf); 3750 WinQueryClassName(item, 99, tmpbuf);
3711 if(strncmp(tmpbuf, "#6", 2)!=0 /*&& strncmp(tmpbuf, "#2", 2)!=0*/) 3751 if(strncmp(tmpbuf, "#6", 3)!=0 /*&& strncmp(tmpbuf, "#2", 2)!=0*/)
3712 { 3752 {
3713 if((boxowner = WinQueryWindow(box, QW_OWNER)) != 0) 3753 if((boxowner = WinQueryWindow(box, QW_OWNER)) != 0)
3714 WinSetOwner(item, boxowner); 3754 WinSetOwner(item, boxowner);
3715 else 3755 else
3716 WinSetOwner(item, box); 3756 WinSetOwner(item, box);
4032 * index: Item index. 4072 * index: Item index.
4033 * state: TRUE if selected FALSE if unselected. 4073 * state: TRUE if selected FALSE if unselected.
4034 */ 4074 */
4035 void dw_listbox_select(HWND handle, int index, int state) 4075 void dw_listbox_select(HWND handle, int index, int state)
4036 { 4076 {
4077 char tmpbuf[100];
4078
4037 WinSendMsg(handle, LM_SELECTITEM, MPFROMSHORT(index), (MPARAM)state); 4079 WinSendMsg(handle, LM_SELECTITEM, MPFROMSHORT(index), (MPARAM)state);
4038 _run_event(handle, WM_CONTROL, MPFROM2SHORT(0, LN_SELECT), (MPARAM)handle); 4080
4081 WinQueryClassName(handle, 99, tmpbuf);
4082
4083 /* If we are setting a combobox call the event handler manually */
4084 if(strncmp(tmpbuf, "#6", 3)==0)
4085 _run_event(handle, WM_CONTROL, MPFROM2SHORT(0, LN_SELECT), (MPARAM)handle);
4039 } 4086 }
4040 4087
4041 /* 4088 /*
4042 * Deletes the item with given index from the list. 4089 * Deletes the item with given index from the list.
4043 * Parameters: 4090 * Parameters:
4625 { 4672 {
4626 ULONG *flags = (ULONG *)WinQueryWindowPtr(handle, 0); 4673 ULONG *flags = (ULONG *)WinQueryWindowPtr(handle, 0);
4627 int z, size = 0, totalsize, count = 0; 4674 int z, size = 0, totalsize, count = 0;
4628 PRECORDCORE temp; 4675 PRECORDCORE temp;
4629 ContainerInfo *ci; 4676 ContainerInfo *ci;
4630 void *blah; 4677 void *blah = NULL;
4631 4678
4632 if(!flags) 4679 if(!flags || rowcount < 1)
4633 return NULL; 4680 return NULL;
4634 4681
4635 while(flags[count]) 4682 while(flags[count])
4636 count++; 4683 count++;
4637 4684
4650 size += sizeof(CTIME); 4697 size += sizeof(CTIME);
4651 } 4698 }
4652 4699
4653 totalsize = size + sizeof(RECORDCORE); 4700 totalsize = size + sizeof(RECORDCORE);
4654 4701
4655 blah = (void *)WinSendMsg(handle, CM_ALLOCRECORD, MPFROMLONG(size), MPFROMLONG(rowcount)); 4702 z = 0;
4703
4704 while((blah = (void *)WinSendMsg(handle, CM_ALLOCRECORD, MPFROMLONG(size), MPFROMLONG(rowcount))) == NULL)
4705 {
4706 z++;
4707 if(z > 5000000)
4708 break;
4709 DosSleep(1);
4710 }
4656 4711
4657 if(!blah) 4712 if(!blah)
4658 return NULL; 4713 return NULL;
4659 4714
4660 temp = (PRECORDCORE)blah; 4715 temp = (PRECORDCORE)blah;
4785 * title: String title of the item. 4840 * title: String title of the item.
4786 */ 4841 */
4787 void dw_container_set_row_title(void *pointer, int row, char *title) 4842 void dw_container_set_row_title(void *pointer, int row, char *title)
4788 { 4843 {
4789 ContainerInfo *ci = (ContainerInfo *)pointer; 4844 ContainerInfo *ci = (ContainerInfo *)pointer;
4790 PRECORDCORE temp = (PRECORDCORE)ci->data; 4845 PRECORDCORE temp;
4791 int z, currentcount; 4846 int z, currentcount;
4792 CNRINFO cnr; 4847 CNRINFO cnr;
4793 4848
4794 if(!ci) 4849 if(!ci)
4795 return; 4850 return;
4851
4852 temp = (PRECORDCORE)ci->data;
4796 4853
4797 WinSendMsg(ci->handle, CM_QUERYCNRINFO, (MPARAM)&cnr, MPFROMSHORT(sizeof(CNRINFO))); 4854 WinSendMsg(ci->handle, CM_QUERYCNRINFO, (MPARAM)&cnr, MPFROMSHORT(sizeof(CNRINFO)));
4798 currentcount = cnr.cRecords; 4855 currentcount = cnr.cRecords;
4799 4856
4800 for(z=0;z<(row-currentcount);z++) 4857 for(z=0;z<(row-currentcount);z++)
4814 */ 4871 */
4815 void dw_container_insert(HWND handle, void *pointer, int rowcount) 4872 void dw_container_insert(HWND handle, void *pointer, int rowcount)
4816 { 4873 {
4817 RECORDINSERT recin; 4874 RECORDINSERT recin;
4818 ContainerInfo *ci = (ContainerInfo *)pointer; 4875 ContainerInfo *ci = (ContainerInfo *)pointer;
4876 int z;
4819 4877
4820 if(!ci) 4878 if(!ci)
4821 return; 4879 return;
4822 4880
4823 recin.cb = sizeof(RECORDINSERT); 4881 recin.cb = sizeof(RECORDINSERT);
4825 recin.pRecordParent = NULL; 4883 recin.pRecordParent = NULL;
4826 recin.zOrder = CMA_TOP; 4884 recin.zOrder = CMA_TOP;
4827 recin.fInvalidateRecord = TRUE; 4885 recin.fInvalidateRecord = TRUE;
4828 recin.cRecordsInsert = rowcount; 4886 recin.cRecordsInsert = rowcount;
4829 4887
4830 WinSendMsg(handle, CM_INSERTRECORD, MPFROMP(ci->data), MPFROMP(&recin)); 4888 z = 0;
4889
4890 while(WinSendMsg(handle, CM_INSERTRECORD, MPFROMP(ci->data), MPFROMP(&recin)) == 0)
4891 {
4892 z++;
4893 if(z > 5000000)
4894 break;
4895 DosSleep(1);
4896 }
4831 } 4897 }
4832 4898
4833 /* 4899 /*
4834 * Removes all rows from a container. 4900 * Removes all rows from a container.
4835 * Parameters: 4901 * Parameters:
4836 * handle: Handle to the window (widget) to be cleared. 4902 * handle: Handle to the window (widget) to be cleared.
4837 */ 4903 */
4838 void dw_container_clear(HWND handle) 4904 void dw_container_clear(HWND handle)
4839 { 4905 {
4840 WinSendMsg(handle, CM_REMOVERECORD, (MPARAM)0L, MPFROM2SHORT(0, CMA_INVALIDATE | CMA_FREE)); 4906 int z = 0;
4907
4908 while((int)WinSendMsg(handle, CM_REMOVERECORD, (MPARAM)0L, MPFROM2SHORT(0, CMA_INVALIDATE | CMA_FREE)) == -1)
4909 {
4910 z++;
4911 if(z > 5000000)
4912 break;
4913 DosSleep(1);
4914 }
4841 } 4915 }
4842 4916
4843 /* 4917 /*
4844 * Removes the first x rows from a container. 4918 * Removes the first x rows from a container.
4845 * Parameters: 4919 * Parameters:
4847 * rowcount: The number of rows to be deleted. 4921 * rowcount: The number of rows to be deleted.
4848 */ 4922 */
4849 void dw_container_delete(HWND handle, int rowcount) 4923 void dw_container_delete(HWND handle, int rowcount)
4850 { 4924 {
4851 RECORDCORE *last, **prc = malloc(sizeof(RECORDCORE *) * rowcount); 4925 RECORDCORE *last, **prc = malloc(sizeof(RECORDCORE *) * rowcount);
4852 int current = 1; 4926 int current = 1, z;
4853 4927
4854 prc[0] = last = (RECORDCORE *)WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); 4928 prc[0] = last = (RECORDCORE *)WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
4855 4929
4856 while(last && current < rowcount) 4930 while(last && current < rowcount)
4857 { 4931 {
4858 prc[current] = last = (RECORDCORE *)WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)last, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 4932 prc[current] = last = (RECORDCORE *)WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)last, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
4859 current++; 4933 current++;
4860 } 4934 }
4861 WinSendMsg(handle, CM_REMOVERECORD, (MPARAM)prc, MPFROM2SHORT(current, CMA_INVALIDATE | CMA_FREE)); 4935
4936 z = 0;
4937
4938 while((int)WinSendMsg(handle, CM_REMOVERECORD, (MPARAM)prc, MPFROM2SHORT(current, CMA_INVALIDATE | CMA_FREE)) == -1)
4939 {
4940 z++;
4941 if(z > 5000000)
4942 break;
4943 DosSleep(1);
4944 }
4945
4862 free(prc); 4946 free(prc);
4863 } 4947 }
4864 4948
4865 /* 4949 /*
4866 * Scrolls container up or down. 4950 * Scrolls container up or down.
5734 tmpitem[z+1] = thisitem[z]; 5818 tmpitem[z+1] = thisitem[z];
5735 } 5819 }
5736 5820
5737 WinQueryClassName(item, 99, tmpbuf); 5821 WinQueryClassName(item, 99, tmpbuf);
5738 5822
5739 if(strncmp(tmpbuf, "#1", 2)==0) 5823 if(strncmp(tmpbuf, "#1", 3)==0)
5740 tmpitem[0].type = TYPEBOX; 5824 tmpitem[0].type = TYPEBOX;
5741 else 5825 else
5742 tmpitem[0].type = TYPEITEM; 5826 tmpitem[0].type = TYPEITEM;
5743 5827
5744 tmpitem[0].hwnd = item; 5828 tmpitem[0].hwnd = item;
5762 5846
5763 thisbox->count++; 5847 thisbox->count++;
5764 5848
5765 WinQueryClassName(item, 99, tmpbuf); 5849 WinQueryClassName(item, 99, tmpbuf);
5766 /* Don't set the ownership if it's an entryfield or combobox */ 5850 /* Don't set the ownership if it's an entryfield or combobox */
5767 if(strncmp(tmpbuf, "#6", 2)!=0 /*&& strncmp(tmpbuf, "#2", 2)!=0*/) 5851 if(strncmp(tmpbuf, "#6", 3)!=0 /*&& strncmp(tmpbuf, "#2", 2)!=0*/)
5768 { 5852 {
5769 if((boxowner = WinQueryWindow(box, QW_OWNER)) != 0) 5853 if((boxowner = WinQueryWindow(box, QW_OWNER)) != 0)
5770 WinSetOwner(item, boxowner); 5854 WinSetOwner(item, boxowner);
5771 else 5855 else
5772 WinSetOwner(item, box); 5856 WinSetOwner(item, box);
5856 } 5940 }
5857 } 5941 }
5858 return (ulBuild); 5942 return (ulBuild);
5859 } 5943 }
5860 5944
5945 /*
5946 * Sets the default focus item for a window/dialog.
5947 * Parameters:
5948 * window: Toplevel window or dialog.
5949 * defaultitem: Handle to the dialog item to be default.
5950 */
5951 void dw_window_default(HWND window, HWND defaultitem)
5952 {
5953 Box *thisbox = NULL;
5954 HWND box;
5955
5956 box = WinWindowFromID(window, FID_CLIENT);
5957 if(box)
5958 thisbox = WinQueryWindowPtr(box, QWP_USER);
5959
5960 if(thisbox)
5961 thisbox->defaultitem = defaultitem;
5962 }
5861 5963
5862 /* 5964 /*
5863 * Returns some information about the current operating environment. 5965 * Returns some information about the current operating environment.
5864 * Parameters: 5966 * Parameters:
5865 * env: Pointer to a DWEnv struct. 5967 * env: Pointer to a DWEnv struct.