FUNCTION OnMouseHover( hWnd, cFormName )

Topic Specific Tutorials and Tips.

Moderator: Rathinagiri

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

Re: FUNCTION OnMouseHover( hWnd, cFormName )

Post by koke »

Hola Andy
Estoy tratando de utilizar el código, pero cuando inserto un grid deja de funcionar
tienes alguna idea de porque está sucediendo esto???
o será algún error en mi código?? Solo hice copia y pega (sin cambios)
no estoy tratando de cambiar nada en el grid con este código solo los labels..
saludos


-------------------------------------------------------------------------------
with google translate

Hello Andy
I am trying to use the code, but when I insert a grid it stops working
do you have any idea why this is happening ???
or will it be some error in my code? I just did copy and paste (no changes)
I am not trying to change anything in the grid with this code only the labels ..
Cheers
,___,
[O.o]
/)__)
-”–”-
KoKe
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: FUNCTION OnMouseHover( hWnd, cFormName )

Post by andyglezl »

koke wrote: Sat Sep 04, 2021 4:36 am Hola Andy
Estoy tratando de utilizar el código, pero cuando inserto un grid deja de funcionar
tienes alguna idea de porque está sucediendo esto???
o será algún error en mi código?? Solo hice copia y pega (sin cambios)
no estoy tratando de cambiar nada en el grid con este código solo los labels..
saludos


-------------------------------------------------------------------------------
with google translate

Hello Andy
I am trying to use the code, but when I insert a grid it stops working
do you have any idea why this is happening ???
or will it be some error in my code? I just did copy and paste (no changes)
I am not trying to change anything in the grid with this code only the labels ..
Cheers

:roll: :roll:
Que tal Koke
Así como está la función, solo funciona con controles "LABEL".
Porque no posteas el código para ver que pudiera ser ?
*-----------------------------------------------------------------------------
:roll: :roll:
How about koke
As is the function, it only works with "LABEL" controls.
Why don't you post the code to see what it might be?
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
koke
Posts: 116
Joined: Wed Aug 21, 2013 3:54 pm
DBs Used: DBF, mySql, mariaDB

Re: FUNCTION OnMouseHover( hWnd, cFormName )

Post by koke »

Hola Andy
Solo agregue un grid en el form no modifique nada de la función.

Google translate
Hello Andy
Just add a grid in the form do not modify anything of the function.

Labels.fmg

Code: Select all

* HMG-IDE ANSI Form Designer Generated Code
* (c) Roberto Lopez - http://sites.google.com/site/hmgweb

