Page 1 of 3
Control under the Mouse
Posted: Wed Jan 22, 2014 5:13 pm
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
Re: Control under the Mouse
Posted: Thu Jan 23, 2014 3:00 am
by Rathinagiri
That is so nice.
Re: Control under the Mouse
Posted: Thu Jan 23, 2014 4:29 am
by Javier Tovar
Muy bien amigo!
Saludos
Re: Control under the Mouse
Posted: Thu Jan 23, 2014 10:50 am
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
Re: Control under the Mouse
Posted: Thu Jan 23, 2014 11:04 am
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
Re: Control under the Mouse
Posted: Thu Jan 23, 2014 4:59 pm
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?
Re: Control under the Mouse
Posted: Thu Jan 23, 2014 6:43 pm
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
Re: Control under the Mouse
Posted: Thu Jan 23, 2014 9:28 pm
by jpp
Hi,
Sorry for the mistake !
win_1.handle does not exist, it's W_TEST ( the name of the form )
bye
Control under the Mouse
Posted: Fri Jan 24, 2014 11:14 pm
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 NilNice 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)
Re: Control under the Mouse
Posted: Sat Jan 25, 2014 12:03 am
by Javier Tovar
Hola Pablo César,
Fantastico! me quede
Un Abrazo