Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

spurious BN_CLICKED messages

Posted on 1998-06-10
6
Medium Priority
?
403 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

916 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