Control under the Mouse

Topic Specific Tutorials and Tips.

Moderator: Rathinagiri

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 »

Eres un mago :D
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: Control under the Mouse

Post by srvet_claudio »

My two cents:

Code: Select all

#define WM_SETCURSOR     32
#define WM_PARENTNOTIFY  528
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
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 DR. Claudio Soto
srvet_claudio wrote:Re: Control under the Mouse
My two cents:



Code:
#define WM_SETCURSOR     32
#define WM_PARENTNOTIFY  528
No se como utilizar sus "Dos centavos", alguna idea?, Como se manejan o ...

Saludos
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: Control under the Mouse

Post by srvet_claudio »

Hola Javier,
son los nombres de los mensajes de Windows interceptados por la rutina, es solo por cuestión de claridad.

Code: Select all

#define WM_SETCURSOR     32
#define WM_PARENTNOTIFY  528


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

if nMsg == WM_SETCURSOR .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 == WM_PARENTNOTIFY .and. !empty(ctrlselect)
      msgbox("ctrl selected " + ctrlselect )
   else
      if nMsg == WM_SETCURSOR
         GetControlNameByHandle(wParam,@cNom, @cForm)
         ctrlselect:= HMG_UPPER (cNom)
      else
         ctrlselect:= ""
      endif
   endif   
endif
Return Nil
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
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 Dr. Claudio Soto,

Gracias por aclarar, vi un poco Microsoft sobre #define WM_SETCURSOR 32 y #define WM_PARENTNOTIFY 528 y todo sobre las API's y es un mundo de información.

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

Re: Control under the Mouse

Post by jpp »

hi,
first thanks for ure answers.

