Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Button borders not disappearing correctly

Posted on 1998-05-08
4
Medium Priority
?
621 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 11

Expert Comment

by:mikeblas
ID: 1308745
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
ID: 1308746
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 100 total points
ID: 1308747
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
ID: 1308748
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

618 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