DEFINE WINDOW TEMPLATE AT 296 , 438 WIDTH 550 HEIGHT 350 VIRTUAL WIDTH Nil VIRTUAL HEIGHT Nil TITLE "" ICON NIL  CURSOR NIL ON INIT Nil ON RELEASE Nil ON INTERACTIVECLOSE Nil ON MOUSECLICK Nil ON MOUSEDRAG Nil ON MOUSEMOVE Nil ON SIZE Nil ON MAXIMIZE Nil ON MINIMIZE Nil ON PAINT Nil BACKCOLOR Nil NOTIFYICON NIL NOTIFYTOOLTIP NIL ON NOTIFYCLICK Nil ON GOTFOCUS Nil ON LOSTFOCUS Nil ON SCROLLUP Nil ON SCROLLDOWN Nil ON SCROLLLEFT Nil ON SCROLLRIGHT Nil ON HSCROLLBOX Nil ON VSCROLLBOX Nil

    DEFINE LABEL Label_1
        ROW    100
        COL    50
        WIDTH  120
        HEIGHT 24
        VALUE "Label_1"
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        HELPID Nil
        VISIBLE .T.
        TRANSPARENT .F.
        ACTION Nil
        AUTOSIZE .F.
        BACKCOLOR NIL
        FONTCOLOR NIL
    END LABEL

    DEFINE LABEL Label_2
        ROW    100
        COL    200
        WIDTH  120
        HEIGHT 24
        VALUE "Label_2"
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        HELPID Nil
        VISIBLE .T.
        TRANSPARENT .F.
        ACTION Nil
        AUTOSIZE .F.
        BACKCOLOR NIL
        FONTCOLOR NIL
    END LABEL

    DEFINE LABEL Label_3
        ROW    100
        COL    350
        WIDTH  120
        HEIGHT 24
        VALUE "Label_3"
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        HELPID Nil
        VISIBLE .T.
        TRANSPARENT .F.
        ACTION Nil
        AUTOSIZE .F.
        BACKCOLOR NIL
        FONTCOLOR NIL
    END LABEL

    DEFINE GRID Grid_1
        ROW    170
        COL    70
        WIDTH  120
        HEIGHT 120
        ITEMS { {""} }
        VALUE Nil
        WIDTHS { 0 }
        HEADERS {''}
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        ONCHANGE Nil
        ONGOTFOCUS Nil
        ONLOSTFOCUS Nil
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        ONDBLCLICK Nil
        ONHEADCLICK Nil
        ONQUERYDATA Nil
        MULTISELECT .F.
        ALLOWEDIT .F.
        VIRTUAL .F.
        DYNAMICBACKCOLOR Nil
        DYNAMICFORECOLOR Nil
        COLUMNWHEN Nil
        COLUMNVALID Nil
        COLUMNCONTROLS Nil
        SHOWHEADERS .T.
        CELLNAVIGATION .F.
        NOLINES .F.
        HELPID Nil
        IMAGE Nil
        JUSTIFY Nil
        ITEMCOUNT Nil
        BACKCOLOR Nil
        FONTCOLOR Nil
        HEADERIMAGES Nil
        ROWSOURCE Nil
        COLUMNFIELDS Nil
        ALLOWAPPEND .F.
        ALLOWDELETE .F.
        BUFFERED .F.
        DYNAMICDISPLAY Nil
        ONSAVE Nil
        LOCKCOLUMNS Nil
    END GRID

	CREATE EVENT PROCNAME OnMouseHover( EventWPARAM(), "Labels" ) HWND Labels.Handle

END WINDOW
Main.fmg

Code: Select all

* HMG-IDE ANSI Form Designer Generated Code
* (c) Roberto Lopez - http://sites.google.com/site/hmgweb

DEFINE WINDOW TEMPLATE AT 168 , 343 WIDTH 666 HEIGHT 458 VIRTUAL WIDTH Nil VIRTUAL HEIGHT Nil TITLE "" ICON NIL MAIN CURSOR NIL ON INIT Nil ON RELEASE Nil ON INTERACTIVECLOSE Nil ON MOUSECLICK Nil ON MOUSEDRAG Nil ON MOUSEMOVE Nil ON SIZE Nil ON MAXIMIZE Nil ON MINIMIZE Nil ON PAINT Nil BACKCOLOR Nil NOTIFYICON NIL NOTIFYTOOLTIP NIL ON NOTIFYCLICK Nil ON GOTFOCUS Nil ON LOSTFOCUS Nil ON SCROLLUP Nil ON SCROLLDOWN Nil ON SCROLLLEFT Nil ON SCROLLRIGHT Nil ON HSCROLLBOX Nil ON VSCROLLBOX Nil

    DEFINE LABEL Label_1
        ROW    40
        COL    40
        WIDTH  120
        HEIGHT 50
        VALUE "Label_1"
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        HELPID Nil
        VISIBLE .T.
        TRANSPARENT .F.
        ACTION Nil
        AUTOSIZE .F.
        BACKCOLOR NIL
        FONTCOLOR NIL
    END LABEL

    DEFINE LABEL Label_2
        ROW    110
        COL    40
        WIDTH  120
        HEIGHT 50
        VALUE "Label_2"
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        HELPID Nil
        VISIBLE .T.
        TRANSPARENT .F.
        ACTION Nil
        AUTOSIZE .F.
        BACKCOLOR NIL
        FONTCOLOR NIL
    END LABEL

    DEFINE LABEL Label_3
        ROW    170
        COL    40
        WIDTH  120
        HEIGHT 50
        VALUE "Label_3"
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        HELPID Nil
        VISIBLE .T.
        TRANSPARENT .F.
        ACTION Nil
        AUTOSIZE .F.
        BACKCOLOR NIL
        FONTCOLOR NIL
    END LABEL

    DEFINE LABEL Label_4
        ROW    230
        COL    40
        WIDTH  120
        HEIGHT 50
        VALUE "Label_4"
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        HELPID Nil
        VISIBLE .T.
        TRANSPARENT .F.
        ACTION Nil
        AUTOSIZE .F.
        BACKCOLOR NIL
        FONTCOLOR NIL
    END LABEL

    DEFINE BUTTON Button_1
        ROW    320
        COL    170
        WIDTH  100
        HEIGHT 28
        ACTION main_button_1_action()
        CAPTION "Button_1"
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        ONGOTFOCUS Nil
        ONLOSTFOCUS Nil
        HELPID Nil
        FLAT .F.
        TABSTOP .T.
        VISIBLE .T.
        TRANSPARENT .F.
        MULTILINE .F.
        PICTURE Nil
        PICTALIGNMENT TOP
    END BUTTON
	CREATE EVENT PROCNAME OnMouseHover( EventWPARAM(), "Main" ) HWND Main.Handle
