[SOLVED] How to move a dialog to a relative position?

[SOLVED] How to move a dialog to a relative position?

Postby sambomb » Fri Jun 07, 2013 7:32 pm

I want to change the position of one dialog 130 pixels up, same left position, height, width.

I tried oDlg:Move( oDlg:nTop - 130, oDlg:nLeft, oDlg:nWidth, oDlg:nHeight ) but the dialog don't move properly.

The main problem here is that oDlg:nTop and oDlg:nLeft aren't filled with the absolute position.

I tried oWndTop( oDlg:hWnd, oWndTop( oDlg:hWnd ) - 130 ) and the same error happened.

Just to clarify, the Wnd/Dialog sequence is:
oWnd
oDlg
MsgMeter -> this is the dialog that I want to move
Another MsgMeter
Last edited by sambomb on Mon Jun 10, 2013 11:39 am, edited 2 times in total.
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: How to move a dialog to a relative position?

Postby cnavarro » Fri Jun 07, 2013 7:37 pm

Have you tried

oDlg: Move (oDlg: nTop - 130, oDlg: nLeft) or

oDlg: Move (oDlg: nTop - 130, oDlg: nLeft, oDlg: Nright, oDlg: nBottom)

regards
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: How to move a dialog to a relative position?

Postby sambomb » Fri Jun 07, 2013 7:44 pm

cnavarro wrote:Have you tried

oDlg: Move (oDlg: nTop - 130, oDlg: nLeft) or

oDlg: Move (oDlg: nTop - 130, oDlg: nLeft, oDlg: Nright, oDlg: nBottom)

regards


sambomb wrote:I tried oDlg:Move( oDlg:nTop - 130, oDlg:nLeft, oDlg:nWidth, oDlg:nHeight ) but the dialog don't move properly.


As I told before, the oDlgMove doesn't work properly
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: How to move a dialog to a relative position?

Postby Enrico Maria Giordano » Fri Jun 07, 2013 9:46 pm

Samir,

sambomb wrote:I want to change the position of one dialog 130 pixels up, same left position, height, width.

I tried oDlg:Move( oDlg:nTop - 130, oDlg:nLeft, oDlg:nWidth, oDlg:nHeight ) but the dialog don't move properly.


Can I see a reduced and self-contained sample of the problem, please?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: How to move a dialog to a relative position?

Postby Jeff Barnes » Sat Jun 08, 2013 12:23 am

I use this to move a dialog in my app:

DEFINE DIALOG......

ACTIVATE DIALOG oDlg NOWAIT ON INIT oDlg:Move( WndMain():nTop+110, WndMain():nLeft+760 )
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: How to move a dialog to a relative position?

Postby ukoenig » Sat Jun 08, 2013 2:17 pm

Jeff,

I created a nice test.
Maybe it will help.
1. a dialog on the right-hand-side, designed as a buttonbar
on window-resize it keeps the position
2. Another dialog to add
testing window resize and MOVE-function

Download
http://www.pflegeplus.com/fw_downloads/move1.zip

Image

Image

Image
Last edited by ukoenig on Sat Jun 08, 2013 3:18 pm, edited 1 time in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: How to move a dialog to a relative position?

Postby James Bott » Sat Jun 08, 2013 2:50 pm

Samir,

Dialogs don't use the same measurement units as windows (see a discussion of this on my website in the article "Introduction to Fivewin.")

The easy solution would be to just move it where you want it to be manually, then read the new dialog coordinates. Otherwise you need to translate the dialog coordinates to windows, then subtract the desired values, then translate them back to dialog units.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: How to move a dialog to a relative position?

Postby ukoenig » Sat Jun 08, 2013 3:19 pm

James,
testing with the tool, windows TOP/LEFT and dialog TOP/LEFT

Image

Best Regards
Uwe :?:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: [SOLVED] How to move a dialog to a relative position?

Postby sambomb » Mon Jun 10, 2013 12:11 pm

Thanks for everybody that reply.
Since both dialog's have the same size and are centered, I solved with this:

Code: Select all  Expand view

   poDlg:Move( Round( ((GetSysMetrics(1)-poDlg:nHeight)/2),0)-poDlg:nHeight,;
               Round( ((GetSysMetrics(0)-poDlg:nWidth) /2),0) )
 


Enrico Maria Giordano wrote:Samir,

sambomb wrote:I want to change the position of one dialog 130 pixels up, same left position, height, width.

I tried oDlg:Move( oDlg:nTop - 130, oDlg:nLeft, oDlg:nWidth, oDlg:nHeight ) but the dialog don't move properly.


Can I see a reduced and self-contained sample of the problem, please?

EMG


Enrico, this is what I want to do:
I need to call 2 MsgMeter in sequence, so I want to move the first one to stay above the second:
Code: Select all  Expand view
+-----------------------------------+
|       First Meter bar             |
+-----------------------------------+
+-----------------------------------+
|       Second Meter bar            | <- Centered in the monitor
+-----------------------------------+

Code: Select all  Expand view

****************************************************************************
static procedure Test2Meter()
****************************************************************************
Local bAction := {| oMeter, oText, oDlg, lEnd | Execute1Step(oDlg) }

   MsgMeter(bAction,"First Step","Test dialog movement")

Return Nil

/*------------------------------------------------------------------------*/

****************************************************************************
static procedure Execute1Step(poDlg)
****************************************************************************
Local bAction := {| oMeter, oText, oDlg, lEnd | Execute2Step(oDlg) }

   SysWait(1)

   oDlg:Move(oDlg:nTop -oDlg:nHeight , oDlg:nLeft)

   SysWait(1)
   
   MsgMeter(bAction,"Second Step","Test dialog movement second")
   
Return Nil

/*------------------------------------------------------------------------*/

****************************************************************************
static procedure Execute2Step(poDlg)

   SysWait(10)

Return Nil

/*------------------------------------------------------------------------*/


Jeff Barnes wrote:I use this to move a dialog in my app:

DEFINE DIALOG......

ACTIVATE DIALOG oDlg NOWAIT ON INIT oDlg:Move( WndMain():nTop+110, WndMain():nLeft+760 )

Jeff, I cant move to a position relative to the main window because my clients have different resolutions and I use a centered window.

James Bott wrote:Samir,

Dialogs don't use the same measurement units as windows (see a discussion of this on my website in the article "Introduction to Fivewin.")

The easy solution would be to just move it where you want it to be manually, then read the new dialog coordinates. Otherwise you need to translate the dialog coordinates to windows, then subtract the desired values, then translate them back to dialog units.

Regards,
James

James, I think I ain't using the windows measurement since I use only dialogs(TWindow) properties oDlg:Move( oDlg:nTop - oDlg:nHeight, oDlg:nLeft )
I can't just move and take coordinates because I have clients with a lot of different resolutions and the coordinates will change to each client.
How to translate coordinates?


ukoenig wrote:Jeff,

I created a nice test.
Maybe it will help.
1. a dialog on the right-hand-side, designed as a buttonbar
on window-resize it keeps the position
2. Another dialog to add
testing window resize and MOVE-function

Download
http://www.pflegeplus.com/fw_downloads/move1.zip

Image

Image

Image


I'll test soon.
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: [SOLVED] How to move a dialog to a relative position?

Postby Enrico Maria Giordano » Mon Jun 10, 2013 12:16 pm

Samir,

sambomb wrote:Enrico, this is what I want to do:


Sorry, I need a sample that I can compile and run here.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 119 guests