comparison win/dw.c @ 1131:5d27b8562c6f

With subclasses calling _wndproc directly on Windows, save the result... and if the handler returned TRUE do not call the higher level procedure. A full audit of the Windows procedure tree is really required to ensure proper behavior.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 02 Sep 2011 18:02:29 +0000
parents e8e7f048f0b8
children 6d618dcff792
comparison
equal deleted inserted replaced
1130:c3138ffd0de0 1131:5d27b8562c6f
2605 BOOL CALLBACK _colorwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) 2605 BOOL CALLBACK _colorwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
2606 { 2606 {
2607 ColorInfo *cinfo; 2607 ColorInfo *cinfo;
2608 char tmpbuf[100]; 2608 char tmpbuf[100];
2609 WNDPROC pOldProc = 0; 2609 WNDPROC pOldProc = 0;
2610 int ret = -1;
2610 2611
2611 cinfo = (ColorInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA); 2612 cinfo = (ColorInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
2612 2613
2613 GetClassName(hWnd, tmpbuf, 99); 2614 GetClassName(hWnd, tmpbuf, 99);
2614 if(strcmp(tmpbuf, FRAMECLASSNAME) == 0) 2615 if(strcmp(tmpbuf, FRAMECLASSNAME) == 0)
2615 cinfo = &(((Box *)cinfo)->cinfo); 2616 cinfo = &(((Box *)cinfo)->cinfo);
2616 2617
2617 if ( msg == WM_MOUSEMOVE ) 2618 if ( msg == WM_MOUSEMOVE )
2618 _wndproc(hWnd, msg, mp1, mp2); 2619 ret = _wndproc(hWnd, msg, mp1, mp2);
2619 2620
2620 if (cinfo) 2621 if (cinfo)
2621 { 2622 {
2622 pOldProc = cinfo->pOldProc; 2623 pOldProc = cinfo->pOldProc;
2623 2624
2624 switch( msg ) 2625 switch( msg )
2625 { 2626 {
2626 case WM_SETFOCUS: 2627 case WM_SETFOCUS:
2627 if(cinfo->combo) 2628 if(cinfo->combo)
2628 _wndproc(cinfo->combo, msg, mp1, mp2); 2629 ret = _wndproc(cinfo->combo, msg, mp1, mp2);
2629 else 2630 else
2630 _wndproc(hWnd, msg, mp1, mp2); 2631 ret = _wndproc(hWnd, msg, mp1, mp2);
2631 break; 2632 break;
2632 case WM_VSCROLL: 2633 case WM_VSCROLL:
2633 case WM_HSCROLL: 2634 case WM_HSCROLL:
2634 _wndproc(hWnd, msg, mp1, mp2); 2635 ret = _wndproc(hWnd, msg, mp1, mp2);
2635 break; 2636 break;
2636 case WM_KEYDOWN: 2637 case WM_KEYDOWN:
2637 case WM_KEYUP: 2638 case WM_KEYUP:
2638 { 2639 {
2639 if (hWnd && (mp1 == VK_UP || mp1 == VK_DOWN)) 2640 if (hWnd && (mp1 == VK_UP || mp1 == VK_DOWN))
2640 { 2641 {
2641 BOOL ret;
2642
2643 if (!cinfo || !cinfo->pOldProc) 2642 if (!cinfo || !cinfo->pOldProc)
2644 ret = DefWindowProc(hWnd, msg, mp1, mp2); 2643 ret = DefWindowProc(hWnd, msg, mp1, mp2);
2645 ret = CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2); 2644 ret = CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2);
2646 2645
2647 /* Tell the spinner control that a keypress has 2646 /* Tell the spinner control that a keypress has
2661 break; 2660 break;
2662 case WM_TIMER: 2661 case WM_TIMER:
2663 { 2662 {
2664 if(mp1 == 101) 2663 if(mp1 == 101)
2665 { 2664 {
2666 BOOL ret;
2667
2668 if(!cinfo || !cinfo->pOldProc) 2665 if(!cinfo || !cinfo->pOldProc)
2669 ret = DefWindowProc(hWnd, msg, mp1, mp2); 2666 ret = DefWindowProc(hWnd, msg, mp1, mp2);
2670 ret = CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2); 2667 ret = CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2);
2671 2668
2672 /* Tell the spinner control that a keypress has 2669 /* Tell the spinner control that a keypress has
2678 return ret; 2675 return ret;
2679 } 2676 }
2680 } 2677 }
2681 break; 2678 break;
2682 case WM_CHAR: 2679 case WM_CHAR:
2683 _wndproc(hWnd, msg, mp1, mp2); 2680 ret = _wndproc(hWnd, msg, mp1, mp2);
2684 if (LOWORD(mp1) == '\t') 2681 if (ret != TRUE && LOWORD(mp1) == '\t')
2685 { 2682 {
2686 if (GetAsyncKeyState(VK_SHIFT) & 0x8000) 2683 if (GetAsyncKeyState(VK_SHIFT) & 0x8000)
2687 { 2684 {
2688 if (cinfo->combo) 2685 if (cinfo->combo)
2689 _shift_focus_back(cinfo->combo); 2686 _shift_focus_back(cinfo->combo);
2818 } 2815 }
2819 break; 2816 break;
2820 } 2817 }
2821 } 2818 }
2822 2819
2823 if(!pOldProc) 2820 if(ret == -1)
2824 return DefWindowProc(hWnd, msg, mp1, mp2); 2821 {
2825 return CallWindowProc(pOldProc, hWnd, msg, mp1, mp2); 2822 if(!pOldProc)
2823 return DefWindowProc(hWnd, msg, mp1, mp2);
2824 return CallWindowProc(pOldProc, hWnd, msg, mp1, mp2);
2825 }
2826 return ret;
2826 } 2827 }
2827 2828
2828 BOOL CALLBACK _containerwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) 2829 BOOL CALLBACK _containerwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
2829 { 2830 {
2830 ContainerInfo *cinfo; 2831 ContainerInfo *cinfo;
2944 } 2945 }
2945 2946
2946 BOOL CALLBACK _treewndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) 2947 BOOL CALLBACK _treewndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
2947 { 2948 {
2948 ContainerInfo *cinfo; 2949 ContainerInfo *cinfo;
2950 int ret = -1;
2949 2951
2950 cinfo = (ContainerInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA); 2952 cinfo = (ContainerInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
2951 2953
2952 switch( msg ) 2954 switch( msg )
2953 { 2955 {
2954 case WM_MOUSEMOVE: 2956 case WM_MOUSEMOVE:
2955 _wndproc(hWnd, msg, mp1, mp2); 2957 ret = _wndproc(hWnd, msg, mp1, mp2);
2956 break; 2958 break;
2957 case WM_CHAR: 2959 case WM_CHAR:
2958 if(LOWORD(mp1) == '\t') 2960 ret = _wndproc(hWnd, msg, mp1, mp2);
2961 if(ret != TRUE && LOWORD(mp1) == '\t')
2959 { 2962 {
2960 if(GetAsyncKeyState(VK_SHIFT) & 0x8000) 2963 if(GetAsyncKeyState(VK_SHIFT) & 0x8000)
2961 _shift_focus_back(hWnd); 2964 _shift_focus_back(hWnd);
2962 else 2965 else
2963 _shift_focus(hWnd); 2966 _shift_focus(hWnd);
2964 return FALSE; 2967 return FALSE;
2965 } 2968 }
2966 break; 2969 break;
2967 } 2970 }
2968 2971
2969 if(!cinfo || !cinfo->pOldProc) 2972 if(ret != TRUE)
2970 return DefWindowProc(hWnd, msg, mp1, mp2); 2973 {
2971 return CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2); 2974 if(!cinfo || !cinfo->pOldProc)
2975 return DefWindowProc(hWnd, msg, mp1, mp2);
2976 return CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2);
2977 }
2978 return ret;
2972 } 2979 }
2973 2980
2974 void _changebox(Box *thisbox, int percent, int type) 2981 void _changebox(Box *thisbox, int percent, int type)
2975 { 2982 {
2976 int z; 2983 int z;