Mouse Out Event - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Mouse Out Event

VorenusVorenus Posts: 1Member
Hi all,

I am trying to figure out how to catch the fact that mouse is out of a control i got on a form. That is: I have some images on a form that i am using instead of buttons. The click event and mousemove events work fine. But i need to catch the fact that the mouse has left the control. Like an mouseout event. I have tried with just catching the mousemove event on the form, but if the images are to close and you move the mouse to fast its unstable. I am new to borland c++ so go easy on me :)

To sum up: I am trying to create a "webpage design" where i use images on a form with a rollover effect. No problems switching images using the mousemove event, however i am having trouble catching the fact that the mouse has left the control. I have also tried testing agains the width and height of the control againts the x and y of the mouse position, but with no luck. How do i go about this?

Vorenus

Comments

  • stephdev1965stephdev1965 Posts: 6Member
    Hello

    I have still the same need and am still looking for the solution...

    Do you have found a key for this problem ?

    May be you (we) can use the TApplicationEvent control to test simulate a MouSeOut event.

    regards
  • stephdev1965stephdev1965 Posts: 6Member
    This post has been deleted.
  • stephdev1965stephdev1965 Posts: 6Member
    Hello again

    I think i found an easy solution. I set up a little project to test it:

    TForm1: a form called myForm1, main form on the application with a TApplicationEvent instance called ApplicationEvents1.

    TForm2: a form called myForm2 with a picture called Image1,
    a TLabel called Label1, and others controls with or without focus capability.

    myForm1 creates an instance of TForm2 called myForm2

    myForm2Ok a global variable of the project

    On myForm2->Image1, MouseDown event make myForm2->Label1 visible.

    Here is some Code of Form2

    //---------------------------------------------------------------------------
    void __fastcall TForm2::Image1MouseDown(TObject *Sender,
    TMouseButton Button, TShiftState Shift, int X, int Y)
    {
    Label1->Visible = true;
    }
    //---------------------------------------------------------------------------

    void __fastcall TForm2::FormCreate(TObject *Sender)
    {
    myForm2Ok = true;
    Label1->Visible = false;
    }

    //---------------------------------------------------------------------------
    void __fastcall TForm2::FormDestroy(TObject *Sender)
    {
    myForm2Ok = false;
    }


    And there some Code of Form1

    //---------------------------------------------------------------------------
    void __fastcall TForm1::ApplicationEvents1Message(tagMSG &Msg,
    bool &Handled)
    {

    static unsigned int oldwparam;
    static long oldlparam;

    Handled = false;

    switch (Msg.message)
    {
    case WM_LBUTTONDOWN:
    if (myForm2Ok)
    {
    if ( ( oldwparam != Msg.wParam ) || ( oldlparam != Msg.lParam ))
    myForm2->Label1->Visible = false;
    break;
    }
    case WM_LBUTTONUP:

    if (myForm2Ok)
    {
    break;
    }

    default:

    }
    oldwparam = Msg.wParam;
    oldlparam = Msg.lParam;

    }

    It works !
    When you click on myForm2->Image1, it shows myForm2->Label1
    When you click ANYWHERE ELSE in the application (any other control of the application, including other controls of myForm2) it hides myForm2->Label1

    Notice, i did'nt modify the Handled flag, not to block local control event handling methods...

    :0)

    Hope it helps

  • stephdev1965stephdev1965 Posts: 6Member
    Hi, all

    the Msg (tagMSG) parameter has a hwnd property

    you can find which control fired the event using

    FindControl(Msg.hwnd) and casting it to access its properties (name, ...)

    Hope it helps


Sign In or Register to comment.