Solved

Button borders not disappearing correctly

Posted on 1998-05-08
4
613 Views
Last Modified: 2013-11-20
I have placed two CButtons on a CStatic dynamically (i.e. I call CButton()->Create( CStatic as parent );

The buttons display fine, but when tabbing around them (changing focus), the default (black) border does not disappear.  It looks as though all the buttons on the window are the default and this is not the case (actually none of them are).

I have found a workaround, but still not sure why this works and if it is a good workaround.  If I override the CButton::OnKillFocus() and call SetButtonStyle(BS_PUSHBUTTON); (before the CWnd::OnKillFocus()), everything works fine.

Why? and is this a fix?
0
Comment
Question by:tdietz
  • 2
4 Comments
 
LVL 11

Expert Comment

by:mikeblas
Comment Utility
Are you sure the buttons aren't being given the default button style? Have you checked with Spy++?  Are you responding to WM_GETDLGCODE?

Windows doesn't slap the style on randomly selected buttons.

.B ekiM

0
 

Author Comment

by:tdietz
Comment Utility
I don't think they are being given the default style.  I am not doing it.  The buttons are the children of a CStatic and not a CDialog.  Does a CDialog implement extra functionality to remove the dark border when focus changes?

0
 
LVL 1

Accepted Solution

by:
speedup earned 50 total points
Comment Utility
First you should check its style. Are you sure it's DEFAULT button?
Secondly, do you use owner draw function?


0
 

Author Comment

by:tdietz
Comment Utility
I guess I am not making it completely clear, so do this simple test:

Create a dialog with a group box on it.
From the Dialog's OnInitDialog, create several pushbuttons (by hand):

m_button1.Create(...., groupBoxHwnd);
m_button2.Create(...., groupBoxHwnd);

make sure you make the groupBox the button's parent.
Do not set any default buttons for any button on the screen (get rid of the OK & CANCEL buttons generated for you already).

When the dialog opens, you will see your buttons and the groupbox, now set focus to one of the buttons and move to the other.  You will notice that the button's border (for the one you were tabbing off of) does not change, it still shows as bold (the focus rect has moved to the second button, but the bold border is on both).

This is a real easy test and can be reproduced under MSVC 5.0 (sp3).

0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now