Solved

spurious BN_CLICKED messages

Posted on 1998-06-10
6
383 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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

770 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