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 » Drawing focus rect to a button with only icon on it Collapse All
Subject Author Date
Suhai Gyorgy Aug 10, 2007 - 6:57 AM

Dear Support,

I have some small buttons (CExtButton) which have only an icon on them, but no text. I want each of them to have focus rect when it is in focus. By default, focus rect is only around the text part of the button, but you have a CExtButton::SetFocusMode method, with which I can change this default behaviour and make the focus rect drawn around the client area of the button. But this still doesn’t allow me to have focus rect for a button without text. I’ve stepped through your code CExtPaintManagerXP::PaintPushButton and I see that the code which would draw the focus rect is inside an if-block with the following condition:

	if(		rectCaption.bottom > rectCaption.top
		&&	rectCaption.right > rectCaption.left
		)
	{ // if we have valid area for text & focus rect
		...
	}
So rectFocus is not checked, and even though I have valid rectFocus in that code, the invalid rectCaption keeps me from getting to the code which would draw the focus rect.

Please check this issue! Thank you!

Technical Support Sep 24, 2007 - 12:19 PM

Unfortunately you cannot do that.

The button is drawn in the CExtPaintManager::PaintPushButton() virtual method and in its overridden versions. Here is the code that draws the focus rectangle:

if(		_ppbd.m_bDrawFocusRect 
	&&	( ( !sTitle.IsEmpty() ) || _ppbd.m_nFocusMode == __EBFM_CLIENT_AREA )
	&&	rcFocus.bottom > rcFocus.top 
	&&	rcFocus.right > rcFocus.left
	)
{
	rcFocus.DeflateRect( 2, 2 );
	dc.DrawFocusRect( &rcFocus );
}


As for the forum, that you for this suggestions. We look into it, may be it will be not difficult to implement it.

Suhai Gyorgy Aug 14, 2007 - 9:17 AM

I can also reproduce this problem in your ProfUIS_Controls sample.

Test #1:
Insert line
    m_btnPushButton.SetFocusMode(CExtPaintManagerXP::__EBFM_CLIENT_AREA);
in CPageButtons::OnInitDialog. Build, run sample, check CheckBox for "Show Focus Rect", press tab couple of times. Result: Focus rect is shown around client area of pushbutton.

Test #2:
Insert line
    m_btnPushButton.SetWindowText(_T(""));
right after the line with SetFocusMode we inserted in Test #1. Build, run sample, check CheckBox for "Show Focus Rect", press tab couple of times. Result: Focus rect is not shown anywhere inside pushbutton.

Please let me know if you encounter the same problem! Thank you.

Technical Support Aug 28, 2007 - 3:33 AM

The bug is fixed. Thank you again. You can download the updated source code from our ftp site.

Suhai Gyorgy Sep 24, 2007 - 4:56 AM

Dear Support,

I haven’t compiled your new source code till now, so I couldn’t confirm the changes earlier. But now I see the fix is there, works nicely, thank you very much!

One more question concerning this issue: Our buttons are very-very small (18x18 pixel), the pictures in them cover almost the entire area of the button. Because of this, the focus rect is drawn over the picture. Is there a way I could change the distance between the button border and the focus rect? Only for these buttons, of course.

Chris

P.S.: Do you have any plans improving your forum in a way that the readers could sort the forum by date of last post? It’d be really great.

Technical Support Aug 17, 2007 - 1:01 PM

Thank you for reporting the problem. The programmer who is responsible for this feature is on vacation and will be back on August 26. He will certainly fix this. Thank you again.