Page 3 of 3
Re: ON MOUSEDRAG ?
Posted: Wed Sep 11, 2013 12:45 am
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!!!
Re: ON MOUSEDRAG ?
Posted: Wed Sep 11, 2013 12:57 am
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).
Re: ON MOUSEDRAG ?
Posted: Wed Sep 11, 2013 1:27 am
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.
ON MOUSEDRAG ?
Posted: Wed Sep 11, 2013 1:31 am
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.
Re: ON MOUSEDRAG ?
Posted: Wed Sep 11, 2013 1:33 am
by Javier Tovar
Gracias Pablo César, voy a instalar la nueva versión.
Re: ON MOUSEDRAG ?
Posted: Wed Sep 11, 2013 1:40 am
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
Re: ON MOUSEDRAG ?
Posted: Wed Sep 11, 2013 1:45 am
by Pablo César
Ahhh no vale con Timer...
With Timer... I thought it already. But try to make in code C in 3.0.46
Re: ON MOUSEDRAG ?
Posted: Wed Sep 11, 2013 9:43 am
by esgici
esgici wrote:
...
I hope attached sample will help you
...
Another "Move Window" implementation :
- Move Window - 2 ( with dragging method )
- MoveWin2.JPG (26.56 KiB) Viewed 5155 times
- MoveWin2.zip
- Source (.prg) file for Move Win-2
- (1.02 KiB) Downloaded 297 times
This recalled me
Law of the instrument
Happy HMG'ing
Re: ON MOUSEDRAG ?
Posted: Wed Sep 11, 2013 6:18 pm
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...