ON MOUSEDRAG ?

Moderator: Rathinagiri

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

Re: ON MOUSEDRAG ?

Post by srvet_claudio »

Pablo César wrote:Andrés, tomé tu ejemplo, más lo que yo ya habia postado y más la idea imprecindible del Claudio, surgió este efecto:

Code: Select all

#include "hmg.ch"
#define HTCAPTION          2
#define WM_MOVE            3
#define WM_NCLBUTTONDOWN   161

Function Main
DEFINE WINDOW Form_1 AT 0,0 WIDTH 400 HEIGHT 600 TITLE 'Hello World!' MAIN ;
     ON MOUSECLICK MoveActiveWindow( GetFormHandle('Form_1') ) ;
     ON INIT CreaChild() ;
     ON SIZE (MoveTest(),ChgChild()) ;
     NOMAXIMIZE NOMINIMIZE
   
  ON KEY ESCAPE ACTION ThisWindow.Release
  
  DEFINE STATUSBAR
     STATUSITEM "Click on Form and holding mouse's button for moving this window"
  END STATUSBAR
END WINDOW

CENTER WINDOW Form_1
CREATE EVENT PROCNAME MoveTest() HWND Form_1.HANDLE MSG WM_MOVE
ACTIVATE WINDOW Form_1
Return Nil

Function CreaChild()
Local xPos := Form_1.Col
Local yPos := Form_1.Row
Local nWidth := Form_1.Width

DEFINE WINDOW Form_2 AT yPos,xPos+nWidth WIDTH 300 HEIGHT 200 TITLE 'WinChild' CHILD NOSYSMENU 
    
   ON KEY ESCAPE ACTION ThisWindow.Release
    
   DEFINE STATUSBAR
             STATUSITEM "This window CHILD will be 'anchored' to the MAIN ..."
   END STATUSBAR
 
END WINDOW
ACTIVATE WINDOW Form_2
RETURN Nil

Function MoveActiveWindow( hWnd )
PostMessage( hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0 )
Return Nil

Function MoveTest()
Local xPos := LOWORD(EventlParam())
Local yPos := HIWORD(EventlParam())
Local nWidth := Form_1.Width

Form_1.StatusBar.Item(1):="Lin: "+Str(yPos,4,0)+" / Col: "+Str(xPos,4,0)+" | "+Str(nWidth,4,0)
ChgChild()
Return Nil

Function ChgChild()
Local xPos := Form_1.Col
Local yPos := Form_1.Row
Local nWidth := Form_1.Width

Form_2.Row:=yPos
Form_2.Col:=xPos+nWidth
Return Nil
Fijate si es o que querias.

I mixed up all examples, but the most important is to create the MOVE event that Claudio has indicated.
Very good!!!
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: ON MOUSEDRAG ?

Post by srvet_claudio »

andyglezl wrote: El detalle está en que yo todavia sigo con HMG 3.46 y algunas lineas me dan error.
Voy a ver si lo puedo solucionar. (espero pronto poder dar el paso a 3.1.5 )
Andy, probablemente utilices código de pagina en español, hace en HMG.3.1.5:

Code: Select all

Function Main
SET CODEPAGE TO SPANISH

...

Return
y tu programa escrito en HMG.3.0.46 correrá perfectamente en HMG.3.1.5 en ANSI.

PD: Todos las versiones de HMG.3.1.xx son mixtas, funcionan tanto en ANSI como en UNICODE, basta especificar el código de pagina apropiado (no es necesario volver a compilar la biblioteca de HMG en ANSI).
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: ON MOUSEDRAG ?

Post by Javier Tovar »

Hola a todos, he tretado de compilar los ejemplos y me da un error. HMG.3.0.46
/////////////////////////////////////////////////////////////////////////////////////////////
Hi all, I tretado to compile the examples and gives me an error. HMG.3.0.46

Code: Select all

Harbour 3.2.0dev (Rev. 18443)
Copyright (c) 1999-2012, http://harbour-project.org/

C:\hmg\Mios\DetectaMovWin\Main2.PRG(23) Error E0030  Syntax error "syntax error at 'EVENT'"

1 error
El ejemplo que compile:

Code: Select all

#include "hmg.ch"
#define HTCAPTION          2
#define WM_MOVE            3
#define WM_NCLBUTTONDOWN   161

Function Main
SET CODEPAGE TO SPANISH

