Change position of Modal Dialog?

Change position of Modal Dialog?

Postby JC » Wed Mar 26, 2008 12:03 am

Hi my friends!

How I can change the position ( Top and Left ) of a modal dialog at runtime?
It's possible?


Thanks for all!
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby Antonio Linares » Wed Mar 26, 2008 7:56 am

Julio,

oDlg:nTop = ...
oDlg:nLeft = ...
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby JC » Wed Mar 26, 2008 12:17 pm

Antonio Linares wrote:Julio,

oDlg:nTop = ...
oDlg:nLeft = ...



First, thanks Antonio...

This is my situation:

Code: Select all  Expand view  RUN


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!
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby Biel EA6DD » Wed Mar 26, 2008 12:26 pm

Try with functions WndTop(oDlgp:hWnd) and WndLeft(oDlgp:hWnd)
Saludos desde Mallorca
Biel Maimó
http://bielsys.blogspot.com/
User avatar
Biel EA6DD
 
Posts: 682
Joined: Tue Feb 14, 2006 9:48 am
Location: Mallorca

Postby JC » Wed Mar 26, 2008 1:18 pm

Biel EA6DD wrote:Try with functions WndTop(oDlgp:hWnd) and WndLeft(oDlgp:hWnd)


Gabriel.... this not fun! :(
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby Otto » Wed Mar 26, 2008 1:38 pm

Hello Cesar,

maybe you can try with
oDlg:Move(20,20,700,800,.t.)
Regards,
Otto




Code: Select all  Expand view  RUN
          //



//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
User avatar
Otto
 
Posts: 6344
Joined: Fri Oct 07, 2005 7:07 pm

Postby JC » Wed Mar 26, 2008 1:50 pm

Otto wrote:Hello Cesar,

maybe you can try with
oDlg:Move(20,20,700,800,.t.)
Regards,
Otto




Code: Select all  Expand view  RUN
          //



//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!
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby Antonio Linares » Wed Mar 26, 2008 3:40 pm

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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Otto » Wed Mar 26, 2008 3:56 pm

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
User avatar
Otto
 
Posts: 6344
Joined: Fri Oct 07, 2005 7:07 pm

Postby Antonio Linares » Wed Mar 26, 2008 4:35 pm

As Biel pointed, WndTop( oDlg:hWnd [,nNewTop] ) should work similar to oDlg:nTop
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Otto » Wed Mar 26, 2008 5:17 pm

Antonio, where do you get nNewTop from?
Regards,
Otto
User avatar
Otto
 
Posts: 6344
Joined: Fri Oct 07, 2005 7:07 pm

Postby Antonio Linares » Wed Mar 26, 2008 5:33 pm

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 )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Otto » Wed Mar 26, 2008 5:54 pm

Cesar,
maybe this is what you need.

Regards,
Otto
Code: Select all  Expand view  RUN
#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

User avatar
Otto
 
Posts: 6344
Joined: Fri Oct 07, 2005 7:07 pm

Postby JC » Wed Mar 26, 2008 7:14 pm

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!! ;)
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: dutch, wilsongamboa and 80 guests