Botschaftsbehandlungsroutinen für OnMouseOver & OnMouseOut

// *.h:

protected:

    void __fastcall OnMouseOver(TMessage & Msg);
    void __fastcall OnMouseOut(TMessage & Msg);

    BEGIN_MESSAGE_MAP

        VCL_MESSAGE_HANDLER(CM_MOUSEENTER , TMessage, OnMouseOver)
        VCL_MESSAGE_HANDLER(CM_MOUSELEAVE , TMessage, OnMouseOut)

    END_MESSAGE_MAP(TForm)

// *.cpp:

void __fastcall TForm1::OnMouseOver(TMessage & Msg)
{
    if (((TLabel *)Msg.LParam) == myLabel)
    {
        myLabel->Caption = "Mouse Over";
    }
}

void __fastcall TForm1::OnMouseOut(TMessage & Msg)
{
    if ( ((TLabel *)Msg.LParam) == myLabel)
    {
        myLabel->Caption = "Mouse Out";
    }
}

Schreibe einen Kommentar