DEFINE WINDOW Form_1 AT 0,0 WIDTH 400 HEIGHT 600 TITLE 'Hello World!' MAIN ;
     ON MOUSECLICK MoveActiveWindow( GetFormHandle('Form_1') ) ;
     ON INIT CreaChild() ;
     ON SIZE (MoveTest(),ChgChild()) ;
     NOMAXIMIZE NOMINIMIZE
   
  ON KEY ESCAPE ACTION ThisWindow.Release
  
  DEFINE STATUSBAR
     STATUSITEM "Click on Form and holding mouse's button for moving this window"
  END STATUSBAR
END WINDOW

CENTER WINDOW Form_1
CREATE EVENT PROCNAME MoveTest() HWND Form_1.HANDLE MSG WM_MOVE
ACTIVATE WINDOW Form_1
Return Nil

Function CreaChild()
Local xPos := Form_1.Col
Local yPos := Form_1.Row
Local nWidth := Form_1.Width

DEFINE WINDOW Form_2 AT yPos,xPos+nWidth WIDTH 300 HEIGHT 200 TITLE 'WinChild' CHILD NOSYSMENU 
    
   ON KEY ESCAPE ACTION ThisWindow.Release
    
   DEFINE STATUSBAR
             STATUSITEM "This window CHILD will be 'anchored' to the MAIN ..."
   END STATUSBAR
 
END WINDOW
ACTIVATE WINDOW Form_2
RETURN Nil

Function MoveActiveWindow( hWnd )
PostMessage( hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0 )
Return Nil

Function MoveTest()
Local xPos := LOWORD(EventlParam())
Local yPos := HIWORD(EventlParam())
Local nWidth := Form_1.Width

Form_1.StatusBar.Item(1):="Lin: "+Str(yPos,4,0)+" / Col: "+Str(xPos,4,0)+" | "+Str(nWidth,4,0)
ChgChild()
Return Nil

Function ChgChild()
Local xPos := Form_1.Col
Local yPos := Form_1.Row
Local nWidth := Form_1.Width

Form_2.Row:=yPos
Form_2.Col:=xPos+nWidth
Return Nil
En que estaré mal?, alguna sugerencia por favor. GRACIAS.

////////////////////////////////////////////////////////////////////////////////////////////

In that I'll be bad?, Any suggestions please. Thank you.
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

ON MOUSEDRAG ?

Post by Pablo César »

Hola Javier,

Ese ejemplo que posté es para la version 3.1.5. Es ese tu error, porque estarias utilizando una version donde no reconoce nuevas funciones que fueron implementadas.

Y lo que decia el Dr. Soto, es que se puede utilizar la ultima version con codepage para español.

--

Hi Javier,

That example that I had posted is for version 3.1.5. Is that your mistake because you'd be using a version which does not recognize new features that were implemented.

And what he said Dr. Soto, is that you can use the latest version with codepage for Spanish.
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: ON MOUSEDRAG ?

Post by Javier Tovar »

Gracias Pablo César, voy a instalar la nueva versión.
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: ON MOUSEDRAG ?

Post by andyglezl »

Lo hice, es tan simple !
----------------------
I did, it's so simple!
----------------------

Code: Select all

#include "hmg.ch"

Function Main
	PRIVATE nXY:=0
    DEFINE WINDOW Form_1 AT 0,0 WIDTH 400 HEIGHT 600 TITLE 'Hello World!' MAIN ;
		   ON MOUSECLICK MoveActiveWindow( ) ;
		   ON INIT     ( CreaChild( )  )   

		ON KEY ESCAPE ACTION ThisWindow.Release

		DEFINE TIMER Timer_1 INTERVAL 500 ACTION MoveActiveWindow( )  // cada 1/2 segundos <============
		DEFINE STATUSBAR
			STATUSITEM "Click on Form and holding mouse's button for moving this window"
		END STATUSBAR
    END WINDOW
    
    CENTER WINDOW Form_1
    ACTIVATE WINDOW Form_1
Return Nil

FUNCTION CreaChild()
	Local xPos := Form_1.Col
	Local yPos := Form_1.Row
	Local nWidth := Form_1.Width
	
	DEFINE WINDOW Form_2 AT yPos,xPos+nWidth WIDTH 300 HEIGHT 200 TITLE 'WinChild' CHILD NOSYSMENU NOCAPTION
       
		ON KEY ESCAPE ACTION ThisWindow.Release
       
		DEFINE STATUSBAR
                STATUSITEM "This window CHILD will be 'anchored' to the MAIN ..."
		END STATUSBAR
    
    END WINDOW
    ACTIVATE WINDOW Form_2
