Solved

Button borders not disappearing correctly

Posted on 1998-05-08
4
614 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
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 50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ADO Memory leak with DELPHI 2007 37 171
unable to delete all specified values regedit 38 278
Use of condition with 'serial' in ansible 2 49
Change to event 1 101
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. …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

896 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