Control under the Mouse

Topic Specific Tutorials and Tips.

Moderator: Rathinagiri

jpp
Posts: 34
Joined: Thu Jan 16, 2014 3:04 pm

Control under the Mouse

Post by jpp »

Hi to all,

if you want to know the control under the mouse pointer ( to select it or change the shape of the pointer ) here if the way to simulate a MOUSE OVER

DEFINE WINDOW w_test

some controls ( label, textbox, etc ... )

END WINDOW

CREATE EVENT PROCNAME TESTMOVE HWND W_test
ACTIVATE WINDOW W_TEST

function testmove()
LOCAL hWnd := EventHWND()
Local nMsg:= EventMsg()
local wParam:= EventWPARAM ()
local cNom, cForm
if nMsg == 32 .and. wParam <> win_1.HANDLE
GetControlNameByHandle(wParam,@cNom, @cForm)
msgbox("Event " + str( nMsg,3,0) + " / " + str(wParam,8,0) + " / " + cNom + " / " + cForm )
endif
return nil

that's all !!!
bye
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Control under the Mouse

Post by Rathinagiri »

That is so nice. :)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: Control under the Mouse

Post by Javier Tovar »

Muy bien amigo!

Saludos
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Control under the Mouse

Post by esgici »

Hi jpp

Welcome aboard :)
jpp wrote:here if the way to simulate a MOUSE OVER
Good sample, thanks to participation :)

Happy HMG'ing :D
Viva INTERNATIONAL HMG :D
jpp
Posts: 34
Joined: Thu Jan 16, 2014 3:04 pm

Re: Control under the Mouse

Post by jpp »

hi and thx for ure messages...

Now if u want to select the control change the proc EVENT to this one :

function selectCtrl()
LOCAL hWnd := EventHWND()
Local nMsg:= EventMsg()
local wParam:= EventWPARAM ()
local cNom,cForm
static ctrlselect:= ""

if wParam <> win_1.HANDLE
if nMsg == 528 .and. !empty(ctrlselect)
msgbox("ctrl selected " + ctrlselect )
else
if nMsg == 32
GetControlNameByHandle(wParam,@cNom, @cForm)
ctrlselect:= upper(cNom)
else
ctrlselect:= ""
endif
endif
endif
return nil

i've tested with label, textbox and button ...

Any feeback welcome
Bye
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: Control under the Mouse

Post by andyglezl »

Hi to all,

if you want to know the control under the mouse pointer ( to select it or change the shape of the pointer ) here if the way to simulate a MOUSE OVER

DEFINE WINDOW w_test

some controls ( label, textbox, etc ... )

END WINDOW

CREATE EVENT PROCNAME TESTMOVE HWND W_test
ACTIVATE WINDOW W_TEST

function testmove()
LOCAL hWnd := EventHWND()
Local nMsg:= EventMsg()
local wParam:= EventWPARAM ()
local cNom, cForm
if nMsg == 32 .and. wParam <> win_1.HANDLE <====== ERROR
GetControlNameByHandle(wParam,@cNom, @cForm)
msgbox("Event " + str( nMsg,3,0) + " / " + str(wParam,8,0) + " / " + cNom + " / " + cForm )
endif
return nil

that's all !!!
bye
---------------------------------------------
Hi jpp, gives error, which is defined Win_1?
Andrés González López
Desde Guadalajara, Jalisco. México.
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: Control under the Mouse

Post by Javier Tovar »

Hola jpp,

Me da error, me dice que no existe la variable "W_test"


DEFINE WINDOW w_test

some controls ( label, textbox, etc ... )

END WINDOW

CREATE EVENT PROCNAME TESTMOVE HWND W_test <===== ERROR
ACTIVATE WINDOW W_TEST

function testmove()
LOCAL hWnd := EventHWND()
Local nMsg:= EventMsg()
local wParam:= EventWPARAM ()
local cNom, cForm
if nMsg == 32 .and. wParam <> win_1.HANDLE
GetControlNameByHandle(wParam,@cNom, @cForm)
msgbox("Event " + str( nMsg,3,0) + " / " + str(wParam,8,0) + " / " + cNom + " / " + cForm )
endif
return nil

Saludos
jpp
Posts: 34
Joined: Thu Jan 16, 2014 3:04 pm

