Solved

spurious BN_CLICKED messages

Posted on 1998-06-10
6
377 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 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

21 Experts available now in Live!

Get 1:1 Help Now