mouseover label

HMG en Español

Moderator: Rathinagiri

User avatar
gfilatov
Posts: 545
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Has thanked: 10 times
Been thanked: 116 times
Contact:

Re: mouseover label

Post by gfilatov » Sun Jun 10, 2018 4:50 pm

KDJ wrote:
Sun Jun 10, 2018 4:36 pm
Grigory
...
Why WM_MOUSELEAVE in HMG Extended works and in classic HMG doesn't work?
Krzysztof

IMHO Because HMG Extended uses a Label subclassing on C-level 8-)
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein

KDJ
Posts: 202
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland
Been thanked: 226 times

Post by KDJ » Sun Jun 10, 2018 8:31 pm

Grigory, thank you very much for your explanation.

User avatar
koke
Posts: 46
Joined: Wed Aug 21, 2013 3:54 pm
DBs Used: DBF, mySql, mariaDB
Has thanked: 5 times
Been thanked: 16 times

Post by koke » Mon Jun 11, 2018 3:10 am

Gracias a todos han sido de mucha ayuda.

Google translate

Thank you all, you have been very helpful.
,___,
[O.o]
/)__)
-”–”-
KoKe

KDJ
Posts: 202
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland
Been thanked: 226 times

Post by KDJ » Wed Jun 20, 2018 6:32 pm

gfilatov wrote:
Sun Jun 10, 2018 4:50 pm
KDJ wrote:
Sun Jun 10, 2018 4:36 pm
Grigory
...
Why WM_MOUSELEAVE in HMG Extended works and in classic HMG doesn't work?
Krzysztof

IMHO Because HMG Extended uses a Label subclassing on C-level 8-)

Grigory

I solved this problem.
Before that I completely forgot about the function EventProcessAllHookMessage().
WM_MOUSELEAVE works also in classic HMG:

Code: Select all

#include "hmg.ch"

MEMVAR _HMG_SYSDATA

FUNCTION Main()

  DEFINE WINDOW MainForm;
    WIDTH  300;
    HEIGHT 260;
    TITLE  "Move cursor over labels";
    MAIN

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

    DEFINE LABEL Label2
      ROW       65
      COL       10
      WIDTH     140
      HEIGHT    45
      VALUE     "This is LABEL2"
      ALIGNMENT Center
      FONTCOLOR BLACK
    END LABEL

    DEFINE LABEL Label3
      ROW       120
      COL       10
      WIDTH     140
      HEIGHT    45
      VALUE     "This is LABEL3"
      ALIGNMENT Center
      FONTCOLOR BLACK
    END LABEL

    DEFINE BUTTON CloseButton
      ROW     190
      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.)
  HMG_ChangeWindowStyle(MainForm.Label2.HANDLE, 0x00800200 /*WS_BORDER|SS_CENTERIMAGE*/, NIL, .F., .T.)
  HMG_ChangeWindowStyle(MainForm.Label3.HANDLE, 0x00800200 /*WS_BORDER|SS_CENTERIMAGE*/, NIL, .F., .T.)

  EventProcessAllHookMessage(EventCreate("LabelEventHandler", MainForm.Label1.HANDLE), .T.)
  EventProcessAllHookMessage(EventCreate("LabelEventHandler", MainForm.Label2.HANDLE), .T.)
  EventProcessAllHookMessage(EventCreate("LabelEventHandler", MainForm.Label3.HANDLE), .T.)

  MainForm.CENTER
  MainForm.ACTIVATE

RETURN NIL


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

  SWITCH nMsg
    CASE WM_MOUSEMOVE
      IF ! lTracking
        GetControlNameByHandle(nHWnd, @cControl, @cForm)
        SetProperty(cForm, cControl, "FONTCOLOR", RED)
        SetProperty(cForm, cControl, "FONTBOLD", .T.)
        lTracking := TrackMouseEvent(nHWnd) //TME_LEAVE is default flag
      ENDIF
      EXIT

    CASE WM_MOUSELEAVE
      GetControlNameByHandle(nHWnd, @cControl, @cForm)
      SetProperty(cForm, cControl, "FONTCOLOR", BLACK)
      SetProperty(cForm, cControl, "FONTBOLD", .F.)
      lTracking := .F.
      EXIT
  ENDSWITCH

RETURN NIL


#pragma BEGINDUMP

#include "SET_COMPILE_HMG_UNICODE.ch"
#include "HMG_UNICODE.h"

#include <windows.h>
#include "hbapi.h"

      // https://msdn.microsoft.com/en-us/library/windows/desktop/ms646265(v=vs.85).aspx
      // TrackMouseEvent(nHWnd, [nFlags], [nHoverTime]) --> lSuccess
HB_FUNC( TRACKMOUSEEVENT )
{
  TRACKMOUSEEVENT tmi;

  tmi.cbSize      = sizeof(TRACKMOUSEEVENT);
  tmi.dwFlags     = HB_ISNUM(3) ? (DWORD) hb_parni(2) : TME_LEAVE;
  tmi.hwndTrack   = (HWND) HMG_parnl(1);
  tmi.dwHoverTime = HB_ISNUM(3) ? (DWORD) hb_parni(3) : HOVER_DEFAULT;

  hb_retl(TrackMouseEvent(&tmi));
}

#pragma ENDDUMP

Post Reply