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.
Subject |
Author |
Date |
|
Suhai Gyorgy
|
Dec 8, 2006 - 9:12 AM
|
Dear Support, I’ve experienced 2 strange things with your CExtRadioButton class, which is different in pure MFC. - When the radiobutton has no text, it’s radio-circle is drawn in the top left corner of the given location, not vertically centered, as in MFC. - In MFC I had a group of radio buttons and all of them had the WS_TABSTOP style. When tabbing through all the controls in the program, the focus stopped only on the group’s selected radiobutton, none of the others, and user could change selection of group by pressing up-down arrows on the keyboard. When adapting the same in Prof-UIS, and then tabbing through controls, focus stops on every single radiobutton, not only on the selected one. Are these behaviours on purpose? Could I change them somehow? Thank you, Chris.
|
|
Technical Support
|
Dec 11, 2006 - 10:41 AM
|
Thank you for reporting the problem with aligning the check box. To fix it, please update the CExtPaintManager::PaintCheckOrRadioButtonText() method: void CExtPaintManager::PaintCheckOrRadioButtonText(
CDC & dc,
CExtPaintManager::PAINTCHECKRADIOBUTTONDATA & _pcrbd,
CSize _sizeBox,
CRect & rcBoxLocation
)
{
ASSERT_VALID( this );
ASSERT( dc.GetSafeHdc() != NULL );
if( _pcrbd.m_rcClient.IsRectEmpty() )
return;
if( !_pcrbd.m_bEnabled )
{
_pcrbd.m_bHover = false;
_pcrbd.m_bDrawFocusRect = false;
}
CRect rcTextArea( _pcrbd.m_rcClient );
CRect rcTextLocation( 0, 0, 0, 0);
rcBoxLocation.SetRect(
_pcrbd.m_rcClient.left,
_pcrbd.m_rcClient.top,
_pcrbd.m_rcClient.left + _sizeBox.cx,
_pcrbd.m_rcClient.top + _sizeBox.cy
);
if( (_pcrbd.m_eAlign&__ALIGN_VERT_MASK) == __ALIGN_VERT_BOTTOM )
rcBoxLocation.OffsetRect(
0,
( _pcrbd.m_rcClient.bottom - _sizeBox.cy ) - 2
);
else if( (_pcrbd.m_eAlign&__ALIGN_VERT_MASK) == __ALIGN_VERT_CENTER )
rcBoxLocation.OffsetRect(
0,
( _pcrbd.m_rcClient.Height() - rcBoxLocation.Height() ) / 2
);
else
rcBoxLocation.OffsetRect( 0, 1 );
// pre-calculate box coordinates
if( _pcrbd.m_bLeftText )
{
rcBoxLocation.OffsetRect(
_pcrbd.m_rcClient.Width() - rcBoxLocation.Width(),
0
);
rcTextArea.right = rcBoxLocation.left - 2;
rcTextArea.left += 1;
} // if( _pcrbd.m_bLeftText )
else
rcTextArea.left = rcBoxLocation.right + 4;
rcTextArea.DeflateRect( 1, 1 );
INT nOldBkMode = dc.SetBkMode( TRANSPARENT );
// draw text
INT nTextLength =
(_pcrbd.m_sText == NULL)
? INT(0)
: INT(_tcslen(_pcrbd.m_sText));
if( nTextLength > 0
&& rcTextArea.bottom > rcTextArea.top
&& rcTextArea.right > rcTextArea.left
)
{
// if have valid area, text & focus rect
ASSERT( _pcrbd.m_sText != NULL );
COLORREF clrText =
QueryObjectTextColor(
dc,
_pcrbd.m_bEnabled,
_pcrbd.m_bDrawFocusRect,
_pcrbd.m_bHover,
_pcrbd.m_bPushed,
_pcrbd.m_pHelperSrc
);
if( clrText == COLORREF(-1L) )
{
if( _pcrbd.m_bEnabled )
{
if( _pcrbd.m_bHover || _pcrbd.m_bPushed )
{
if( _pcrbd.m_bPushed
&& _pcrbd.m_clrForceTextPressed != ((COLORREF)-1L)
)
clrText = _pcrbd.m_clrForceTextPressed;
else if( _pcrbd.m_bHover
&& _pcrbd.m_clrForceTextHover != ((COLORREF)-1L)
)
clrText = _pcrbd.m_clrForceTextHover;
else if( _pcrbd.m_clrForceTextNormal != ((COLORREF)-1L) )
clrText = _pcrbd.m_clrForceTextNormal;
else
clrText = GetColor( COLOR_BTNTEXT, this );
} // if( _pcrbd.m_bHover || _pcrbd.m_bPushed )
else
clrText =
( _pcrbd.m_clrForceTextNormal == ((COLORREF)-1L) )
? GetColor( COLOR_BTNTEXT, this )
: _pcrbd.m_clrForceTextNormal;
} // if( _pcrbd.m_bEnabled )
else
{
clrText =
( _pcrbd.m_clrForceTextDisabled == ((COLORREF)-1L) )
? GetColor( COLOR_3DSHADOW, this )
: _pcrbd.m_clrForceTextDisabled;
} // else from if( _pcrbd.m_bEnabled )
} // if( clrText == COLORREF(-1L) )
COLORREF clrOldText = dc.SetTextColor( clrText );
CFont * pOldBtnFont = NULL;
CFont * pCurrFont = NULL;
if( _pcrbd.m_hFont != NULL )
pCurrFont = CFont::FromHandle( _pcrbd.m_hFont );
else
pCurrFont = &m_FontNormal;
ASSERT( pCurrFont != NULL );
pOldBtnFont = dc.SelectObject( pCurrFont );
UINT nDtMeasureFlags =
DT_LEFT|DT_TOP|DT_CALCRECT;
if( _pcrbd.m_bMultiline )
{
rcTextLocation = rcTextArea;
rcTextLocation.OffsetRect( -rcTextLocation.TopLeft() );
rcTextLocation.bottom = rcTextLocation.top;
nDtMeasureFlags |= DT_WORDBREAK;
}
else
nDtMeasureFlags |= DT_SINGLELINE;
dc.DrawText(
_pcrbd.m_sText,
nTextLength,
rcTextLocation,
nDtMeasureFlags
);
rcTextLocation.OffsetRect(
rcTextArea.TopLeft() - rcTextLocation.TopLeft()
);
UINT nDtDrawFlags = 0;
if( (_pcrbd.m_eAlign&__ALIGN_HORIZ_MASK) == __ALIGN_HORIZ_RIGHT )
{
nDtDrawFlags |= DT_RIGHT;
rcTextLocation.OffsetRect(
rcTextArea.Width() - rcTextLocation.Width(),
0
);
}
else if( (_pcrbd.m_eAlign&__ALIGN_HORIZ_MASK) == __ALIGN_HORIZ_CENTER )
{
nDtDrawFlags |= DT_CENTER;
rcTextLocation.OffsetRect(
( rcTextArea.Width() - rcTextLocation.Width() ) / 2,
0
);
}
else
nDtDrawFlags |= DT_LEFT;
if( (_pcrbd.m_eAlign&__ALIGN_VERT_MASK) == __ALIGN_VERT_BOTTOM )
{
nDtDrawFlags |= DT_BOTTOM;
rcTextLocation.OffsetRect(
0,
rcTextArea.Height() - rcTextLocation.Height()
);
}
else if( (_pcrbd.m_eAlign&__ALIGN_VERT_MASK) == __ALIGN_VERT_TOP )
{
nDtDrawFlags |= DT_TOP;
}
else
{
nDtDrawFlags |= DT_VCENTER;
rcTextLocation.OffsetRect(
0,
( rcTextArea.Height() - rcTextLocation.Height() ) / 2
);
}
if( _pcrbd.m_bMultiline )
nDtDrawFlags |= DT_WORDBREAK;
else
nDtDrawFlags |= DT_SINGLELINE;
dc.DrawText(
_pcrbd.m_sText,
nTextLength,
rcTextLocation,
nDtDrawFlags
);
dc.SelectObject( pOldBtnFont );
dc.SetTextColor( clrOldText );
if( _pcrbd.m_bDrawFocusRect )
{
CRect rcFocus( rcTextLocation );
rcFocus.InflateRect( 2, 2 );
rcFocus.left = max( rcFocus.left, rcTextArea.left );
rcFocus.top = max( rcFocus.top, rcTextArea.top );
rcFocus.right = min( rcFocus.right, rcTextArea.right );
rcFocus.bottom = min( rcFocus.bottom, rcTextArea.bottom );
rcFocus.InflateRect(
_pcrbd.m_bLeftText ? 0 : 1,
0,
_pcrbd.m_bLeftText ? 1 : 0,
0
);
dc.DrawFocusRect( &rcFocus );
} // if( _pcrbd.m_bDrawFocusRect )
} // if have valid area, text & focus rect
dc.SetBkMode( nOldBkMode );
} As for the second problem, we cannot confirm it yet. The Prof-UIS radio button group acts in the same way as the standard radio buttons. If the WS_TABSTOP style is set for all the radio buttons in the group, the focus will stop at every button both with the standard and Prof-UIS radio buttons. We made all the tests using the StatusPanes sample.
|
|
Suhai Gyorgy
|
Dec 11, 2006 - 12:41 PM
|
I made a small sample to reproduce the problem. You can download it from here. To reproduce, start the program, click on MFC Radio1 and Prof Radio1 to select them from their group. At that point focus is on Prof Radio1. Start tabbing through controls. You should see tab stopping on Prof Radio2, but not on MFC Radio2. If later on you select Prof Radio2, they start to behave as expected.
|
|
Technical Support
|
Dec 12, 2006 - 1:07 PM
|
Thank you for the test project. We found the bug and fixed it. You can download the updated source code via FTP.
|
|