15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


LButton Press Problem

Shankara Narayana Giri -- giri@ndrgw.ndr.co.jp
Wednesday, May 15, 1996



        Environment : WIN 95, WINNT 3.51, VC4.0, VB 4.0

        Hello EveryBody,
             
               I hope somebody might have experienced the same problem. Please
        help me if anyone does. Thanks in advance.

        Here is my problem.

        I have a OCX built with OLE ControlWizard. The only addition I have made 
        to it is to trap WM_LBUTTONDOWN.

        void CMsgtestCtrl::OnLButtonDown(UINT nFlags, CPoint point) 
        {
         	MessageBox("here");	
        	COleControl::OnLButtonDown(nFlags, point);
        }

        Then I used VB 4.0 to test it. What I did was to place 2 objects of the
        same OCX on a form. Let me call it msgtest1 and msgtest2. I hope when
        I place a few controls upon a VB form, the focus lies with the oldest
        one(Am I right?). After placing them on the form, I ran it from within
        VB. 

        I clicked msgtest2(2nd object). My MessageBox got displayed. But from 
        then wherever I click, whether on the form or outside the form, or on
        window of some other application, My MessageBox kept on appearing. Even
        I could not STOP the program, nor I was able to destroy the form window.
        So, finally I had to use right button of the mouse to display some
        properties and change the focus.

        I also tried clicking msgtest1(First object) first. Until I clicked the
        second object, evrything went fine. But once clicked it, same thing 
        happened once again.

        I also tried the same thing with TEST CONTAINER supplied with VC 4.0
        The result was the same, the only difference being that in the case
        Test Container, the focus lies with the youngest control. So once I
        happened to click the First object, the problem started.

        Can anybody thow light upon this ASAP? Is displaying Message Box
        inside OnLButtonDown itself is a mistake?
         
        Also, I need one more help. Can anybody teach me how to use DUAL
        interface to achieve direct communication between OCXs on VB form?

        Thanks once again,
        S.N. GIRI
          

----------------------------------------------------------------
 
                        SHANKARA NARAYANA  GIRI
 
                                        Residential Address:
Design Division                         606, SUNSHINE MKM IMAZATO
Development & Engineering Dept.         10-5,O IMAZATO-NISHI 3-CHOME
NDR Co. Ltd.                            HIGASHI NARI-KU
OSAKA, JAPAN                            OSAKA   537, JAPAN
e-mail: giri@ndrgw.ndr.co.jp
 
Tel : 81-6-539-5511 (OFF)               Tel : 81-6-977-1517(RES)
      81-6-539-5512 (OFF)
 
Fax : 81-6-539-2111 (OFF)
---------------------------------------------------------------- 



Mark Kramer -- markkra@microsoft.com
Tuesday, May 21, 1996

Your problem is that even though you have handled the WM_LBUTTONDOWN
message yourself, you are still passing it on to the default behavior
provided
by COleControl. Do it like this and it will work.


>        void CMsgtestCtrl::OnLButtonDown(UINT nFlags, CPoint point) 
>        {
>         	MessageBox("here");	
        	// COleControl::OnLButtonDown(nFlags, point);    <== remove
>this line
>        }

If you step in to the COleControl code, you will see that there is a
SetCapture()
happening that gets released in the button up code. Your dialog box is
short
circuiting the button up message and so your ocx gets stuck with a
captured mouse.

Good luck.

>From the desk of ...
     Mark Kramer
	MFC QA

>----------
>From: 	Shankara Narayana Giri[SMTP:giri@ndrgw.ndr.co.jp]
>Sent: 	Wednesday, May 15, 1996 12:31 AM
>To: 	mfc-l@netcom.com
>Cc: 	miyamoto@ndrgw.ndr.co.jp; itomen@ndrgw.ndr.co.jp
>Subject: 	LButton Press Problem
>
>
>
>        Environment : WIN 95, WINNT 3.51, VC4.0, VB 4.0
>
>        Hello EveryBody,
>             
>               I hope somebody might have experienced the same problem.
>Please
>        help me if anyone does. Thanks in advance.
>
>        Here is my problem.
>
>        I have a OCX built with OLE ControlWizard. The only addition I
>have made 
>        to it is to trap WM_LBUTTONDOWN.
>
>        void CMsgtestCtrl::OnLButtonDown(UINT nFlags, CPoint point) 
>        {
>         	MessageBox("here");	
>        	COleControl::OnLButtonDown(nFlags, point);
>        }
>
>        Then I used VB 4.0 to test it. What I did was to place 2
>objects of the
>        same OCX on a form. Let me call it msgtest1 and msgtest2. I
>hope when
>        I place a few controls upon a VB form, the focus lies with the
>oldest
>        one(Am I right?). After placing them on the form, I ran it from
>within
>        VB. 
>
>        I clicked msgtest2(2nd object). My MessageBox got displayed.
>But from 
>        then wherever I click, whether on the form or outside the form,
>or on
>        window of some other application, My MessageBox kept on
>appearing. Even
>        I could not STOP the program, nor I was able to destroy the
>form window.
>        So, finally I had to use right button of the mouse to display
>some
>        properties and change the focus.
>
>        I also tried clicking msgtest1(First object) first. Until I
>clicked the
>        second object, evrything went fine. But once clicked it, same
>thing 
>        happened once again.
>
>        I also tried the same thing with TEST CONTAINER supplied with
>VC 4.0
>        The result was the same, the only difference being that in the
>case
>        Test Container, the focus lies with the youngest control. So
>once I
>        happened to click the First object, the problem started.
>
>        Can anybody thow light upon this ASAP? Is displaying Message
>Box
>        inside OnLButtonDown itself is a mistake?
>         
>        Also, I need one more help. Can anybody teach me how to use
>DUAL
>        interface to achieve direct communication between OCXs on VB
>form?
>
>        Thanks once again,
>        S.N. GIRI
>          
>
>----------------------------------------------------------------
> 
>                        SHANKARA NARAYANA  GIRI
> 
>                                        Residential Address:
>Design Division                         606, SUNSHINE MKM IMAZATO
>Development & Engineering Dept.         10-5,O IMAZATO-NISHI 3-CHOME
>NDR Co. Ltd.                            HIGASHI NARI-KU
>OSAKA, JAPAN                            OSAKA   537, JAPAN
>e-mail: giri@ndrgw.ndr.co.jp
> 
>Tel : 81-6-539-5511 (OFF)               Tel : 81-6-977-1517(RES)
>      81-6-539-5512 (OFF)
> 
>Fax : 81-6-539-2111 (OFF)
>---------------------------------------------------------------- 
>




| Вернуться в корень Архива |