?
Solved

CButton question

Posted on 2002-05-18
8
Medium Priority
?
271 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Accepted Solution

by:
Crius earned 152 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month15 days, 5 hours left to enroll

840 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