Solved

Button borders not disappearing correctly

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
function returning CString in a regular win32 DLL 8 201
repeateFront java challenge 31 95
Strange date stored 22 175
method notes when mouse over in eclipse 5 90
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

726 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