Re: Control under the Mouse

Post by jpp »

Hi,

Sorry for the mistake !
win_1.handle does not exist, it's W_TEST ( the name of the form )

bye
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Control under the Mouse

Post by Pablo César »

jpp wrote:if you want to know the control under the mouse pointer ( to select it or change the shape of the pointer ) here if the way to simulate a MOUSE OVER

Code: Select all

#include <hmg.ch>

Function Main
DEFINE WINDOW w_test AT 222 , 270 WIDTH 550 HEIGHT 350 ;
    TITLE "simulate a MOUSE OVER" ICON NIL MAIN
	
    ON KEY ESCAPE ACTION Thiswindow.Release()

    DEFINE TEXTBOX Text_1
        ROW    40
        COL    80
        WIDTH  120
        HEIGHT 24
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        ONCHANGE Nil
        ONGOTFOCUS Nil
        ONLOSTFOCUS Nil
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        ONENTER Nil
        HELPID Nil
        TABSTOP .T.
        VISIBLE .T.
        READONLY .F.
        RIGHTALIGN .F.
        DISABLEDBACKCOLOR Nil
        DISABLEDFONTCOLOR Nil
        CASECONVERT NONE
        BACKCOLOR Nil
        FONTCOLOR Nil
        INPUTMASK Nil
        FORMAT Nil
        VALUE "Test Box"
    END TEXTBOX

    DEFINE LISTBOX List_1
        ROW    100
        COL    80
        WIDTH  100
        HEIGHT 100
        ITEMS {"Test1","Test2"}
        VALUE 0
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        ONCHANGE Nil
        ONGOTFOCUS Nil
        ONLOSTFOCUS Nil
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        BACKCOLOR Nil
        FONTCOLOR Nil
        ONDBLCLICK Nil
        HELPID Nil
        TABSTOP .T.
        VISIBLE .T.
        SORT .F.
        MULTISELECT .F.
        DRAGITEMS .F.
    END LISTBOX

    DEFINE RADIOGROUP RadioGroup_1
        ROW    100
        COL    300
        WIDTH  120
        HEIGHT 50
        OPTIONS { 'Option 1','Option 2'}
        VALUE 1
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        ONCHANGE Nil
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        HELPID Nil
        TABSTOP .T.
        VISIBLE .T.
        TRANSPARENT .F.
        SPACING 25
        BACKCOLOR Nil
        FONTCOLOR Nil
        READONLY Nil
        HORIZONTAL .F. 
    END RADIOGROUP

END WINDOW
CREATE EVENT PROCNAME TESTMOVE HWND W_test.HANDLE
// CREATE EVENT PROCNAME SELECTCTRL HWND W_test.HANDLE
w_test.Center
w_test.Activate
Return Nil

Function TestMove()
Local hWnd := EventHWND()
Local nMsg:= EventMsg()
Local wParam:= EventWPARAM () 
Local cNom, cForm

if nMsg == 32 .and. wParam <> w_test.HANDLE
   GetControlNameByHandle(wParam,@cNom, @cForm)
   msgbox("Event " + str( nMsg,3,0) + " / " + str(wParam,8,0) + " / " + cNom + " / " + cForm )
endif
Return Nil

Function SelectCtrl()
Local hWnd := EventHWND()
Local nMsg:= EventMsg()
Local wParam:= EventWPARAM () 
Local cNom,cForm
Static ctrlselect:= ""

if wParam <> w_test.HANDLE
   if nMsg == 528 .and. !empty(ctrlselect)
      msgbox("ctrl selected " + ctrlselect )
   else
      if nMsg == 32 
         GetControlNameByHandle(wParam,@cNom, @cForm)
         ctrlselect:= upper(cNom)
      else
         ctrlselect:= ""
      endif
   endif	
endif
Return Nil
Nice sample. Thanks JPP for you sharing with us ! :)
Javier Tovar wrote:Hola jpp,

Me da error, me dice que no existe la variable "W_test"
Hola Javier, prueba con: W_test.HANDLE (ejemplo completo es el que acabé postando)
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: Control under the Mouse

Post by Javier Tovar »

Hola Pablo César,

Fantastico! me quede :o

Un Abrazo :D
Post Reply