window:center() doesn´t work right

AHF
Posts: 837
Joined: Fri Feb 10, 2006 12:14 pm

Post by AHF »

Yes. The first mdichild is centered. How can I use it?
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Do you want to center all of them ?

Please explain a little what you want to do, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
AHF
Posts: 837
Joined: Fri Feb 10, 2006 12:14 pm

Post by AHF »

Antonio,

I need that the ::center() method on mdichilds places them in the center of the main window.

Antonio
AHF
Posts: 837
Joined: Fri Feb 10, 2006 12:14 pm

Post by AHF »

Antonio,

I need that windows are centered in order that all the mdichild is automacticly visible otherwise the user will have to center the window by hand to begin toi work. The Mdichilds can't be maximized or chanhed in size.

Antonio
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Antonio,

We are going to review it again asap. Its on our todo list.
regards, saludos

Antonio Linares
www.fivetechsoft.com
AHF
Posts: 837
Joined: Fri Feb 10, 2006 12:14 pm

Post by AHF »

Antonio,

Thanks,

Antonio
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Antonio,

Have you tried to use this code:

Code: Select all

function BuildChild( oWnd ) 

   local oChild 

   DEFINE WINDOW oChild TITLE "Test" MDICHILD 

   WndTop( oChild:hWnd, 30 )  // change 30 for your own needs
   WndLeft( oChild:hWnd, 30 )  //    "

return nil 
regards, saludos

Antonio Linares
www.fivetechsoft.com
AHF
Posts: 837
Joined: Fri Feb 10, 2006 12:14 pm

Post by AHF »

I´ve re writen the:center method and now works ok!.
Thanks.

Antonio
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Antonio,

> I´ve re writen the:center method and now works ok!.

Excellent! :-)

Will you mind to share the code with us ? thanks!
regards, saludos

Antonio Linares
www.fivetechsoft.com
AHF
Posts: 837
Joined: Fri Feb 10, 2006 12:14 pm

Post by AHF »

Antonio,

Right! Here it is :

METHOD Center() CLASS TDMdiChild //own class redefinition
LOCAL nLargura,nAltura,ntop,nleft
LOCAL nlrgmain,naltmain
LOCAL meioljan, meiolmain,meioajan,meioamain

nlargura := ::nwidth() //dialog width
naltura := ::nheight() //dialog height

nlrgmain := Wmain():owndclient:nwidth() //container width
naltmain := Wmain():owndclient:nheight()//container height

//middle of each dialog and container
meioljan := nlargura /2
meioajan := naltura /2
meiolmain := nlrgmain /2
meioamain := naltmain/2

//coordinates to place the mdichild
ntop := meioamain-meioajan
nleft := meiolmain-meioljan

WndTop( ::hWnd, ntop )
WndLeft( ::hWnd, nleft )
RETURN nil

Antonio
AHF
Posts: 837
Joined: Fri Feb 10, 2006 12:14 pm

Post by AHF »

Again problem.

If I modify the size of the main window the mdichilds opened after are disapering.

That is caused by my modify center() method posted before.

Ntop or Nleft are returning a negative value and when this happens the child window disapears.

Any ideas ?

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

Post by James Bott »

>Ntop or Nleft are returning a negative value and when this happens the child window disapears.

>Any ideas ?

Try using the main window's bResize codeblock to call the center function then maybe the mdichild Move() method (to redisplay it).

James
AHF
Posts: 837
Joined: Fri Feb 10, 2006 12:14 pm

Post by AHF »

James,

It worked.

Thanks

Antonio
Post Reply