END WINDOW

main.prg

Code: Select all

#include <hmg.ch>

Function Main
public cPrevious1 := "", cPrevious2 := ""
        Load Window Main
        Main.Center
        Main.Activate

Return

FUNCTION OnMouseHover( hWnd, cFormName )	// Funciona para utilizar en varias FORMAS
	LOCAL cControl := "", cForm := ""
	
	GetControlNameByHandle( hWnd, @cControl, @cForm )
	IF EMPTY( cControl ) .OR. GetControlType( cControl, cForm ) <> "LABEL"					// Validar solo Control LABEL
		RETURN
	ENDIF
	SetProperty( cForm, "Title", cFormName + " - " + cControl )								// Para saber donde estoy... Quitar luego
	DO CASE
		CASE cFormName == "Main"
			IF ! EMPTY( cPrevious1 )														// cPrevious1 definido como PRIVATE en MAIN
				IF ! ( cControl == cPrevious1 )
					SetProperty( cFormName, cPrevious1, "BackColor", WHITE )				// El mismo Color como se definió
					SetProperty( cFormName, cPrevious1, "FontColor", BLACK )				// El mismo Color como se definió
				ELSE
					SetProperty( cFormName, cPrevious1, "BackColor", { 173 , 255 , 47 } )
					SetProperty( cFormName, cPrevious1, "FontColor", BLUE )
				ENDIF
			ENDIF
			cPrevious1 := cControl
		CASE cFormName == "Labels"
			IF ! EMPTY( cPrevious2 )														// cPrevious2 definido como PRIVATE en MAIN
				IF ! ( cControl == cPrevious2 )
					SetProperty( cFormName, cPrevious2, "BackColor", { 65 , 105 , 225 } )	// El mismo Color como se definió
					SET CONTROL &cPrevious2 OF &cFormName NOTEDGE	// STATICEDGE
				ELSE
					SetProperty( cFormName, cPrevious2, "BackColor", BLUE )
					SET CONTROL &cPrevious2 OF &cFormName CLIENTEDGE
				ENDIF
			ENDIF
			cPrevious2 := cControl
	ENDCASE
RETURN

Function main_button_1_action
	if !IsWindowDefined("Labels")
		load window Labels
		labels.center
		activate window labels
	endif

Return Nil
,___,
[O.o]
/)__)
-”–”-
KoKe
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: FUNCTION OnMouseHover( hWnd, cFormName )

Post by andyglezl »

koke wrote: Sat Sep 04, 2021 3:37 pm Hola Andy
Solo agregue un grid en el form no modifique nada de la función.

Google translate
Hello Andy
Just add a grid in the form do not modify anything of the function.

No lo he probado, así a simple vista pudiera ser que no funciona con TEMPLATE...
*--------------------------------------------------------------------------------------------------------------------
I have not tested it, so at first glance it could be that it does not work with TEMPLATE ...


