Page 1 of 1

controls on dialog init/not init

PostPosted: Wed Jul 01, 2015 8:28 am
by AntoninoP
hello,
I have those 2 samples:
Code: Select all  Expand view
#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  Expand view
#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

Re: controls on dialog init/not init

PostPosted: Wed Jul 01, 2015 10:23 am
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.

Re: controls on dialog init/not init

PostPosted: Wed Jul 01, 2015 12:54 pm
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/library/windows/desktop/ms645475(v=vs.85).aspx

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

Re: controls on dialog init/not init

PostPosted: Wed Jul 01, 2015 2:45 pm
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/library/windows/desktop/ms645475(v=vs.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...

Re: controls on dialog init/not init

PostPosted: Wed Jul 01, 2015 8:02 pm
by Antonio Linares
Antonino,

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