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

x
?
Solved

Owner Draw CButton Not Relinquishing Press State

Posted on 2008-06-20
2
Medium Priority
?
842 Views
Last Modified: 2013-11-20
I've created an owner-drawn CButton class to do custom painting including a hover state.  I've added tooltip functionality as well.  Everything works correctly, except if I select the button with the left mouse, then before releasing the left mouse, I move the cursor off the button.  I would expect the button to unselect, similar to standard windows buttons.  When I release the left mouse, the button selects no matter where the cursor is located on the screen (it can even be over a different application).

In my code, I'm checking the LPDRAWITEMSTRUCT object for disabled, selected, and focus states to paint the correct button state.  Additionally, I maintain a m_bHovering bool to tell me when I'm hovering over a button.  All states work correctly, and the button paints exactly how I want it to.

My problem is what I mentioned above, I can't get the button to "disengage" once it has been selected with the mouse.  Once it has received the left mouse down message, that button is going to get selected eventually (once the left button is released), even if I don't want it to.

It doesn't seem like a painting issue to me.  Functionally, I add the BS_OWNERDRAW style in PreCreateWindow().  In OnCreate() I create the tooltip control and create some fonts. I do handle OnKeyDown(), and it sends a message to it's parent. Otherwise, the remainder of the code does tooltip stuff, and painting stuff.

Thanks for any help...
0
Comment
Question by:Voltus_WoW
[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 Comments
 
LVL 49

Accepted Solution

by:
DanRollins earned 1500 total points
ID: 21838665
I suggest using Spy++ to examine the sequence of messages that normally occur (on a standard button) when you click-and-hold then drag off of the button and release.  Then I'd do the same thing for these special buttons, and compare the message logs to see what's different.
0
 

Author Comment

by:Voltus_WoW
ID: 21887846
The answer definitely pointed me in the direction I needed.  I found out that the we overrode the MouseMove event handler but failed to call the base class functionality.
0

Featured Post

Independent Software Vendors: 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!

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…
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.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

636 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