Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Getting double BN_CLICKED messages in dlg...

Posted on 1998-01-13
11
Medium Priority
?
535 Views
Last Modified: 2013-12-03
In an application I'm working on I have a group of radio buttons. I elected to handle the messages myself, so I turned the AUTO property of these buttons off.  To handle turning the radio buttons on and off, I handle the BN_CLICKED message.  This seems to work fine, with one exception:  I'm getting 2 BN_CLICKED messages for each time I click on the radio button.  Any suggestions?
0
Comment
Question by:salamander
[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
  • 5
  • 5
11 Comments
 
LVL 32

Expert Comment

by:jhance
ID: 1410036
Yes, one is the button down message and the other is the button up message.
0
 

Author Comment

by:salamander
ID: 1410037
So, how can I tell which is which so I can disregard one of them?
0
 

Author Comment

by:salamander
ID: 1410038
I need an answer, sorry.
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
LVL 5

Expert Comment

by:inter
ID: 1410039
Dear salamander,
As you probably note the BN_CLICKED message carries the following info:

idButton = (int) LOWORD(wParam);    // identifier of button
hwndButton = (HWND) lParam;         // handle of button

so if you know hwndButton for each of you buttons, at the program begining record it your defaults handle as oldButtonHandle. Then when receive BN_CLICKED :
  ignore the message if hwnButton == oldButtonHandle
  and process if hwnButton != oldButtonHandle {
    ... // processing code
    oldButtonHandle := hwnButton
  }

Does it solves your problem! (It may require other steps if you wrote in Delphi or VB)

Please notify,
Sincerely,
Igor
0
 

Author Comment

by:salamander
ID: 1410040
Is BN_CLICKED the only solution for this?  Is it the best solution?  This just seems to be too common a situation to have no standard way of message handling.
0
 
LVL 5

Expert Comment

by:inter
ID: 1410041
Please indicate the compiler you are using, so if I know more (or specific handling)I can help you.
Thanks,
Igor
0
 

Author Comment

by:salamander
ID: 1410042
I'm using Microsoft VC++ 5.  I'm not using MFC, just standard WIN32 API.
0
 
LVL 5

Expert Comment

by:inter
ID: 1410043
Friend,
I am mainly using Delphi 2.0. So, in about 15 minutes I can digup the source code for their library and find out how they can simply do on group of radio buttons and post C pseudo code, it may solve your problem.
If you want to add anything I am here to extend the discussion.
Igor
0
 
LVL 5

Expert Comment

by:inter
ID: 1410044
Wow!
Thats a mess but I try to explain. They provide a base that can handle any windows control. But for our problem, the easiest way can be as follows(here we cannot follow but simulate Borlands way):
1 - The idea is to use the message sending logic of the customcontrol such as radio buttons. The BN_CLICKED message is passes to the owner of the radiobuttons. So first we should create a group box.
2 - Place only radio buttons to this group box and set the id of these group boxes to 0 to N-1
3 - Override WM_COMMAND of group box we have created
4 - If the message is BN_CLICKED use switch to determine the IDs(0 to N-1) and perform the required funtion.

Unfortunately, without using an OOP approach we can not simplify more(as far as I know).

Sincerely,
Igor
0
 

Author Comment

by:salamander
ID: 1410045
This is what I have been doing.  This does not eliminate the double BN_CLICKED messages.  I'll just use your first answer.  Respond back by answering, and I'll give you the points.
0
 
LVL 5

Accepted Solution

by:
inter earned 300 total points
ID: 1410046
Ok Thanks,
If you want to add anything I have still notification check.

Sincerely,
Igor
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

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…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

721 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