Bug in message bar

Post Reply
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Bug in message bar

Post by Enrico Maria Giordano »

In the following sample, the text "CHECKLIST" is not centered and the item background is not red:

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oWnd

    DEFINE WINDOW oWnd

    SET MESSAGE OF oWnd 2007

    DEFINE MSGITEM OF oWnd:oMsgBar;
           SIZE 70;
           COLOR CLR_BLACK, CLR_HRED;
           PROMPT "CHECKLIST"

    oWnd:oMsgBar:KeybOn()
    oWnd:oMsgBar:DateOn()
    oWnd:oMsgBar:ClockOn()

    ACTIVATE WINDOW oWnd

    RETURN NIL
EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Enrico,

The item background color is not used if 2007 is specified (at least, not yet)

Regarding the center of the text, we are using GetTextWidth() to calculate its position when painting it. But it seems that GetTextWidth() does not work fine or we are doing something wrong...
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Antonio Linares wrote:Enrico,

The item background color is not used if 2007 is specified (at least, not yet)
Ok.
Antonio Linares wrote:Regarding the center of the text, we are using GetTextWidth() to calculate its position when painting it. But it seems that GetTextWidth() does not work fine or we are doing something wrong...
Ok, thank you.

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

Post by Enrico Maria Giordano »

This is a possible fix:

Code: Select all

   if ::oMsgBar:l2007
      ::oMsgBar:Say( ::oMsgBar:nHeight / 4 - 2,;
             nLeft - 1 + ( ::nWidth - GetTextWidth( hDC, AllTrim( ::cMsg ), ::oFont:hFont ) ) / 2,;
             AllTrim( ::cMsg ), If( ::lActive, ::nClrText, ::nClrDisabled ),;
             ::nClrPane, ::oFont, .T., .T. )
      WndBoxIn( hDC, 2, nLeft - 4, ::oMsgBar:nHeight - 2, nLeft - 3 )
   else
EMG
Cgallegoa
Posts: 335
Joined: Sun Oct 16, 2005 3:32 am
Location: Quito - Ecuador
Contact:

Post by Cgallegoa »

Possible fix with BitMap:

if ::oMsgBar:l2007
::oMsgBar:Say( ::oMsgBar:nHeight / 4 - 2,;
nLeft + nBmpWidth - iif(nBmpWidth>0,7,1) + ( ::nWidth - GetTextWidth( hDC, AllTrim( ::cMsg ), ::oFont:hFont ) ) / 2,;
AllTrim( ::cMsg ), If( ::lActive, ::nClrText, ::nClrDisabled ),;
::nClrPane, ::oFont, .T., .T. )

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

WndBoxIn( hDC, 2, nLeft - 4, ::oMsgBar:nHeight - 2, nLeft - 3 )

else


Regards,

Carlos Gallego
Post Reply