RETURN Nil

Function MoveActiveWindow( )
	Local xPos := Form_1.Col
	Local yPos := Form_1.Row
	Local nWidth := Form_1.Width
	IF nXY <> xPos+yPos  <============
		Form_1.StatusBar.Item(1):="Lin: "+Str(yPos,3,0)+" / Col: "+Str(xPos,3,0)
		Form_2.Row:=yPos
		Form_2.Col:=xPos+nWidth
		nXY:=xPos+yPos
	ENDIF                       <============
Return Nil
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Re: ON MOUSEDRAG ?

Post by Pablo César »

Ahhh no vale con Timer... :lol:

With Timer... I thought it already. But try to make in code C in 3.0.46
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: ON MOUSEDRAG ?

Post by esgici »

esgici wrote: ...
I hope attached sample will help you :arrow:
...
Another "Move Window" implementation :
Move Window - 2 ( with dragging method )
Move Window - 2 ( with dragging method )
MoveWin2.JPG (26.56 KiB) Viewed 4926 times
MoveWin2.zip
Source (.prg) file for Move Win-2
(1.02 KiB) Downloaded 281 times
This recalled me Law of the instrument ;)

Happy HMG'ing :D
Viva INTERNATIONAL HMG :D
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Re: ON MOUSEDRAG ?

Post by Pablo César »

srvet_claudio wrote:
Pablo César wrote:Andrés, tomé tu ejemplo, más lo que yo ya habia postado y más la idea imprecindible del Claudio, surgió este efecto:

Code: Select all

#include "hmg.ch"
#define HTCAPTION          2
#define WM_MOVE            3
#define WM_NCLBUTTONDOWN   161

Function Main
DEFINE WINDOW Form_1 AT 0,0 WIDTH 400 HEIGHT 600 TITLE 'Hello World!' MAIN ;
     ON MOUSECLICK MoveActiveWindow( GetFormHandle('Form_1') ) ;
     ON INIT CreaChild() ;
     ON SIZE (MoveTest(),ChgChild()) ;
     NOMAXIMIZE NOMINIMIZE
   
  ON KEY ESCAPE ACTION ThisWindow.Release
  
  DEFINE STATUSBAR
     STATUSITEM "Click on Form and holding mouse's button for moving this window"
  END STATUSBAR
END WINDOW

CENTER WINDOW Form_1
CREATE EVENT PROCNAME MoveTest() HWND Form_1.HANDLE MSG WM_MOVE
ACTIVATE WINDOW Form_1
Return Nil

Function CreaChild()
Local xPos := Form_1.Col
Local yPos := Form_1.Row
Local nWidth := Form_1.Width

DEFINE WINDOW Form_2 AT yPos,xPos+nWidth WIDTH 300 HEIGHT 200 TITLE 'WinChild' CHILD NOSYSMENU 
    
   ON KEY ESCAPE ACTION ThisWindow.Release
    
   DEFINE STATUSBAR
             STATUSITEM "This window CHILD will be 'anchored' to the MAIN ..."
   END STATUSBAR
 
END WINDOW
ACTIVATE WINDOW Form_2
RETURN Nil

Function MoveActiveWindow( hWnd )
PostMessage( hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0 )
Return Nil

Function MoveTest()
Local xPos := LOWORD(EventlParam())
Local yPos := HIWORD(EventlParam())
Local nWidth := Form_1.Width

Form_1.StatusBar.Item(1):="Lin: "+Str(yPos,4,0)+" / Col: "+Str(xPos,4,0)+" | "+Str(nWidth,4,0)
ChgChild()
Return Nil

Function ChgChild()
Local xPos := Form_1.Col
Local yPos := Form_1.Row
Local nWidth := Form_1.Width

Form_2.Row:=yPos
Form_2.Col:=xPos+nWidth
Return Nil
Fijate si es o que querias.

I mixed up all examples, but the most important is to create the MOVE event that Claudio has indicated.
Very good!!!
Thanks, Claudio but all of these we can get with your valious work and all these routines, could be usefull for HMG Events Monitor example or in the future with GUI DEBUG...
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Post Reply