Object on Form can be move by user
Moderator: Rathinagiri
Object on Form can be move by user
Dear All,
It is possible by user to drag /move object like Text Box, Button etc. on Form
and we can know Screen position of said object
Example please
It is possible by user to drag /move object like Text Box, Button etc. on Form
and we can know Screen position of said object
Example please
BPD
Convert Dream into Reality through HMG
Convert Dream into Reality through HMG
Re: Object on Form can be move by user
Do you think about something like IDE?
I was thinking about it too, but I have no idea.
Maybe Roberto could free the code of IDE? Maybe some piece of code for dragging controls?
I was thinking about it too, but I have no idea.
Maybe Roberto could free the code of IDE? Maybe some piece of code for dragging controls?
- Rathinagiri
- Posts: 5482
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: Object on Form can be move by user
Hi
Consider this small sample. Just 'ActivateDrag' and then select the control to drag. Then just drag the control to wherever you want inside the window and drop.
Consider this small sample. Just 'ActivateDrag' and then select the control to drag. Then just drag the control to wherever you want inside the window and drop.
Code: Select all
#include <hmg.ch>
Function Main
define window sample at 0, 0 width 800 height 600 main on mousedrag mousedragged()
define toolbar tool1
toolbutton c1 caption 'Activate Drag' check .t.
end toolbar
define button b1
row 200
col 100
caption 'Move it!'
action b1action()
end button
define textbox t1
row 200
col 200
end textbox
define statusbar
statusitem ''
statusitem 'Row:'
statusitem 'Col:'
end statusbar
end window
sample.center
sample.activate
Return
function b1action
if sample.c1.value
return nil
endif
msginfo( 'Clicked' )
return nil
function mousedragged
local cCtrlName := _GetFocusedControl ( 'sample' )
sample.statusbar.item( 1 ) := 'Active Control: ' + cCtrlName
sample.StatusBar.Item( 2 ) := "Row : " + LTRIM( STR( _HMG_SYSDATA [ 191 ] )) // Mouse Row
sample.StatusBar.Item( 3 ) := "Col : " + LTRIM( STR( _HMG_SYSDATA [ 192 ] )) // Mouse Col
if sample.c1.value
setproperty( 'sample', cCtrlName, 'ROW', _HMG_SYSDATA [ 191 ] )
setproperty( 'sample', cCtrlName, 'COL', _HMG_SYSDATA [ 192 ] )
endif
return nil
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
Re: Object on Form can be move by user
Dear Rathi,
Excellant, thank you for example
Any improvement in code, on Activate Drag
We select Object, Object will move as per mouse movement
on Right Click it release
Excellant, thank you for example
Any improvement in code, on Activate Drag
We select Object, Object will move as per mouse movement
on Right Click it release
BPD
Convert Dream into Reality through HMG
Convert Dream into Reality through HMG
Re: Object on Form can be move by user
Dear Rathi,
On change from
define window sample at 0, 0 width 800 height 600 main on mousedrag mousedragged()
to
define window sample at 0, 0 width 800 height 600 main on mousemove mousedragged()
Control moves as per mouse movement but how to release mouse / control
pl. guide
On change from
define window sample at 0, 0 width 800 height 600 main on mousedrag mousedragged()
to
define window sample at 0, 0 width 800 height 600 main on mousemove mousedragged()
Control moves as per mouse movement but how to release mouse / control
pl. guide
BPD
Convert Dream into Reality through HMG
Convert Dream into Reality through HMG
- Rathinagiri
- Posts: 5482
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: Object on Form can be move by user
That is the problem. You can make escape key press to release. Use On Key ESCAPE.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
Re: Object on Form can be move by user
There must be some solutionrathinagiri wrote:That is the problem. You can make escape key press to release. Use On Key ESCAPE.
Is there mouse event / click related example ??
BPD
Convert Dream into Reality through HMG
Convert Dream into Reality through HMG
-
Javier Tovar
- Posts: 1275
- Joined: Tue Sep 03, 2013 4:22 am
- Location: Tecámac, México
Re: Object on Form can be move by user
Hola a todos,
Creia yo que estaba inventando la rueda, si la rueda ya esta hecha. Pero se los comparto a ver si a alguien le sirve!
Saludos
P.D.: Solo el control debe de tener el foco!
, después hacer Click en el Form-arrastrar y soltar.
Creia yo que estaba inventando la rueda, si la rueda ya esta hecha. Pero se los comparto a ver si a alguien le sirve!
Code: Select all
#include <hmg.ch>
PROCEDURE DefWindow()
DEFINE WINDOW frmMousDrag;
AT 0, 0 ;
WIDTH 620 HEIGHT 400 ;
TITLE "Mouse drag sample" ;
MAIN ;
ON INIT NIL;
ON MOUSEDRAG MueveControl()
@ 10,200 LABEL Label_1 WIDTH 60 HEIGHT 12 VALUE "Trabajador" ACTION MiNombre(1)
@ 70,20 LABEL Label_2 WIDTH 50 HEIGHT 12 VALUE "Nombre" ACTION MiNombre(2)
@ 90,20 LABEL Label_3 WIDTH 50 HEIGHT 12 VALUE "Activo" ACTION MiNombre(4)
@ 70,200 TEXTBOX TextBox_1 ;
VALUE 'Hi All' ;
TOOLTIP 'Character TextBox' ;
HEIGHT 20 ;
ON GOTFOCUS MiNombre(3) ;
DISABLEDBACKCOLOR { 0,255,0 } ;
DISABLEDFONTCOLOR { 255,255,255 }
DEFINE CHECKBOX CheckBox_1
ROW 90
COL 200
CAPTION ""
VALUE .F.
WIDTH 20
HEIGHT 20
ONGOTFOCUS MiNombre(5)
END CHECKBOX
END WINDOW
RETURN
PROCEDURE MAIN()
PUBLIC cName := ''
PUBLIC nCursRow := 0
PUBLIC nCursCol := 0
DefWindow()
ON KEY ESCAPE OF frmMousDrag ACTION ThisWindow.Release
frmMousDrag.Center
frmMousDrag.Activate
RETURN // Main()
PROCEDURE MueveControl()
nCursRow := GetCursorPos()[ 1 ] - frmMousDrag.Row
nCursCol := GetCursorPos()[ 2 ] - frmMousDrag.Col
frmMousDrag.&(cName).Row := nCursRow
frmMousDrag.&(cName).Col := nCursCol
RETURN NIL
PROCEDURE MiNombre(nControl)
IF nControl = 1
cName := "Label_1"
ELSEIF nControl = 2
cName := "Label_2"
ELSEIF nControl = 3
cName := "TextBox_1"
ELSEIF nControl = 4
cName := "Label_3"
ELSEIF nControl = 5
cName := "CheckBox_1"
ENDIF
RETURN NIL
P.D.: Solo el control debe de tener el foco!
Re: Object on Form can be move by user
Dear Javier Tovar,
Thank you for code
I have created attached sample code that can be compile in minigui
I want same code to compile in HMG
Any help
Thank you for code
I have created attached sample code that can be compile in minigui
I want same code to compile in HMG
Any help
- Attachments
-
- demo.rar
- (537 Bytes) Downloaded 219 times
BPD
Convert Dream into Reality through HMG
Convert Dream into Reality through HMG