Mercurial > dwindows
comparison os2/dw.c @ 1196:452a5b1b2aa5
Fixed a longstanding issue on OS/2 of event handlers being
triggered by events on the wrong window when more than one
slider/percent control is in a box. Removed that from the
known issues, although it was incorrectly attributed as a
Windows bug instead of an OS/2 bug.
Also createda GlobalID() function that will keep the global
ID used by unspecified controls within the "short" range.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 28 Sep 2011 16:51:56 +0000 |
parents | 9b021f787ad1 |
children | cad6f7aa421c |
comparison
equal
deleted
inserted
replaced
1195:9b021f787ad1 | 1196:452a5b1b2aa5 |
---|---|
56 DWTID _dwtid = 0; | 56 DWTID _dwtid = 0; |
57 LONG _foreground = 0xAAAAAA, _background = DW_CLR_DEFAULT; | 57 LONG _foreground = 0xAAAAAA, _background = DW_CLR_DEFAULT; |
58 | 58 |
59 HWND hwndApp = NULLHANDLE, hwndBubble = NULLHANDLE, hwndBubbleLast = NULLHANDLE, hwndEmph = NULLHANDLE; | 59 HWND hwndApp = NULLHANDLE, hwndBubble = NULLHANDLE, hwndBubbleLast = NULLHANDLE, hwndEmph = NULLHANDLE; |
60 PRECORDCORE pCoreEmph = NULL; | 60 PRECORDCORE pCoreEmph = NULL; |
61 ULONG aulBuffer[4], GlobalID = 10000; | 61 ULONG aulBuffer[4]; |
62 HWND lasthcnr = 0, lastitem = 0, popup = 0, desktop; | 62 HWND lasthcnr = 0, lastitem = 0, popup = 0, desktop; |
63 HMOD wpconfig = 0; | 63 HMOD wpconfig = 0; |
64 | 64 |
65 unsigned long _colors[] = { | 65 unsigned long _colors[] = { |
66 CLR_BLACK, | 66 CLR_BLACK, |
126 { WM_SETFOCUS, DW_SIGNAL_SET_FOCUS }, | 126 { WM_SETFOCUS, DW_SIGNAL_SET_FOCUS }, |
127 { SLN_SLIDERTRACK, DW_SIGNAL_VALUE_CHANGED }, | 127 { SLN_SLIDERTRACK, DW_SIGNAL_VALUE_CHANGED }, |
128 { BKN_PAGESELECTED,DW_SIGNAL_SWITCH_PAGE }, | 128 { BKN_PAGESELECTED,DW_SIGNAL_SWITCH_PAGE }, |
129 { CN_EXPANDTREE, DW_SIGNAL_TREE_EXPAND } | 129 { CN_EXPANDTREE, DW_SIGNAL_TREE_EXPAND } |
130 }; | 130 }; |
131 | |
132 /* Internal function to keep a semi-unique ID within valid range */ | |
133 USHORT _GlobalID(void) | |
134 { | |
135 static USHORT GlobalID = 9999; | |
136 | |
137 GlobalID++; | |
138 if(GlobalID == 65535) | |
139 { | |
140 GlobalID = 10000; | |
141 } | |
142 return GlobalID; | |
143 } | |
131 | 144 |
132 /* This function adds a signal handler callback into the linked list. | 145 /* This function adds a signal handler callback into the linked list. |
133 */ | 146 */ |
134 void _new_signal(ULONG message, HWND window, int id, void *signalfunction, void *data) | 147 void _new_signal(ULONG message, HWND window, int id, void *signalfunction, void *data) |
135 { | 148 { |
2463 case WM_CONTROL: | 2476 case WM_CONTROL: |
2464 if(origmsg == WM_VSCROLL || origmsg == WM_HSCROLL || tmp->message == SHORT2FROMMP(mp1) || | 2477 if(origmsg == WM_VSCROLL || origmsg == WM_HSCROLL || tmp->message == SHORT2FROMMP(mp1) || |
2465 (tmp->message == SLN_SLIDERTRACK && SHORT2FROMMP(mp1) == SLN_CHANGE)) | 2478 (tmp->message == SLN_SLIDERTRACK && SHORT2FROMMP(mp1) == SLN_CHANGE)) |
2466 { | 2479 { |
2467 int svar = SLN_SLIDERTRACK; | 2480 int svar = SLN_SLIDERTRACK; |
2481 int id = SHORT1FROMMP(mp1); | |
2482 HWND notifyhwnd = dw_window_from_id(hWnd, id); | |
2483 | |
2468 if(origmsg == WM_CONTROL) | 2484 if(origmsg == WM_CONTROL) |
2469 svar = SHORT2FROMMP(mp1); | 2485 svar = SHORT2FROMMP(mp1); |
2470 | 2486 |
2471 switch(svar) | 2487 switch(svar) |
2472 { | 2488 { |
2473 case CN_ENTER: | 2489 case CN_ENTER: |
2474 { | 2490 { |
2475 int (* API containerselectfunc)(HWND, char *, void *) = (int (* API)(HWND, char *, void *))tmp->signalfunction; | 2491 int (* API containerselectfunc)(HWND, char *, void *) = (int (* API)(HWND, char *, void *))tmp->signalfunction; |
2476 int id = SHORT1FROMMP(mp1); | |
2477 HWND conthwnd = dw_window_from_id(hWnd, id); | |
2478 char *text = NULL; | 2492 char *text = NULL; |
2479 | 2493 |
2480 if(mp2) | 2494 if(mp2) |
2481 { | 2495 { |
2482 PRECORDCORE pre; | 2496 PRECORDCORE pre; |
2484 pre = ((PNOTIFYRECORDENTER)mp2)->pRecord; | 2498 pre = ((PNOTIFYRECORDENTER)mp2)->pRecord; |
2485 if(pre) | 2499 if(pre) |
2486 text = pre->pszIcon; | 2500 text = pre->pszIcon; |
2487 } | 2501 } |
2488 | 2502 |
2489 if(tmp->window == conthwnd) | 2503 if(tmp->window == notifyhwnd) |
2490 { | 2504 { |
2491 result = containerselectfunc(tmp->window, text, tmp->data); | 2505 result = containerselectfunc(tmp->window, text, tmp->data); |
2492 tmp = NULL; | 2506 tmp = NULL; |
2493 } | 2507 } |
2494 } | 2508 } |
2495 break; | 2509 break; |
2496 case CN_EXPANDTREE: | 2510 case CN_EXPANDTREE: |
2497 { | 2511 { |
2498 int (* API treeexpandfunc)(HWND, HTREEITEM, void *) = (int (* API)(HWND, HTREEITEM, void *))tmp->signalfunction; | 2512 int (* API treeexpandfunc)(HWND, HTREEITEM, void *) = (int (* API)(HWND, HTREEITEM, void *))tmp->signalfunction; |
2499 int id = SHORT1FROMMP(mp1); | 2513 |
2500 HWND conthwnd = dw_window_from_id(hWnd, id); | 2514 if(tmp->window == notifyhwnd) |
2501 | |
2502 if(tmp->window == conthwnd) | |
2503 { | 2515 { |
2504 result = treeexpandfunc(tmp->window, (HTREEITEM)mp2, tmp->data); | 2516 result = treeexpandfunc(tmp->window, (HTREEITEM)mp2, tmp->data); |
2505 tmp = NULL; | 2517 tmp = NULL; |
2506 } | 2518 } |
2507 } | 2519 } |
2508 break; | 2520 break; |
2509 case CN_CONTEXTMENU: | 2521 case CN_CONTEXTMENU: |
2510 { | 2522 { |
2511 int (* API containercontextfunc)(HWND, char *, int, int, void *, void *) = (int (* API)(HWND, char *, int, int, void *, void *))tmp->signalfunction; | 2523 int (* API containercontextfunc)(HWND, char *, int, int, void *, void *) = (int (* API)(HWND, char *, int, int, void *, void *))tmp->signalfunction; |
2512 int id = SHORT1FROMMP(mp1); | |
2513 HWND conthwnd = dw_window_from_id(hWnd, id); | |
2514 char *text = NULL; | 2524 char *text = NULL; |
2515 void *user = NULL; | 2525 void *user = NULL; |
2516 LONG x,y; | 2526 LONG x,y; |
2517 | 2527 |
2518 if(mp2) | 2528 if(mp2) |
2525 user = pci->user; | 2535 user = pci->user; |
2526 } | 2536 } |
2527 | 2537 |
2528 dw_pointer_query_pos(&x, &y); | 2538 dw_pointer_query_pos(&x, &y); |
2529 | 2539 |
2530 if(tmp->window == conthwnd) | 2540 if(tmp->window == notifyhwnd) |
2531 { | 2541 { |
2532 int container = (int)dw_window_get_data(tmp->window, "_dw_container"); | 2542 int container = (int)dw_window_get_data(tmp->window, "_dw_container"); |
2533 | 2543 |
2534 if(mp2) | 2544 if(mp2) |
2535 { | 2545 { |
2609 | 2619 |
2610 if(strncmp(classbuf, "#38", 4) == 0) | 2620 if(strncmp(classbuf, "#38", 4) == 0) |
2611 { | 2621 { |
2612 int (* API valuechangedfunc)(HWND, int, void *) = (int (* API)(HWND, int, void *))tmp->signalfunction; | 2622 int (* API valuechangedfunc)(HWND, int, void *) = (int (* API)(HWND, int, void *))tmp->signalfunction; |
2613 | 2623 |
2614 if(tmp->window == hWnd || WinQueryWindow(tmp->window, QW_PARENT) == hWnd) | 2624 if(tmp->window == hWnd || notifyhwnd == hWnd) |
2615 { | 2625 { |
2616 static int lastvalue = -1; | 2626 static int lastvalue = -1; |
2617 static HWND lasthwnd = NULLHANDLE; | 2627 static HWND lasthwnd = NULLHANDLE; |
2618 int ulValue = (int)WinSendMsg(tmp->window, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), 0); | 2628 int ulValue = (int)WinSendMsg(tmp->window, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), 0); |
2619 if(lastvalue != ulValue || lasthwnd != tmp->window) | 2629 if(lastvalue != ulValue || lasthwnd != tmp->window) |
2626 } | 2636 } |
2627 } | 2637 } |
2628 else | 2638 else |
2629 { | 2639 { |
2630 int (* API listboxselectfunc)(HWND, int, void *) = (int (* API )(HWND, int, void *))tmp->signalfunction; | 2640 int (* API listboxselectfunc)(HWND, int, void *) = (int (* API )(HWND, int, void *))tmp->signalfunction; |
2631 int id = SHORT1FROMMP(mp1); | |
2632 HWND conthwnd = dw_window_from_id(hWnd, id); | |
2633 static int _recursing = 0; | 2641 static int _recursing = 0; |
2634 | 2642 |
2635 if(_recursing == 0 && (tmp->window == conthwnd || (!id && tmp->window == (HWND)mp2))) | 2643 if(_recursing == 0 && (tmp->window == notifyhwnd || (!id && tmp->window == (HWND)mp2))) |
2636 { | 2644 { |
2637 char buf1[500]; | 2645 char buf1[500]; |
2638 int index = dw_listbox_selected(tmp->window); | 2646 int index = dw_listbox_selected(tmp->window); |
2639 | 2647 |
2640 dw_listbox_get_text(tmp->window, index, buf1, 500); | 2648 dw_listbox_get_text(tmp->window, index, buf1, 500); |
2670 int (* API valuechangedfunc)(HWND, int, void *) = (int (* API)(HWND, int, void *))tmp->signalfunction; | 2678 int (* API valuechangedfunc)(HWND, int, void *) = (int (* API)(HWND, int, void *))tmp->signalfunction; |
2671 | 2679 |
2672 if(origmsg == WM_CONTROL) | 2680 if(origmsg == WM_CONTROL) |
2673 { | 2681 { |
2674 /* Handle Slider control */ | 2682 /* Handle Slider control */ |
2675 if(tmp->window == hWnd || WinQueryWindow(tmp->window, QW_PARENT) == hWnd) | 2683 if(tmp->window == hWnd || tmp->window == notifyhwnd) |
2676 { | 2684 { |
2677 static int lastvalue = -1; | 2685 static int lastvalue = -1; |
2678 static HWND lasthwnd = NULLHANDLE; | 2686 static HWND lasthwnd = NULLHANDLE; |
2679 int ulValue = (int)WinSendMsg(tmp->window, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), 0); | 2687 int ulValue = (int)WinSendMsg(tmp->window, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE), 0); |
2680 if(lastvalue != ulValue || lasthwnd != tmp->window) | 2688 if(lastvalue != ulValue || lasthwnd != tmp->window) |
2688 } | 2696 } |
2689 } | 2697 } |
2690 else | 2698 else |
2691 { | 2699 { |
2692 /* Handle scrollbar control */ | 2700 /* Handle scrollbar control */ |
2693 if(tmp->window > 65535 && tmp->window == WinWindowFromID(hWnd, (ULONG)mp1)) | 2701 if(tmp->window > 65535 && tmp->window == notifyhwnd) |
2694 { | 2702 { |
2695 int pos = _HandleScroller(tmp->window, (int)SHORT1FROMMP(mp2), (int)SHORT2FROMMP(mp2));; | 2703 int pos = _HandleScroller(tmp->window, (int)SHORT1FROMMP(mp2), (int)SHORT2FROMMP(mp2));; |
2696 | 2704 |
2697 if(pos > -1) | 2705 if(pos > -1) |
2698 { | 2706 { |
4848 (multi ? CCS_EXTENDSEL : CCS_SINGLESEL) | | 4856 (multi ? CCS_EXTENDSEL : CCS_SINGLESEL) | |
4849 CCS_AUTOPOSITION, | 4857 CCS_AUTOPOSITION, |
4850 0,0,2000,1000, | 4858 0,0,2000,1000, |
4851 NULLHANDLE, | 4859 NULLHANDLE, |
4852 HWND_TOP, | 4860 HWND_TOP, |
4853 id ? id : (GlobalID++), | 4861 id ? id : _GlobalID(), |
4854 NULL, | 4862 NULL, |
4855 NULL); | 4863 NULL); |
4856 blah->oldproc = WinSubclassWindow(tmp, _TreeProc); | 4864 blah->oldproc = WinSubclassWindow(tmp, _TreeProc); |
4857 WinSetWindowPtr(tmp, QWP_USER, blah); | 4865 WinSetWindowPtr(tmp, QWP_USER, blah); |
4858 dw_window_set_font(tmp, DefaultFont); | 4866 dw_window_set_font(tmp, DefaultFont); |
4876 WS_VISIBLE | CCS_READONLY | | 4884 WS_VISIBLE | CCS_READONLY | |
4877 CCS_SINGLESEL | CCS_AUTOPOSITION, | 4885 CCS_SINGLESEL | CCS_AUTOPOSITION, |
4878 0,0,2000,1000, | 4886 0,0,2000,1000, |
4879 NULLHANDLE, | 4887 NULLHANDLE, |
4880 HWND_TOP, | 4888 HWND_TOP, |
4881 id ? id : (GlobalID++), | 4889 id ? id : _GlobalID(), |
4882 NULL, | 4890 NULL, |
4883 NULL); | 4891 NULL); |
4884 | 4892 |
4885 cnrinfo.flWindowAttr = CV_TREE | CA_TREELINE; | 4893 cnrinfo.flWindowAttr = CV_TREE | CA_TREELINE; |
4886 cnrinfo.slBitmapOrIcon.cx = 16; | 4894 cnrinfo.slBitmapOrIcon.cx = 16; |
5051 text, | 5059 text, |
5052 WS_VISIBLE | CBS_DROPDOWN | WS_GROUP, | 5060 WS_VISIBLE | CBS_DROPDOWN | WS_GROUP, |
5053 0,0,2000,1000, | 5061 0,0,2000,1000, |
5054 NULLHANDLE, | 5062 NULLHANDLE, |
5055 HWND_TOP, | 5063 HWND_TOP, |
5056 id, | 5064 id ? id : _GlobalID(), |
5057 NULL, | 5065 NULL, |
5058 NULL); | 5066 NULL); |
5059 HENUM henum = WinBeginEnumWindows(tmp); | 5067 HENUM henum = WinBeginEnumWindows(tmp); |
5060 HWND child, last = NULLHANDLE; | 5068 HWND child, last = NULLHANDLE; |
5061 | 5069 |
5474 WS_VISIBLE | SLS_SNAPTOINCREMENT | | 5482 WS_VISIBLE | SLS_SNAPTOINCREMENT | |
5475 (vertical ? SLS_VERTICAL : SLS_HORIZONTAL), | 5483 (vertical ? SLS_VERTICAL : SLS_HORIZONTAL), |
5476 0,0,2000,1000, | 5484 0,0,2000,1000, |
5477 NULLHANDLE, | 5485 NULLHANDLE, |
5478 HWND_TOP, | 5486 HWND_TOP, |
5479 id, | 5487 id ? id : _GlobalID(), |
5480 &sldcData, | 5488 &sldcData, |
5481 NULL); | 5489 NULL); |
5482 | 5490 |
5483 blah->oldproc = WinSubclassWindow(tmp, _entryproc); | 5491 blah->oldproc = WinSubclassWindow(tmp, _entryproc); |
5484 WinSetWindowPtr(tmp, QWP_USER, blah); | 5492 WinSetWindowPtr(tmp, QWP_USER, blah); |
5500 WS_VISIBLE | SBS_AUTOTRACK | | 5508 WS_VISIBLE | SBS_AUTOTRACK | |
5501 (vertical ? SBS_VERT : SBS_HORZ), | 5509 (vertical ? SBS_VERT : SBS_HORZ), |
5502 0,0,2000,1000, | 5510 0,0,2000,1000, |
5503 NULLHANDLE, | 5511 NULLHANDLE, |
5504 HWND_TOP, | 5512 HWND_TOP, |
5505 id ? id : (GlobalID++), | 5513 id ? id : _GlobalID(), |
5506 NULL, | 5514 NULL, |
5507 NULL); | 5515 NULL); |
5508 } | 5516 } |
5509 | 5517 |
5510 /* | 5518 /* |
5521 WS_VISIBLE | SLS_READONLY | 5529 WS_VISIBLE | SLS_READONLY |
5522 | SLS_RIBBONSTRIP, | 5530 | SLS_RIBBONSTRIP, |
5523 0,0,2000,1000, | 5531 0,0,2000,1000, |
5524 NULLHANDLE, | 5532 NULLHANDLE, |
5525 HWND_TOP, | 5533 HWND_TOP, |
5526 id, | 5534 id ? id : _GlobalID(), |
5527 NULL, | 5535 NULL, |
5528 NULL); | 5536 NULL); |
5529 blah->oldproc = WinSubclassWindow(tmp, _percentproc); | 5537 blah->oldproc = WinSubclassWindow(tmp, _percentproc); |
5530 WinSetWindowPtr(tmp, QWP_USER, blah); | 5538 WinSetWindowPtr(tmp, QWP_USER, blah); |
5531 dw_window_disable(tmp); | 5539 dw_window_disable(tmp); |
5575 WS_VISIBLE | LS_NOADJUSTPOS | | 5583 WS_VISIBLE | LS_NOADJUSTPOS | |
5576 (multi ? LS_MULTIPLESEL : 0), | 5584 (multi ? LS_MULTIPLESEL : 0), |
5577 0,0,2000,1000, | 5585 0,0,2000,1000, |
5578 NULLHANDLE, | 5586 NULLHANDLE, |
5579 HWND_TOP, | 5587 HWND_TOP, |
5580 id ? id : (GlobalID++), | 5588 id ? id : _GlobalID(), |
5581 NULL, | 5589 NULL, |
5582 NULL); | 5590 NULL); |
5583 blah->oldproc = WinSubclassWindow(tmp, _entryproc); | 5591 blah->oldproc = WinSubclassWindow(tmp, _entryproc); |
5584 WinSetWindowPtr(tmp, QWP_USER, blah); | 5592 WinSetWindowPtr(tmp, QWP_USER, blah); |
5585 dw_window_set_font(tmp, DefaultFont); | 5593 dw_window_set_font(tmp, DefaultFont); |