Strange behavior of TGet

Post Reply
User avatar
Enrico Maria Giordano
Posts: 8777
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 8 times
Contact:

Strange behavior of TGet

Post by Enrico Maria Giordano »

In the following sample the GET is rendered with a couple of [ ]. Any ideas about the reason and a possible solution?

Code: Select all | Expand

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL cVar := PADR( "This is a test", 35 )

    DEFINE DIALOG oDlg;
           SIZE 800, 600

    ACTIVATE DIALOG oDlg;
             ON INIT TEST( oDlg, @cVar );
             CENTER

    RETURN NIL


STATIC FUNCTION TEST( oDlg, cVar )

    @ 1, 1 GET cVar OF oDlg

    @ 3, 1 BUTTON "&Close" OF oDlg;
           ACTION oDlg:End()

    RETURN NIL


EMG
User avatar
anserkk
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India
Has thanked: 4 times

Re: Strange behavior of TGet

Post by anserkk »

EMG,

I think that the height of the GET object is overlapping the border and hence the []
[] will Vanish if you specify the size for the GET :)

Code: Select all | Expand

@ 1, 1 GET cVar OF oDlg SIZE 80,20


Anser
User avatar
Enrico Maria Giordano
Posts: 8777
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 8 times
Contact:

Re: Strange behavior of TGet

Post by Enrico Maria Giordano »

Thank you. One more problem: try to compile the following sample with the manifest file. You will see a strange double border around the GET:

Code: Select all | Expand

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL cVar := PADR( "This is a test", 35 )

    DEFINE DIALOG oDlg;
           SIZE 800, 600

    ACTIVATE DIALOG oDlg;
             ON INIT TEST( oDlg, @cVar );
             CENTER

    RETURN NIL


STATIC FUNCTION TEST( oDlg, cVar )

    @ 1, 1 GET cVar OF oDlg SIZE 80, 20

    @ 3, 1 BUTTON "&Close" OF oDlg;
           ACTION oDlg:End()

    RETURN NIL


EMG
User avatar
anserkk
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India
Has thanked: 4 times

Re: Strange behavior of TGet

Post by anserkk »

Dear EMG

Yes, I could see the problem which you have mentioned. The problem occurs only when you create the controls (GET and BUTTON) via the ON INIT clause.

I was able to eliminate the problem, when I created the "GET" and "BUTTON" controls from the Main() itself

Code: Select all | Expand

FUNCTION MAIN()

 LOCAL oDlg

 LOCAL cVar := PADR( "This is a test", 35 )
   
 MsgInfo(If(IsAppThemed(),"Themed","Not Themed"))

 DEFINE DIALOG oDlg;
        SIZE 800, 600 PIXEL
           
 @ 1, 1 GET cVar OF oDlg SIZE 180, 25

 @ 3, 1 BUTTON "&Close" OF oDlg;
           ACTION oDlg:End()

 ACTIVATE DIALOG oDlg
 //          ON INIT TEST( oDlg, @cVar );
//           CENTER

RETURN NIL


Another problem which I noticed is that the size of the controls (GET and BUTTON) are different, when created from the ON INIT clause and from Main(). If I create the controls from the Main(), the controls are bigger in size. :roll:

Regards
Anser
User avatar
Antonio Linares
Site Admin
Posts: 42752
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 110 times
Been thanked: 108 times
Contact:

Re: Strange behavior of TGet

Post by Antonio Linares »

Anser,

When the controls are created from inside DEFINE DIALOG ... ACTIVATE DIALOG, Windows API uses dialog units:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms645475(v=vs.85).aspx

When the controls are created from the ON INIT clause, the dialog already exists and Windows uses pixels.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 42752
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 110 times
Been thanked: 108 times
Contact:

Re: Strange behavior of TGet

Post by Antonio Linares »

Enrico,

It seems as Windows API is not properly applying the themes when the control is created from the ON INIT clause.

You can disable the themes on a specific control calling SetWindowTheme(), i.e.:

Code: Select all | Expand

STATIC FUNCTION TEST( oDlg, cVar )

    @ 1, 1 GET cVar OF oDlg SIZE 80, 25

    SetWindowTheme( oDlg:aControls[ 1 ]:hWnd, AnsiToWide( "" ), AnsiToWide( "" ) )
   
    @ 3, 1 BUTTON "&Close" OF oDlg ;
           ACTION oDlg:End() SIZE 80, 25

    RETURN NIL


Please notice that we have modified FWH SetWindowTheme() so when just one parameter is used, then we automatically supply L"" to second and third parameters. AnsitoWide( "" ) is equivalent to L"" (in C code). FWH 12.04 automatically supplies L"" when just one parameter is used, so the above code would be equivalent to: SetWindowTheme( oDlg:aControls[ 1 ]:hWnd )

function SetWindowTheme() docs:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb759827(v=vs.85).aspx
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
anserkk
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India
Has thanked: 4 times

Re: Strange behavior of TGet

Post by anserkk »

Antonio Linares wrote:When the controls are created from inside DEFINE DIALOG ... ACTIVATE DIALOG, Windows API uses dialog units:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms645475(v=vs.85).aspx
When the controls are created from the ON INIT clause, the dialog already exists and Windows uses pixels.


Thank you for the info.

With SetWindowTheme() it is working fine.

Regards
Anser
User avatar
Enrico Maria Giordano
Posts: 8777
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 8 times
Contact:

Re: Strange behavior of TGet

Post by Enrico Maria Giordano »

Antonio Linares wrote:Enrico,

It seems as Windows API is not properly applying the themes when the control is created from the ON INIT clause.

You can disable the themes on a specific control calling SetWindowTheme(), i.e.:


Ok, but now I don't get the theme on that control and the result is ugly. :-(

EMG
User avatar
Antonio Linares
Site Admin
Posts: 42752
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 110 times
Been thanked: 108 times
Contact:

Re: Strange behavior of TGet

Post by Antonio Linares »

Enrico,

Yes, I agree. I have not found a way yet to "reset" the theme or another way to fix that strange theme effect :-(
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 8777
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 8 times
Contact:

Re: Strange behavior of TGet

Post by Enrico Maria Giordano »

Ok, no problem. I will avoid to create controls inside the ON INIT clause.

EMG
User avatar
Antonio Linares
Site Admin
Posts: 42752
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 110 times
Been thanked: 108 times
Contact:

Re: Strange behavior of TGet

Post by Antonio Linares »

Enrico,

Afaik, other controls created from the ON INIT clause are fine.

This is the first time that we get this border painting problem, only when a GET is created and themes are in use.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Horizon
Posts: 1329
Joined: Fri May 23, 2008 1:33 pm
Has thanked: 7 times
Been thanked: 1 time

Re: Strange behavior of TGet

Post by Horizon »

Hi,

Has there any solution for this?

Thanks
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
User avatar
Antonio Linares
Site Admin
Posts: 42752
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 110 times
Been thanked: 108 times
Contact:

Re: Strange behavior of TGet

Post by Antonio Linares »

Hakan,

Not yet. The only solution by now is to create the GETs not from the ON INIT clause of the dialog.

In example, you could create them from:
oDlg:bStart = { || CreateGets() }
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply