Strange behavior of TGet

Strange behavior of TGet

Postby Enrico Maria Giordano » Sat Apr 21, 2012 9:58 am

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 view
#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
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Strange behavior of TGet

Postby anserkk » Sat Apr 21, 2012 10:03 am

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 view
@ 1, 1 GET cVar OF oDlg SIZE 80,20


Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Strange behavior of TGet

Postby Enrico Maria Giordano » Sat Apr 21, 2012 10:08 am

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 view
#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
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Strange behavior of TGet

Postby anserkk » Mon Apr 23, 2012 4:51 am

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 view
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
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Strange behavior of TGet

Postby Antonio Linares » Mon Apr 23, 2012 6:28 am

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: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Strange behavior of TGet

Postby Antonio Linares » Mon Apr 23, 2012 6:50 am

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 view
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
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Strange behavior of TGet

Postby anserkk » Mon Apr 23, 2012 6:55 am

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
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Strange behavior of TGet

Postby Enrico Maria Giordano » Mon Apr 23, 2012 8:16 am

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
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Strange behavior of TGet

Postby Antonio Linares » Mon Apr 23, 2012 11:00 am

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
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Strange behavior of TGet

Postby Enrico Maria Giordano » Mon Apr 23, 2012 1:00 pm

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Strange behavior of TGet

Postby Antonio Linares » Mon Apr 23, 2012 1:22 pm

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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Strange behavior of TGet

Postby Enrico Maria Giordano » Mon Apr 23, 2012 1:24 pm

Ok, thank you for the tip.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Strange behavior of TGet

Postby Horizon » Mon Apr 15, 2013 9:10 am

Hi,

Has there any solution for this?

Thanks
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: Strange behavior of TGet

Postby Antonio Linares » Mon Apr 15, 2013 10:16 am

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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 54 guests