FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Bug in TMsgItem
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Bug in TMsgItem
Posted: Mon Feb 09, 2009 06:51 PM
In the following sample the string CHECKLIST is not centered inside its msgitem:

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oWnd, oFnt

    DEFINE FONT oFnt NAME GETSYSFONT() SIZE 0, -8 BOLD

    DEFINE WINDOW oWnd

    SET MESSAGE OF oWnd;
        TO "This is a status bar";
        TIME DATE NOINSET 2007

    DEFINE MSGITEM OF oWnd:oMsgBar;
           SIZE 80;
           PROMPT "CHECKLIST";
           FONT oFnt

    DEFINE MSGITEM OF oWnd:oMsgBar

    ACTIVATE WINDOW oWnd

    RELEASE FONT oFnt

    RETURN NIL


EMG
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in TMsgItem
Posted: Mon Feb 09, 2009 07:27 PM
A possible fix seems to replace, in TMsgItem Paint() method:

nLeft - 1 + ( ::nWidth / 2 ) - ( GetTextWidth( hDC, AllTrim( ::cMsg ), ::oMsgBar:oFont:hFont ) / 2 ),;


with:

nLeft - 1 + ( ::nWidth / 2 ) - ( GetTextWidth( hDC, AllTrim( ::cMsg ), ::oFont:hFont ) / 2 ),;


EMG
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in TMsgItem
Posted: Mon Feb 09, 2009 09:50 PM
Enrico,

This fix is required in Class TMsgItem:
METHOD Paint() CLASS TMsgItem
   ...
   if ::oMsgBar:l2007
      ::oMsgBar:Say( ::oMsgBar:nHeight / 4 - 2,;
             nLeft - 1 + ( ::nWidth / 2 ) - ( GetTextWidth( hDC, AllTrim( ::cMsg ), If( ::oFont != nil, ::oFont:hFont, ::oMsgBar:oFont:hFont ) ) / 2 ),;  // new !!!
      ...

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in TMsgItem
Posted: Mon Feb 09, 2009 09:53 PM
Ok, but it seems not needed as there is

::oFont   = If( oFont != nil, oFont, ::oMsgBar:oFont )


in method New(), if I'm not wrong.

EMG
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in TMsgItem
Posted: Mon Feb 09, 2009 09:57 PM
Enrico,

Then we can simplify the fix :-)
GetTextWidth( hDC, AllTrim( ::cMsg ), ::oFont:hFont )
regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion