controls on dialog init/not init

Post Reply
AntoninoP
Posts: 347
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy
Contact:

controls on dialog init/not init

Post by AntoninoP »

hello,
I have those 2 samples:

Code: Select all

#include "FiveWin.ch"

//----------------------------------------------------------------------------//

function Main()

   local oDlg, cFirst := "Hello", cLast := "World"

   DEFINE DIALOG oDlg SIZE 500, 250
   
   @ 1, 1 GET cFirst OF oDlg SIZE 80, 10
   
   @ 2, 1 GET cLast OF oDlg SIZE 80, 10

   @ 5, 11 BUTTON "Ok" ACTION MsgInfo( cFirst + ", " + cLast )

   @ 5, 21 BUTTON "Cancel" ACTION oDlg:End()

   ACTIVATE DIALOG oDlg CENTERED

return nil
that produce:Image

Code: Select all

#include "FiveWin.ch"

//----------------------------------------------------------------------------//

function Main()

   local oDlg

   DEFINE DIALOG oDlg SIZE 500, 250
      ACTIVATE DIALOG oDlg CENTERED ON INIT init(oDlg)

return nil

PROC init(oDlg)

   local  cFirst := "Hello", cLast := "World"
   @ 1, 1 GET cFirst OF oDlg SIZE 80, 10
   
   @ 2, 1 GET cLast OF oDlg SIZE 80, 10

   @ 5, 11 BUTTON "Ok" ACTION MsgInfo( cFirst + ", " + cLast )

   @ 5, 21 BUTTON "Cancel" ACTION oDlg:End()

return
that produce:Image

I usually use the second code.
I tried for 5 minutes to find why, but I was not able to found it.

Regards,
Antonino
Carlos Mora
Posts: 988
Joined: Thu Nov 24, 2005 3:01 pm
Location: Madrid, España

Re: controls on dialog init/not init

Post by Carlos Mora »

Hi Antonino,

may be the difference is related to the font setup that in turns affects the dialog's coordinates system. It is easy to try: just change dialog font and you'll see how dialog changes it's size. Just try that in a Resource Editor like PellesC, it will be obvious.

Probably setting a font in the DEFINE DIALOG will solve the problem.
Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
“If you think education is expensive, try ignorance"
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: controls on dialog init/not init

Post by Antonio Linares »

Antonino,

When a dialogbox is going to be created it uses "units" (including the created controls):

https://msdn.microsoft.com/en-us/librar ... s.85).aspx

Once it is created (ON INIT) the controls use pixels.
regards, saludos

Antonio Linares
www.fivetechsoft.com
AntoninoP
Posts: 347
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy
Contact:

Re: controls on dialog init/not init

Post by AntoninoP »

Antonio Linares wrote:Antonino,

When a dialogbox is going to be created it uses "units" (including the created controls):

https://msdn.microsoft.com/en-us/librar ... s.85).aspx

Once it is created (ON INIT) the controls use pixels.
It always looks as a bug...

The really strange thing is the style of TGet, in the first case they have the clientEdge, in the second case they look with square brackets...
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: controls on dialog init/not init

Post by Antonio Linares »

Antonino,

Try to increase the height of the GETs and surely they will look fine
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply