mouseover label

HMG en Español

Moderator: Rathinagiri

User avatar
koke
Posts: 116
Joined: Wed Aug 21, 2013 3:54 pm
DBs Used: DBF, mySql, mariaDB

mouseover label

Post by koke »

Buenos días.
¿Alguien a implementado el efecto mouseover para un label?

Vi un post donde se discutió en el 2009

http://hmgforum.com/viewtopic.php?f=5&t ... over#p7043

Pero no funciona bien en 3.4.3 y no pude encontrar ningún otro ejemplo.

Saludos.

traducido por google

Good Morning.
Has anyone implemented the mouseover effect for a label?

I saw a post where it was discussed in 2009

[url] http://hmgforum.com/viewtopic.php?f=5&t ... over#p7043 [/ url]

But it doesn´t work well on 3.4.3 and I could not find any other example.

Greetings.
,___,
[O.o]
/)__)
-”–”-
KoKe
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: mouseover label

Post by mol »

Fee years ago I've posted sample with mouseover effect.
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: mouseover label

Post by andyglezl »

Andrés González López
Desde Guadalajara, Jalisco. México.
KDJ
Posts: 243
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland

Re: mouseover label

Post by KDJ »

Can somebody know why WM_MOUSELEAVE message is not generated for LABEL and another controls?

Example of code:

Code: Select all

#include "hmg.ch"

MEMVAR _HMG_SYSDATA

FUNCTION Main()

  DEFINE WINDOW MainForm;
    WIDTH  300;
    HEIGHT 200;
    MAIN

    DEFINE LABEL Label1
      ROW       10
      COL       10
      WIDTH     140
      HEIGHT    45
      VALUE     "This is LABEL"
      ALIGNMENT Center
    END LABEL

    DEFINE BUTTON CloseButton
      ROW     70
      COL     10
      WIDTH   80
      HEIGHT  23
      CAPTION "Close"
      ACTION  MainForm.RELEASE
    END BUTTON

  END WINDOW

  HMG_ChangeWindowStyle(MainForm.Label1.HANDLE, 0x00800200 /*WS_BORDER|SS_CENTERIMAGE*/, NIL, .F., .T.)
  EventCreate("LabelEventHandler", MainForm.Label1.HANDLE)

  MainForm.CENTER
  MainForm.ACTIVATE

RETURN NIL

FUNCTION LabelEventHandler()
  STATIC lTracking := .F.
  LOCAL  nHWnd := EventHWND()
  LOCAL  nMsg  := EventMSG()

  SWITCH nMsg
    CASE WM_MOUSEMOVE
      IF ! lTracking
        MainForm.Label1.FONTCOLOR := {255, 0, 0}
        MainForm.Label1.FONTBOLD  := .T.
        lTracking := TrackMouseEvent(nHWnd, 0x00000002 /*TME_LEAVE*/)
      ENDIF
      EXIT

    CASE WM_MOUSELEAVE
      MainForm.Label1.FONTCOLOR := {0, 0, 0}
      MainForm.Label1.FONTBOLD  := .F.
      lTracking := .F.
      EXIT
  ENDSWITCH

RETURN NIL

#pragma BEGINDUMP
#include <windows.h>
#include "hbapi.h"
#include "SET_COMPILE_HMG_UNICODE.ch"
#include "HMG_UNICODE.h"

HB_FUNC( TRACKMOUSEEVENT )
{
  TRACKMOUSEEVENT tmi;

  tmi.cbSize      = sizeof(TRACKMOUSEEVENT);
  tmi.dwFlags     = hb_parni(2);
  tmi.hwndTrack   = (HWND) HMG_parnl(1);
  tmi.dwHoverTime = HOVER_DEFAULT;

  hb_retl(TrackMouseEvent(&tmi));
}
#pragma ENDDUMP
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: mouseover label

Post by esgici »

KDJ wrote: Sat Jun 09, 2018 8:09 pm Can somebody know why WM_MOUSELEAVE message is not generated for LABEL and another controls?
...
Thanks, good question
MOUSELEAVE.JPG
MOUSELEAVE.JPG (16.95 KiB) Viewed 5434 times
Viva INTERNATIONAL HMG :D
User avatar
gfilatov
Posts: 1060
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: mouseover label

Post by gfilatov »

KDJ wrote: Sat Jun 09, 2018 8:09 pm Can somebody know why WM_MOUSELEAVE message is not generated for LABEL and another controls?
...
Hi,

