Solved

CButton question

Posted on 2002-05-18
8
266 Views
Last Modified: 2013-11-20
Is there any way to avoid the surrounding line which appears on a button when it gets the focus? (the button may be an ownwerdrawn button).

Code would help for solution.

Thank.
0
Comment
Question by:Iraklis
8 Comments
 
LVL 4

Expert Comment

by:mblat
ID: 7020137
IF button is ownerdrawn button then you are in full control of it's appearance.  So don't draw focus rectangle.

Basically WM_DRAWITEM receives DRAWITEMSTRUCT as a parameter.  

It has itemState member var, that can be inspected to find out if item is in focus and draw focus rectangle.  If you won't do that no rectangle will be drawn.

goto to www.codeguru.com they have many, many examples of owner drawn buttons....

hope it helps...
0
 
LVL 3

Expert Comment

by:Crius
ID: 7021667
You can save your button images as resources, and then use CBitmapButton::LoadBitmaps(), which allows you to tell the application what you want the face to look like very easily.

CBitmapButton works like a button, but you can load the 4 different images into the button with LoadBitmaps().

BOOL LoadBitmaps( LPCTSTR lpszBitmapResource,  //The button looks
 LPCTSTR lpszBitmapResourceSel = NULL,  //When it is selected
 LPCTSTR lpszBitmapResourceFocus = NULL,  //When it has focus **You want this to be the same as lpszBitmapResourceSel I believe
 LPCTSTR lpszBitmapResourceDisabled = NULL  //When it is disabled
);

0
 

Expert Comment

by:amarzee
ID: 7023671

Regular messages like WS_SETFOCUS will reach directly to controls like CButton.CButton::SetFocus has implemetation for focus rectangle.If you can override this you may not get input focus rectangle.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

 
LVL 3

Accepted Solution

by:
Crius earned 38 total points
ID: 7024247
The problem with that though is the button wouldn't actually get focus if you overrode WM_SETFOCUS. Without the button getting focus, the button will react differently than expected. For instance, you couldn't ever use the button with only the keyboard.
0
 

Author Comment

by:Iraklis
ID: 7045090
Ok. I'll split up the points.
0
 
LVL 6

Expert Comment

by:Mindphaser
ID: 7045223
Iraklis

I reduced the points, please accept Crius comment as an answer.

armaze and mblat, there will be a separate question with points for your help.

** Mindphaser - Community Support Moderator **
0
 

Expert Comment

by:amarzee
ID: 8794764
hi Iraklis ,
I think you partially agreed with my answer.
0
 
LVL 3

Expert Comment

by:Crius
ID: 8798244
Mindphaser created a separate question with points for your help Amarzee.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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
Folder Comparison 12 54
scoreUp challenge 14 64
How to convert MFC::CString to UTF8 wchar_t* 10 288
Making an alias 7 101
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 (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

828 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