FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Strange behavior of TGet
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Strange behavior of TGet
Posted: Sat Apr 21, 2012 09:58 AM
In the following sample the GET is rendered with a couple of [ ]. Any ideas about the reason and a possible solution?

Code (fw): Select all Collapse
#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
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Strange behavior of TGet
Posted: 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 (fw): Select all Collapse
 @ 1, 1 GET cVar OF oDlg SIZE 80,20


Anser
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Strange behavior of TGet
Posted: 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 (fw): Select all Collapse
#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
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Strange behavior of TGet
Posted: Mon Apr 23, 2012 04: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 (fw): Select all Collapse
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. :-)

Regards
Anser
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Strange behavior of TGet
Posted: Mon Apr 23, 2012 06: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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Strange behavior of TGet
Posted: Mon Apr 23, 2012 06: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 (fw): Select all Collapse
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
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Strange behavior of TGet
Posted: Mon Apr 23, 2012 06: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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Strange behavior of TGet
Posted: Mon Apr 23, 2012 08: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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Strange behavior of TGet
Posted: 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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Strange behavior of TGet
Posted: Mon Apr 23, 2012 01:00 PM

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

EMG

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Strange behavior of TGet
Posted: Mon Apr 23, 2012 01: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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Strange behavior of TGet
Posted: Mon Apr 23, 2012 01:24 PM

Ok, thank you for the tip.

EMG

Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: Strange behavior of TGet
Posted: Mon Apr 15, 2013 09:10 AM

Hi,

Has there any solution for this?

Thanks

Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Strange behavior of TGet
Posted: 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

Continue the discussion