Page 1 of 1
Change position of Modal Dialog?
Posted: Wed Mar 26, 2008 12:03 am
by JC
Hi my friends!
How I can change the position ( Top and Left ) of a modal dialog at runtime?
It's possible?
Thanks for all!
Posted: Wed Mar 26, 2008 7:56 am
by Antonio Linares
Julio,
oDlg:nTop = ...
oDlg:nLeft = ...
Posted: Wed Mar 26, 2008 12:17 pm
by JC
Antonio Linares wrote:Julio,
oDlg:nTop = ...
oDlg:nLeft = ...
First, thanks Antonio...
This is my situation:
Code: Select all
DEFINE DIALOG oDlg RESOURCE "GRID_SELECTION" OF oDlgP
...
ACTIVATE DIALOG oDlg ON INIT ( oDlg:move( oDlgP:nTop, oDlgP:nLeft,,, .T. ) )
But, the method move() put the top and left of the main window, not of the oDlgP. I'm crazy? hehehe
I want this: the dialog oDlg get the bottom and left position of the oDlgP!
Posted: Wed Mar 26, 2008 12:26 pm
by Biel EA6DD
Try with functions WndTop(oDlgp:hWnd) and WndLeft(oDlgp:hWnd)
Posted: Wed Mar 26, 2008 1:18 pm
by JC
Biel EA6DD wrote:Try with functions WndTop(oDlgp:hWnd) and WndLeft(oDlgp:hWnd)
Gabriel.... this not fun!
Posted: Wed Mar 26, 2008 1:38 pm
by Otto
Hello Cesar,
maybe you can try with
oDlg:Move(20,20,700,800,.t.)
Regards,
Otto
Code: Select all
//
//DEFINE DIALOG oDlg RESOURCE "GRID_SELECTION" OF oDlgP
//...
//ACTIVATE DIALOG oDlg ON INIT ( oDlg:move( oDlgP:nTop, oDlgP:nLeft,,, .T. ) )
//EMG
#include "Fivewin.ch"
FUNCTION MAIN()
LOCAL oDlg, oBtn
LOCAL oGet1, oGet2
LOCAL cVar1 := SPACE( 30 )
LOCAL cVar2 := SPACE( 60 )
DEFINE DIALOG oDlg
@ 1, 1 GET oGet1 VAR cVar1
@ 1, 1 GET oGet2 VAR cVar2
@ 3, 1 BUTTON oBtn PROMPT "Scientific";
ACTION CHANGE( oDlg, oBtn, oGet1, oGet2 )
ACTIVATE DIALOG oDlg;
ON INIT oGet2:Hide()
RETURN NIL
STATIC FUNCTION CHANGE( oDlg, oBtn, oGet1, oGet2 )
IF oBtn:GetText() = "Scientific"
oDlg:SetSize( 500, , .T. )
oDlg:Move(200,300,700,800,.t.)
oBtn:SetText( "Standard" )
oGet1:Hide()
oGet2:Show()
ELSE
oDlg:SetSize( 300, , .T. )
oDlg:Move(20,20,700,800,.t.)
oBtn:SetText( "Scientific" )
oGet1:Show()
oGet2:Hide()
ENDIF
RETURN NIL
Posted: Wed Mar 26, 2008 1:50 pm
by JC
Otto wrote:Hello Cesar,
maybe you can try with
oDlg:Move(20,20,700,800,.t.)
Regards,
Otto
Code: Select all
//
//DEFINE DIALOG oDlg RESOURCE "GRID_SELECTION" OF oDlgP
//...
//ACTIVATE DIALOG oDlg ON INIT ( oDlg:move( oDlgP:nTop, oDlgP:nLeft,,, .T. ) )
//EMG
#include "Fivewin.ch"
FUNCTION MAIN()
LOCAL oDlg, oBtn
LOCAL oGet1, oGet2
LOCAL cVar1 := SPACE( 30 )
LOCAL cVar2 := SPACE( 60 )
DEFINE DIALOG oDlg
@ 1, 1 GET oGet1 VAR cVar1
@ 1, 1 GET oGet2 VAR cVar2
@ 3, 1 BUTTON oBtn PROMPT "Scientific";
ACTION CHANGE( oDlg, oBtn, oGet1, oGet2 )
ACTIVATE DIALOG oDlg;
ON INIT oGet2:Hide()
RETURN NIL
STATIC FUNCTION CHANGE( oDlg, oBtn, oGet1, oGet2 )
IF oBtn:GetText() = "Scientific"
oDlg:SetSize( 500, , .T. )
oDlg:Move(200,300,700,800,.t.)
oBtn:SetText( "Standard" )
oGet1:Hide()
oGet2:Show()
ELSE
oDlg:SetSize( 300, , .T. )
oDlg:Move(20,20,700,800,.t.)
oBtn:SetText( "Scientific" )
oGet1:Show()
oGet2:Hide()
ENDIF
RETURN NIL
Yes, I tried! But this is the problem.... is a Dialog opened from another Dialog... the value must be from the first Dialog, but it get a value of top and left from the main window! I'm crazy, that's it!!!
Really, I want one thing: The second dialog must be show exactly on top of first dialog, with top and left!
Posted: Wed Mar 26, 2008 3:40 pm
by Antonio Linares
Julio,
You need to turn absolute coordinates into relative ones.
Please review function ScreenToClient()
Please make a search for ScreenToClient in these forums. There are several examples of its use
Posted: Wed Mar 26, 2008 3:56 pm
by Otto
Cesar,
I think you are right. There is no function opposite to the SetWindowPos = GetWindowPos in FIVEWIN.
oDlg:nTop() returns 0 in my tests
@ 3, 16 BUTTON "Top" SIZE 40, 12 ACTION msginfo(oDlg:nTop())
Maybe you can store the nTop of the first DIALOG in a STATIC and then use this STATIC for the second DIALOG. If you move the first you must change the STATIC VAR too.
Regards,
Otto
Posted: Wed Mar 26, 2008 4:35 pm
by Antonio Linares
As Biel pointed, WndTop( oDlg:hWnd [,nNewTop] ) should work similar to oDlg:nTop
Posted: Wed Mar 26, 2008 5:17 pm
by Otto
Antonio, where do you get nNewTop from?
Regards,
Otto
Posted: Wed Mar 26, 2008 5:33 pm
by Antonio Linares
Otto,
Its a new value for nTop.
oWnd:nTop is equivalent to WndTop( oWnd:hWnd )
and
oWnd:nTop := 5 is equivalent to WndTop( oWnd:hWnd, 5 )
Posted: Wed Mar 26, 2008 5:54 pm
by Otto
Cesar,
maybe this is what you need.
Regards,
Otto
Code: Select all
#include "fivewin.ch"
STATIC nTop, nLeft
STATIC oWnd
function main()
local oWnd
DEFINE WINDOW oWnd TITLE "oWnd1" ;
FROM 5, 5 TO 24, 64
ACTIVATE WINDOW oWnd on Init f_dlg()
return nil
func f_dlg
local oDlg, oIco, cTest := "Hello world! "
local nTop
DEFINE ICON oIco FILE "..\icons\fivewin.ico"
DEFINE DIALOG oDlg TITLE "I am a DialogBox" COLOR "W+/B" ;
ICON oIco of Ownd
@ 1, 3 GET cTest
@ 3, 5 BUTTON "Ok" SIZE 40, 12 ;
ACTION ( xCheck( oDlg ), f_dlg2() ) DEFAULT
ACTIVATE DIALOG oDlg CENTERED ;
VALID MsgYesNo( "Do you want to end ?" )
return nil
function xCheck( oDlg )
local aPoint := { 0, 0 }
aPoint = ClientToScreen( oDlg:hWnd, aPoint )
if aPoint[ 1 ] > 32768
aPoint[ 1 ] -= 65535
endif
if aPoint[ 2 ] > 32768
aPoint[ 2 ] -= 65535
endif
nTop:= aPoint[ 1 ] - 20
nLeft:= aPoint[ 2 ]
//msginfo(STR(nTop) + " " +str(nLeft) )
return nil
func f_dlg2()
local oDlg, oIco, cTest := "Hello world! "
DEFINE DIALOG oDlg TITLE "I am a DialogBox" of oWnd
@ 3, 5 BUTTON "&Ok" SIZE 40, 12 ;
ACTION oDlg:End() DEFAULT
ACTIVATE DIALOG oDlg ON INIT oDlg:Move(nTop,nLeft,,,.t.)
return nil
Posted: Wed Mar 26, 2008 7:14 pm
by JC
Antonio Linares wrote:Julio,
You need to turn absolute coordinates into relative ones.
Please review function ScreenToClient()
Please make a search for ScreenToClient in these forums. There are several examples of its use
Yes Antonio.... with ScreenToClient() , It's work fine!
Otto, thanks too!
Thanks very much! With much strenght!!