Hi my friends!
How I can change the position ( Top and Left ) of a modal dialog at runtime?
It's possible?
Thanks for all!
Antonio Linares wrote:Julio,
oDlg:nTop = ...
oDlg:nLeft = ...
DEFINE DIALOG oDlg RESOURCE "GRID_SELECTION" OF oDlgP
...
ACTIVATE DIALOG oDlg ON INIT ( oDlg:move( oDlgP:nTop, oDlgP:nLeft,,, .T. ) )
//
//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
Otto wrote:Hello Cesar,
maybe you can try with
oDlg:Move(20,20,700,800,.t.)
Regards,
Otto
- Code: Select all Expand view
//
//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
#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
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
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 99 guests