Solved

spurious BN_CLICKED messages

Posted on 1998-06-10
6
380 Views
Last Modified: 2013-12-03
My application has a window which has several controls in it.  When I click on one of the buttons, I get two WM_COMMAND messages of type BN_CLICKED in response, one for press and one for release.  I return from the WindowProc call with a 0 to signify that the message was handled.  If I click on any of the other controls, I get the same message for the first control before I get one for the second control.  Are there any reasons this type of message could be triggered by anything other than a click on the right button?
0
Comment
Question by:pschwamb
6 Comments
 
LVL 2

Expert Comment

by:WDB
ID: 1407492
Are you possibly setting capture to the button and forgetting to release it on the first button up message?
0
 
LVL 1

Expert Comment

by:Arkadiy
ID: 1407493
BN_CLICKED is undistinguishable from WM_COMMAND created by, say, menu item. Are you posting/sending WM_COMMMAD messages to yourself?

0
 

Author Comment

by:pschwamb
ID: 1407494
Ok, I figured out that it's a problem with focus events. When I click on the button, a message gets sent to another program which pops up an error window (which takes focus away from the button) and sends a message back to the first program telling it to clear the button.  As soon as the first program's window is clicked on (anywhere) again, the button gets another focus event and another BN_CLICKED message, which triggers the error message again (yuck!).  My question should really be: what is a good way around this?
0
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.

 
LVL 3

Accepted Solution

by:
tma050898 earned 100 total points
ID: 1407495
Is the message sent or posted? If it's sent, you can set a local static flag before the SendMessage. Then while your function is blocked on the SendMessage call, your function is reentered and the static flag can be checked. If the flag is on, you don't do anything. After the SendMessage returns, turn the flag back off.

Tom

0
 

Author Comment

by:pschwamb
ID: 1407496
The solution I came up with was to ignore every BN_CLICKED message after a focus event.
0
 
LVL 3

Expert Comment

by:tma050898
ID: 1407497
pschwamb,

I have no problem being graded poorly if I give out a poor effort and/or answer. However, why did you grade me with a 'D' when I took my time to help you? If I didn't answer your question, the proper way to have handled it would have been to reject my answer; NOT insult and embarass me with a 'D'!!!

Tom

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

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

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

15 Experts available now in Live!

Get 1:1 Help Now