A the begining my purpose was to write an ide to save time for designing forms.
( thats why i wanted to know the control's name under the mouse ).
After a cup of day, i realised that foxpro had a good ide ...
As all the form and it's controls are stored into an scx/sct file ( a simple dbf/ftp file ) which is very simple to read with dbu ( rdd dbf/cdx ).
now, it's very simple to convert ur's prg form design to foxpro properties ( as they are quite similar ) and after the foxpro designer, back to hmg prg !
For the moment i've written the first stage ( hmg->foxpro ) and it's very successfull !!!

I will post something when i'll finish the next stage ...

Jpp
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: Control under the Mouse

Post by srvet_claudio »

jpp wrote:hi,
first thanks for ure answers.

A the begining my purpose was to write an ide to save time for designing forms.
( thats why i wanted to know the control's name under the mouse ).
After a cup of day, i realised that foxpro had a good ide ...
As all the form and it's controls are stored into an scx/sct file ( a simple dbf/ftp file ) which is very simple to read with dbu ( rdd dbf/cdx ).
now, it's very simple to convert ur's prg form design to foxpro properties ( as they are quite similar ) and after the foxpro designer, back to hmg prg !
For the moment i've written the first stage ( hmg->foxpro ) and it's very successfull !!!

I will post something when i'll finish the next stage ...

Jpp
Wow very nice!!!
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
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 »

Hola

Aqui les dejo una variante del ejemplo de jpp y Pablo Cesar.
-----------------------------------------------------------------------
Hello

Here 'example of a variant of jpp and Pablo Cesar.

Code: Select all

#include <hmg.ch>
#define BLUE1 { 218,229,243 }
#define BLUE2 { 000,120,187 }
STATIC cCtrlAnt:="",  lProp:=.F.

Function Main

	DEFINE WINDOW w_test AT 000 , 000 WIDTH 230 HEIGHT 380 BACKCOLOR BLUE1 TITLE "SIMULATE A MOUSE OVER --- BY AGL" MAIN 
   
		ON KEY ESCAPE ACTION Thiswindow.Release()
    
		@ 030,010 LABEL LB_1 VALUE "Opcion 1" OF w_test WIDTH 200 HEIGHT 20 FONT 'Verdana' SIZE 9 FONTCOLOR WHITE BACKCOLOR BLUE2 CENTERALIGN ACTION MsgInfo( "Opcion 1" )
		@ 055,010 LABEL LB_2 VALUE "Opcion 2" OF w_test WIDTH 200 HEIGHT 20 FONT 'Verdana' SIZE 9 FONTCOLOR WHITE BACKCOLOR BLUE2 CENTERALIGN ACTION MsgInfo( "Opcion 2" ) 
		@ 080,010 LABEL LB_3 VALUE "Opcion 3" OF w_test WIDTH 200 HEIGHT 20 FONT 'Verdana' SIZE 9 FONTCOLOR WHITE BACKCOLOR BLUE2 CENTERALIGN ACTION MsgInfo( "Opcion 3" )
		@ 105,010 LABEL LB_4 VALUE "Opcion 4" OF w_test WIDTH 200 HEIGHT 20 FONT 'Verdana' SIZE 9 FONTCOLOR WHITE BACKCOLOR BLUE2 CENTERALIGN ACTION MsgInfo( "Opcion 4" )
		@ 130,010 LABEL LB_5 VALUE "Opcion 5" OF w_test WIDTH 200 HEIGHT 20 FONT 'Verdana' SIZE 9 FONTCOLOR WHITE BACKCOLOR BLUE2 CENTERALIGN ACTION MsgInfo( "Opcion 5" )
		@ 155,010 LABEL LB_6 VALUE "Opcion 6" OF w_test WIDTH 200 HEIGHT 20 FONT 'Verdana' SIZE 9 FONTCOLOR WHITE BACKCOLOR BLUE2 CENTERALIGN ACTION MsgInfo( "Opcion 6" )

		@ 250,000 LABEL LB_7 VALUE ""  WIDTH 200 HEIGHT 20 FONT 'Verdana' SIZE 9 FONTCOLOR BLACK  CENTERALIGN TRANSPARENT 

	END WINDOW
	CREATE EVENT PROCNAME SELECTCTRL( EventWPARAM() )  // HWND W_test.HANDLE
	CENTER   WINDOW w_test
	ACTIVATE WINDOW w_test
RETURN Nil

FUNCTION SelectCtrl( wParam )
	LOCAL cCtrl, cForm, cTemp

	GetControlNameByHandle( wParam, @cCtrl, @cForm )
	cTemp:=ALLTRIM( cForm )+ALLTRIM( cCtrl )
	w_test.LB_7.VALUE := cTemp   // **** Display cForn, cCtrl
	IF cTemp==cForm
		IF lProp
			// La intencion es hacer que la Funcion acepte cualquier nombre de Ventana, pero de esta forma no se ejecuta el ACTION del LABEL !
			// The intention is to make the function accepts any window name, but this way the ACTION of LABEL is not running!
			*SETPROPERTY( cForm, cCtrlAnt, "FONTBOLD" , .F. )
			*SETPROPERTY( cForm, cCtrlAnt, "FONTSIZE" , 9   )
			*SETPROPERTY( cForm, cCtrlAnt, "BACKCOLOR", BLUE2 )
			w_test.&cCtrlAnt..FONTBOLD  := .F.
			w_test.&cCtrlAnt..FONTSIZE  := 9
			w_test.&cCtrlAnt..BACKCOLOR := BLUE2
			lProp:=.F.
		ENDIF
	ELSE
		IF ! empty(cCtrl)
			IF ! lProp
				w_test.&cCtrl..FONTBOLD  := .T.
				w_test.&cCtrl..FONTSIZE  := 12
				w_test.&cCtrl..BACKCOLOR := BLUE
				cCtrlAnt:=cCtrl
				lProp:=.T.
			ENDIF
		ENDIF
	ENDIF
RETURN Nil
Attachments
OnMouseOver.jpg
OnMouseOver.jpg (46.12 KiB) Viewed 3949 times
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: Control under the Mouse

Post by srvet_claudio »

Muy buen ejemplo Andrés!!!
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
danielmaximiliano
Posts: 2612
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: Control under the Mouse

Post by danielmaximiliano »

Espectacular Andres, gracias por compartir.
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
Post Reply