Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Two questions about CExtButton Collapse All
Subject Author Date
Gevork Odabashyan Dec 6, 2005 - 12:41 PM

Hi


I create simple Prof-UIS SDI application (VS7.1). All settings are by default.
Add a CExtButton to the resizable dialog.


Question 1.
In the button’s settings set horizontal alignment = center. Button’s text is drown with left alingment.


Question 2.
I set an ahchor on this button:
 m_wndDockedResizableDialog.AddAnchor(
  IDC_BUTTON_TEST,
  __RDA_KEEP,
  __RDA_BOTH
  );
Then start to resize dialog’s control bar. When the width of the button become less then it’s text’s length, the right symbols are clipping (filling with the button’s surface color).



Is this a bug?


Thanks

Technical Support Dec 7, 2005 - 9:39 AM

Here are the answers to your questions.

#1 Thank you for the bug report. The problem was with detecting the button alignment. To detect whether the center alignment, we checked the BS_CENTER style, but in fact this style is a bit mask for the BS_LEFT and BS_RIGHT styles, so the alignment was always center when either the left/right alignment was applied. Here is the update for the CExtButton::PreSubclassWindow() method:

void CExtButton::PreSubclassWindow() 
{
    CButton::PreSubclassWindow();
 
DWORD dwWndStyle = GetStyle();
DWORD dwWndType = dwWndStyle&0x0F;
    m_nButtonType = INT(dwWndType);
    SetButtonStyle( BS_OWNERDRAW );
    
bool bAlignLeft = (dwWndStyle&BS_LEFT) != 0 ? true : false;
bool bAlignRight = (dwWndStyle&BS_RIGHT) != 0 ? true : false;
 
INT nAlignHorz = CExtPaintManager::__ALIGN_HORIZ_CENTER;
    if( bAlignLeft && bAlignRight )
        nAlignHorz = CExtPaintManager::__ALIGN_HORIZ_CENTER;
    else if( bAlignLeft )
        nAlignHorz = CExtPaintManager::__ALIGN_HORIZ_LEFT;
    else if( bAlignRight )
        nAlignHorz = CExtPaintManager::__ALIGN_HORIZ_RIGHT;
    else if( SupportsCommand() || (dwWndStyle&BS_PUSHLIKE) != 0 )
        nAlignHorz = CExtPaintManager::__ALIGN_HORIZ_CENTER;
    
bool bAlignTop = (dwWndStyle&BS_TOP) != 0 ? true : false;
bool bAlignBottom = (dwWndStyle&BS_BOTTOM) != 0 ? true : false;
 
INT nAlignVert = CExtPaintManager::__ALIGN_VERT_CENTER;
    if( bAlignTop && bAlignBottom )
        nAlignVert = CExtPaintManager::__ALIGN_VERT_CENTER;
    else if( bAlignTop )
        nAlignVert = CExtPaintManager::__ALIGN_VERT_TOP;
    else if( bAlignBottom )
        nAlignVert = CExtPaintManager::__ALIGN_VERT_BOTTOM;
    else if( SupportsCommand() || (dwWndStyle&BS_PUSHLIKE) != 0 )
        nAlignVert = CExtPaintManager::__ALIGN_VERT_CENTER;
    
    m_nAlign = (nAlignHorz | nAlignVert);
 
    m_nCheck = GetCheck();
 
bool bEnabled = OnQueryWindowEnabledState();
    PostMessage( // delayed repainting
        WM_ENABLE,
        (WPARAM) bEnabled ? TRUE : FALSE
        );
}

#2 We cannot say that this is a bug, but we agree that the text painting can be improved. Please open the CExtPaintManager::PaintPushButton() and CExtPaintManagerXP::PaintPushButton() methods. Find the following code snippet:
   CRect rcCenteredCaption( rectCaption );
   rcCenteredCaption.OffsetRect(
    ( ( _ppbd.m_nDrawTextFlagsH & DT_CENTER ) != 0 )
     ? ( ( rectCaption.Width() - rcText.Width() ) / 2 )
     : 0
     ,
    ( ( _ppbd.m_nDrawTextFlagsH & DT_VCENTER ) != 0 )
     ? ( ( rectCaption.Height() - rcText.Height() ) / 2 )
     : 0
    );
and replace it with the following one:
   CRect rcCenteredCaption( rectCaption );
   if( rcText.Width() < rectCaption.Width() )
    rcCenteredCaption.OffsetRect(
     ( ( _ppbd.m_nDrawTextFlagsH & DT_CENTER ) != 0 )
      ? ( ( rectCaption.Width() - rcText.Width() ) / 2 )
      : 0,
     0
     );
   if( rcText.Height() < rectCaption.Height() )
    rcCenteredCaption.OffsetRect(
     0,
     ( ( _ppbd.m_nDrawTextFlagsH & DT_VCENTER ) != 0 )
      ? ( ( rectCaption.Height() - rcText.Height() ) / 2 )
      : 0
     );

Gevork Odabashyan Dec 15, 2005 - 9:35 AM

Thanks, all works fine