FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour [SOLVED] How to move a dialog to a relative position?
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
[SOLVED] How to move a dialog to a relative position?
Posted: Fri Jun 07, 2013 07: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

Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: How to move a dialog to a relative position?
Posted: Fri Jun 07, 2013 07: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
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Re: How to move a dialog to a relative position?
Posted: Fri Jun 07, 2013 07: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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: How to move a dialog to a relative position?
Posted: Fri Jun 07, 2013 09: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
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: How to move a dialog to a relative position?
Posted: 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)
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: How to move a dialog to a relative position?
Posted: Sat Jun 08, 2013 02: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





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.
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: How to move a dialog to a relative position?
Posted: Sat Jun 08, 2013 02: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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: How to move a dialog to a relative position?
Posted: Sat Jun 08, 2013 03:19 PM
James,
testing with the tool, windows TOP/LEFT and dialog TOP/LEFT



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.
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Re: [SOLVED] How to move a dialog to a relative position?
Posted: 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 (fw): Select all Collapse
   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 (fw): Select all Collapse
+-----------------------------------+
|       First Meter bar             |
+-----------------------------------+
+-----------------------------------+
|       Second Meter bar            | <- Centered in the monitor
+-----------------------------------+

Code (fw): Select all Collapse
****************************************************************************
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







I'll test soon.
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: [SOLVED] How to move a dialog to a relative position?
Posted: 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

Continue the discussion