Page 1 of 1

Bug in font management? [Solved]

PostPosted: Wed Jul 09, 2014 5:32 pm
by Enrico Maria Giordano
In the sample below, uncommenting the first PROMPT clause the font is reverted to the default one:

Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg, oFnt

    DEFINE FONT oFnt NAME "Arial" SIZE 0, -9

    DEFINE DIALOG oDlg

    ACTIVATE DIALOG oDlg;
             ON INIT TOOLBAR( oDlg, oFnt );
             CENTER

    RELEASE FONT oFnt

    RETURN NIL


STATIC FUNCTION TOOLBAR( oDlg, oFnt )

    DEFINE BUTTONBAR OF oDlg SIZE 40, 40 2007

    DEFINE BUTTON OF oDlg:oBar;
//           PROMPT "Test"

    DEFINE BUTTON OF oDlg:oBar;
           PROMPT "Test";
           FONT oFnt

    RETURN NIL


EMG

Re: Bug in font management?

PostPosted: Thu Jul 10, 2014 2:22 am
by Antonio Linares
Enrico,

I think it is not a font bug but a TbtnBmp bug. As there is a prompt in the first button, a default font is created, and then on the next button the new used font is not taken into account.

I need to finish the new Class TBtnBmp Method Paint (I am reorganizing it) and it will be much easier to solve it.

Re: Bug in font management?

PostPosted: Thu Jul 10, 2014 4:19 am
by Antonio Linares
Enrico,

Please look for hOldFont in Class TBtnBmp where it is assigned and change it this way:

hOldFont = SelectObject( ::hDC, ::oFont:hFont )

That solves it :-)

Re: Bug in font management?

PostPosted: Thu Jul 10, 2014 7:50 am
by Enrico Maria Giordano
Antonio,

thank you. I will wait for the full btnbmp bugfix.

EMG

Re: Bug in font management?

PostPosted: Thu Jul 10, 2014 9:00 am
by Enrico Maria Giordano
Antonio,

Antonio Linares wrote:Enrico,

Please look for hOldFont in Class TBtnBmp where it is assigned and change it this way:

hOldFont = SelectObject( ::hDC, ::oFont:hFont )

That solves it :-)


I found two occurrences:

Code: Select all  Expand view
hOldFont = SelectObject( ::hDC, If( ::lBarBtn, If( ::oWnd:oFont != nil, ::oWnd:oFont:hFont, ::oFont:hFont ), ::oFont:hFont ) )


and

Code: Select all  Expand view
hOldFont = SelectObject( ::hDC, ::oFont:hFont ) // If( ::lBarBtn, ::oWnd:oWnd:oFont:hFont, ::oFont:hFont ) )


Do I have to change the first as it will look like the second?

Please confirm.

EMG

Re: Bug in font management?

PostPosted: Thu Jul 10, 2014 9:03 am
by Enrico Maria Giordano
I forgot to mention that I'm using the old btnbmp.

EMG

Re: Bug in font management?

PostPosted: Thu Jul 10, 2014 1:27 pm
by Antonio Linares
Enrico,

I have emailed you the most recent version of the Class TBtnBmp, with the new Method Paint(), properly structured :-)

Have you received it ?

Re: Bug in font management?

PostPosted: Thu Jul 10, 2014 1:35 pm
by Enrico Maria Giordano