Add SS_NOTIFY style to your Label definition :idea:

Hope that helps.
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
KDJ
Posts: 243
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland

Re: mouseover label

Post by KDJ »

Hi, Grigory
MSDN wrote: SS_NOTIFY
Sends the parent window STN_CLICKED, STN_DBLCLK, STN_DISABLE, and STN_ENABLE notification codes when the user clicks or double-clicks the control.
So applying SS_NOTIFY style should not affect the WM_MOUSELEAVE message generation.

In addition, this LABEL already has SS_NOTIFY style:
0x50800301 == WS_CHILD | WS_VISIBLE | WS_BORDER | SS_CENTERIMAGE | SS_NOTIFY | SS_CENTER

There must be some other reason that WM_MOUSELEAVE is not received.
User avatar
gfilatov
Posts: 1060
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: mouseover label

Post by gfilatov »

KDJ wrote: Sun Jun 10, 2018 12:19 pm this LABEL already has SS_NOTIFY style:
...
Hi,

You are right!

Please take a look for an updated sample below:

Code: Select all

#include "hmg.ch"

STATIC lTracking := .F.

FUNCTION Main()

  DEFINE WINDOW MainForm;
    WIDTH  300;
    HEIGHT 200;
    MAIN ;
    ON MOUSEMOVE (MainForm.Label1.FONTCOLOR := {0, 0, 0}, MainForm.Label1.FONTBOLD := .F., lTracking := .F.)

    DEFINE LABEL Label1
      ROW       10
      COL       10
      WIDTH     140
      HEIGHT    45
      VALUE     "This is LABEL"
      ALIGNMENT Center
    END LABEL

    DEFINE BUTTON CloseButton
      ROW     70
      COL     10
      WIDTH   80
      HEIGHT  23
      CAPTION "Close"
      ACTION  MainForm.RELEASE
    END BUTTON

  END WINDOW

  HMG_ChangeWindowStyle(MainForm.Label1.HANDLE, 0x00800200 /*WS_BORDER|SS_CENTERIMAGE*/, NIL, .F., .T.)
  EventCreate("LabelEventHandler", MainForm.Label1.HANDLE)

  MainForm.CENTER
  MainForm.ACTIVATE

RETURN NIL


FUNCTION LabelEventHandler()

  LOCAL  nHWnd := EventHWND()
  LOCAL  nMsg  := EventMSG()

  SWITCH nMsg
    CASE WM_MOUSEMOVE
      IF ! lTracking
        MainForm.Label1.FONTCOLOR := {255, 0, 0}
        MainForm.Label1.FONTBOLD  := .T.
        lTracking := TrackMouseEvent(nHWnd, 0x00000002 /*TME_LEAVE*/)
      ENDIF
      EXIT

    CASE WM_MOUSELEAVE
      MainForm.Label1.FONTCOLOR := {0, 0, 0}
      MainForm.Label1.FONTBOLD  := .F.
      lTracking := .F.
      EXIT
  ENDSWITCH

RETURN NIL


#pragma BEGINDUMP

#include <windows.h>
#include "hbapi.h"
#include "SET_COMPILE_HMG_UNICODE.ch"
#include "HMG_UNICODE.h"

HB_FUNC( TRACKMOUSEEVENT )
{
  TRACKMOUSEEVENT tmi;

  tmi.cbSize      = sizeof(TRACKMOUSEEVENT);
  tmi.dwFlags     = hb_parni(2);
  tmi.hwndTrack   = (HWND) HMG_parnl(1);
  tmi.dwHoverTime = HOVER_DEFAULT;

  hb_retl(TrackMouseEvent(&tmi));
}

#pragma ENDDUMP
Just idea. :idea:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: mouseover label

Post by esgici »

gfilatov wrote: Sun Jun 10, 2018 3:42 pm ...
Please take a look for an updated sample below
OK :arrow:

Thanks Grigory and KDJ 8-)

Happy HMG'ing
Viva INTERNATIONAL HMG :D
KDJ
Posts: 243
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland

Re: mouseover label

Post by KDJ »

Grigory

Yes, thank you for the idea.
This can also be done by processing WM_SETCURSOR message in main window event handler (example is here: viewtopic.php?f=9&t=4806&hilit=mouse+andyglez ).
But WM_MOUSELEAVE is still not received.
Why WM_MOUSELEAVE in HMG Extended works and in classic HMG doesn't work?
Post Reply