DEFINE WINDOW TEMPLATE...
*-----------------------------------------------
DEFINE WINDOW FormMain ...
DEFINE WINDOW Form_Labels...
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: FUNCTION OnMouseHover( hWnd, cFormName )

Post by andyglezl »

andyglezl wrote: Sat Sep 04, 2021 5:55 pm
koke wrote: Sat Sep 04, 2021 3:37 pm Hola Andy
Solo agregue un grid en el form no modifique nada de la función.

Google translate
Hello Andy
Just add a grid in the form do not modify anything of the function.

No lo he probado, así a simple vista pudiera ser que no funciona con TEMPLATE...
*--------------------------------------------------------------------------------------------------------------------
I have not tested it, so at first glance it could be that it does not work with TEMPLATE ...


DEFINE WINDOW TEMPLATE...
*-----------------------------------------------
DEFINE WINDOW FormMain ...
DEFINE WINDOW Form_Labels...

Al parecer, el control GRID siempre mantiene el FOCO hasta que se haga click en otro control
o en otra ventana u oprimiendo la tecla TAB.
El ONLOSTFOCUS del control GRID parece que no funciona...

Si yo oprimo la tecla TAB, el GRID pierde el FOCO y funciona, si lo oprimes tú te funciona ?
*-------------------------------------------------------------------------------------------------------------------
Apparently the GRID control always keeps FOCUS until another control is clicked
or in another window or by pressing the TAB key.
The ONLOSTFOCUS of the GRID control does not seem to work ...

If I press the TAB key, the GRID loses FOCUS and works, if you press it, will it work for you?
imagen_2021-09-06_155353.png
imagen_2021-09-06_155353.png (133.52 KiB) Viewed 2544 times
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: FUNCTION OnMouseHover( hWnd, cFormName )

Post by andyglezl »

Si defines un control TextBox en la ventana Labels funciona correctamente,
si das click en el GRID, deja de funcionar, Oprimes la tecla TAB o das click
en el TextBox y vuelve a funcionar.
*------------------------------------------------------------------------------------------------
If you define a TextBox control in the Labels window it works correctly,
If you click on the GRID, it stops working, Press the TAB key or click
in the TextBox and it works again.

imagen_2021-09-06_162403.png
imagen_2021-09-06_162403.png (53.57 KiB) Viewed 2542 times
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
koke
Posts: 116
Joined: Wed Aug 21, 2013 3:54 pm
DBs Used: DBF, mySql, mariaDB

Re: FUNCTION OnMouseHover( hWnd, cFormName )

Post by koke »

andyglezl wrote: Mon Sep 06, 2021 9:25 pm Si defines un control TextBox en la ventana Labels funciona correctamente,
si das click en el GRID, deja de funcionar, Oprimes la tecla TAB o das click
en el TextBox y vuelve a funcionar.
*------------------------------------------------------------------------------------------------
If you define a TextBox control in the Labels window it works correctly,
If you click on the GRID, it stops working, Press the TAB key or click
in the TextBox and it works again.
Gracias andy lo voy a checar para tratar de implementarlo
Saludos
*----------------------------------------------------------------------------
Thanks andy I'll check it to try to implement it
Greetings
,___,
[O.o]
/)__)
-”–”-
KoKe
User avatar
koke
Posts: 116
Joined: Wed Aug 21, 2013 3:54 pm
DBs Used: DBF, mySql, mariaDB

Re: FUNCTION OnMouseHover( hWnd, cFormName )

Post by koke »

Buenas noches.
Utilice la función para un proyecto en el que estoy trabajando, así que se me ocurrió incorporar la modificación por si a alguien le es de utilidad.
-------------------------------------------------------------------------------------------------------------
Good evening
I use the function for a project I'm working on, so it occurred to me to incorporate the modification in case it would be useful to someone.

https://www.hmgforum.com/viewtopic.php? ... rio#p67271
,___,
[O.o]
/)__)
-”–”-
KoKe
Post Reply