ON_BN_CLICKED problems

Hello all,

I have an application that throws up a property sheet with 4 
pages (tabs) contained within.  One of the pages (tabs) displays 
a dialog resource that has 2 CBitmapButtons.  These buttons are 
set with the BS_PUSHBUTTON style and represent whether each of 2 
different states in my application are on or off. When I "push" 
either of these buttons, I toggle a state and use those states 
as a key for the SetState method of CBitmapButton.

Some pseudo code is


bool    	    	State1;    	//    	Defined elsewhere
CBitmapButton    	aButton;    //    	Defined elsewhere	

void    	aPropPage::OnBnClickedState1Button (void)
{
    	State1    	=!    	State1    ;    	// Toggle State1
    	aButton.SetState    	(State1)
    	...
    	return;
}

All of this is fairly standard.

Now here comes the strange part.  When State1 is set to false, 
and I "push" the button referenced by aButton, tracing the code 
reveals that I execute OnBnClickedState1Button not ONCE but 
TWICE!!

The first execution sets State1 to true, so the code

    	aButton.SetState (State1)

causes aButton to HIGHLIGHT, as State1 is this instance is
true.  The code seems to cause the ON_BN_CLICKED message to be 
sent again, so OnBnClickedState1Button executes twice.

The result is that State1 reverts back to false.

If I remove the statement aButton.SetState (State1) from this 
function, the function OnBnClickedState1Button only executes 
once upon clicking aButton.

Does anyone know whats going on?

TIA



0
3/6/2005 5:39:16 AM
vc.mfc 33608 articles. 0 followers. Follow

1 Replies
899 Views

Similar Articles

[PageSpeed] 8

Probably because this isn't really a good way to handle the button state. Set the
BS_PUSHLIKE style (if I recall the name correctly) or make it an owner-draw checkbox.
			joe

On Sat, 05 Mar 2005 23:39:16 -0600, Harvey
<HarvNOSPAMey.CoNOSPAMATALLhen@adelpREALLYNOSPAMhia.net> wrote:

>Hello all,
>
>I have an application that throws up a property sheet with 4 
>pages (tabs) contained within.  One of the pages (tabs) displays 
>a dialog resource that has 2 CBitmapButtons.  These buttons are 
>set with the BS_PUSHBUTTON style and represent whether each of 2 
>different states in my application are on or off. When I "push" 
>either of these buttons, I toggle a state and use those states 
>as a key for the SetState method of CBitmapButton.
>
>Some pseudo code is
>
>
>bool    	    	State1;    	//    	Defined elsewhere
>CBitmapButton    	aButton;    //    	Defined elsewhere	
>
>void    	aPropPage::OnBnClickedState1Button (void)
>{
>    	State1    	=!    	State1    ;    	// Toggle State1
>    	aButton.SetState    	(State1)
>    	...
>    	return;
>}
>
>All of this is fairly standard.
>
>Now here comes the strange part.  When State1 is set to false, 
>and I "push" the button referenced by aButton, tracing the code 
>reveals that I execute OnBnClickedState1Button not ONCE but 
>TWICE!!
>
>The first execution sets State1 to true, so the code
>
>    	aButton.SetState (State1)
>
>causes aButton to HIGHLIGHT, as State1 is this instance is
>true.  The code seems to cause the ON_BN_CLICKED message to be 
>sent again, so OnBnClickedState1Button executes twice.
>
>The result is that State1 reverts back to false.
>
>If I remove the statement aButton.SetState (State1) from this 
>function, the function OnBnClickedState1Button only executes 
>once upon clicking aButton.
>
>Does anyone know whats going on?
>
>TIA
>
>

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15972)
3/10/2005 3:17:17 AM
Reply:

Similar Artilces:

Log on problem
IE 8 will not remember my sign in information. What do I do so I don't have to sign in each time? kit kit1109;156866 Wrote: > IE 8 will not remember my sign in information. What do I do so I don't > have > to sign in each time? > kit Check to see if AutoComplete is turned on. Click Tools --> Internet Options --> Content Tab (from the tabs across the top) --> and Settings for AutoComplete AutoComplete feature lets you more quickly fill out web forms and navigate to websites you have visited in the past. AutoComplete collects and stores in th...

Global Address List Problem
I am using WindowsXP pro and Office 2003 pro. I am having issues sending mail to one of the contacts on my GAL as I get undeliverable message whenever I try to send mail to them. When I look at the properties for this recipient, I see the following in the display field: /cn=***/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=***, on the email tab there is no address listed. This is not the case with any of the other recipients in the GAL. This is causing me problems because even if I type in the full email address of the person in the 'To' field, it still comes up with the undeli...

Copy/Paste problem from another app to Excel
I have an application that supports VBA and I'm trying to copy some values from its screen into Excel using VBA. If I do it manualy, wont be a problem. Cliping the text manualy from "Session" and pasting in Excel gives me the wanted result.(text in Excel will be pasted in different lines like the in the original in "Session") Session Excel 9889790 9889790 9889791 9889791 9889792 9889792 But, when I use the VBA code bellow, the text in Excel wont be in 3 different lines,cells like when I do it manually. The whole string ...

Loading problems
Does anyone out there know why I can no longer open Microsoft Money? I click on it, and nothin happens. It locked up on me one day and since then it no longer loads when I try to open it. However, I can start and sign into Money Express from the system tray without a problem; it however will then not load in the full program when I select it. Any thoughts would be apprecaited. Thank you! Assuming you are talking about M2002, you need to uninstall and reinstall. The recommended procedure from MS Support is to reinstall into a different directory although some have found that this ...

Problem Choosing Accout to Send From in Outlook
Whenever I choose a non-default account to "send from", the mail form indicates it will send from the selected account but then ultimately sends from the default. Any suggestions? ...

Problem with Data Migration Framework, nothing is migrated....
Hi, I am trying to get some data into CRM with Data Migration Framework, but I have some problems. I have followed the guide, but when I am doing the migrate process the data fails to migrate. To eliminate some issues I have tried to manaully insert a testrecord in the cdf_mscrm database using the SQL enterprise manager. The only data in the database is a single record in the cdf_account table with corresponding records in _ext and _info databases. The fields AccountID, OwningUser and Name has data, the other fields are empty. OwningUser has a value wich corresponds with a SystemUserId in the...

Sign on/off problem
my mother was using her system and while trying to change her background her system did a restart and on startup asked for a password ( she never had to use a password before) now when she gives it the password it log her on, the microsoft music starts then it logs her off, and then the password window comes up. I went into safemode tryed the administrator account but a blank password doesn't work. Neather does any of the passwords she has used for outlook or anyother app. Question 1 why is it loging on then loging off. Question 2 Can I use Safemode with command promt to res...

Nickname problem
Hello, We've got some users (high-level security types) that are complaining about an option in their Outlook client's Autofill. When they address an email to someone, it shows the regular information "lastname, firstname" but then right next to it, it shows the user id, so it looks like "lastname, firstname <userid>". The security types are beating down the door to get the <userid> part removed because it compromises a level of security that we need here. Anybody know how to just have it show up with the "lastname, firstname" instea...

Outlook 97 Startup Problems #2
I have recently started using Outlook Express as my mail service with my internet provider. They were unwilling to help me set up Outlook. In trying to start up Outlook, I am getting the following messages: Message one: Unable to open your default mail folders. Outlook could not start because a location to send and receive could not be found. It goes on to prompt me to go to my mail icon in my control panel. Message two reads: Couldn't read your internet e-mail profile. Please exit, delete the current profile and create a new one. In trying to follow the instructions in the first m...

Strange email problem,
having issue with one domain with emails, theres is exch 2003 and ours is exch 2007 We had an issue with no emails reaching either domain - sent or received, their IT guy did a bit of fiddling and now we can email each other (using his email address) however we can't send receive any emails to anyone else in either domain, i'm stumped to what it is any ideas? what did the "fiddling" entail? any NDRs involved? what do you see in message tracking? anything between the Exchange servers and the Internet that might be responsible? relay servers? could be lots of th...

Problem using problem reporting
I noticed that windows 7 error reporting no longer works on my machine. It goes through the motions then reports it cannot connect to the error reporting service at this time, try again later. I have tried many times, same results each day. Any clue as to what might be wrong? Anyone heard of this error or know of a fix I'm using Windows 7 64 bit. Seen it reported a few times. The cause has worked out to one of three: 1.) Third party firewall 2.) Horked DNS 3.) Serious infection. Unfortunately, the third is the most common I've seen. -- Charlie. http://msmvps....

Outlook Attachment problem
Hi, I have windows 2000 exchange server with service pack 3 and with all the hotfixes, some of our clients complaigning that thes attachments are corrupted when they receive emails from us , it works perfect some times and some times we need to resend the email to them which is very irritating to client and our users, Please suggest Any AV/Content Filtering/Gateways between your mail system and the external world? I would look there if its indeed happening on your end. On Thu, 3 Feb 2005 13:23:02 -0800, "Deeps" <Deeps@discussions.microsoft.com> wrote: >Hi, >...

help with crazy problem
Hi, I'm building an application using MFC in Visual Studio 2003 on an XP machine. I am building the executable to use MFC as a static library. I use API calls somewhat liberally in the app. When I copy the app over to a Win98SE test system and attempt to run it, a call to CreateFile fails with the error code 87 (ERROR_INVALID_PARAMETER). I have tried every combination of flags that I can think of, and it still fails. I put Visual C++ 6.0 on the 98SE test system (wouldn't let me put VS2003 on there), and created a test app and I'm hard pressed to find a combination of flag...

Sync problem-Sale missing in Offline mode
We are using RMS 1.3.0203 After system has gone into offline mode and came back to online after some transactions but it did not synchronize offline data to Primary Database. I also checked it form SO Manger to close the Blind close batch there was no data in the primary database from the offline transactions. Due to this reason system showing Access amount Can we recover the offline transactions if for whatever reason they do not sync into the primary database. hi Naveed, I am not sure you know how to offline data but let me tell you. first setup the offline database and once it ...

Problem sending #2
When i send mail out in Outlook Express it gets delivered but it does not get logged into the send folder. I checked the options folder to have the mail placed in the send folder afer being sent. I get a error message after it is sent. Anyone know what this could be? Thanks awosolu@bellsouth.net <awosolu@bellsouth.net> wrote: > When i send mail out in Outlook Express it gets delivered but it does > not get logged into the send folder. Ask in an Outlook Express newsgroup. Be sure to include the exact text of the error message. -- Brian Tillman ...

Sending Problem #7
Can anybody advise how to delete a read receipt which will not send without using Outlook Spy? http://www.outlook-tips.net/howto/delete_rr.htm Paul <nothanks@btopenworld.com> wrote: > Can anybody advise how to delete a read receipt which will not send > without using Outlook Spy? > > http://www.outlook-tips.net/howto/delete_rr.htm Using Outlook Spy has been the only way I recall anyone has ever recommended. Why don't you want to use it? -- Brian Tillman "Brian Tillman" <tillman1952@yahoo.com> wrote in message news:%23ReKyzKUHHA.1036@TK2MSFT...

Problem on saving documents from IE8
Hi to everyone can you please help me to solve this problem. My problem is when I tried to save a file(pdf, doc, excel, ppt etc.) using the "Save Target as" on the IE8 by right click on the file link it give me the url not the file itself. I tried this on other pc the same problem it saving the url of the file. I tried uninstalling and reinstalling IE8 but still the same problem. Pleas help. Thank you. Gerald ...

Problem with CHKDSK
Hi When I run CHKDSK it gets a pass with /i but it hangs at the reboot with /f and /x and it says "CHKDSK is verifying indexes (Stage 2) 0 percent complete" and I have to reboot. I have a Seagate disk drive. I downloaded and ran Seatools for windows and got a pass on Long Drive Self Test. So I can assume that the disk is OK. The utility is read only it does not do any repair. I tried to do an Avast anti-virus scan but it stops before completing the scan and the computer has to be rebooted. Disk cleanup also freezes the computer Any idea of what I could do...

Chart Problem ( X-Axis Shrinks as new data added)
Dear Forum Members, This is my first post in this forum. I have made a chart using the following Informative link by Jon Peltier http://pubs.logicalexpressions.com/pub0009/LPMArticle.asp?ID=246 The chart have a large range comprising of abt 1500 rows. I am using the simple Line Chart. I want to see the chart of data covering 200 rows at a time . but when I add data abt 17 rows it shrinks and doesnt show me the chart of all the data I have added the slidders to control the Sart and the end dates. I have start Date in cell G1=02-01-1998 I have End Date in cell G2=27-01-1998 I...

Logon problems
XP/Internet Explorer 8/Outlook express 6.00.29xxxxx Starting yesterday I cannot logon to my email account. I have changed/installed nothing at all. My wife's account will logon without any problem. I even deleted my account and reentered all the information, but all I get is a popup window telling me my password is incorrect. When I recreated my account, I even used a new password but I get the same error message. Can you please offer any help or advice. Thank you for your time. Bob You can't make a new password without coordinating it with your ISP. O...

Windows Time
Afternoon all, My DC (windows 2003 R2) running the PDCe role couldn't sync with time.windows.com and I've now got mismatched times on other servers. After doing some checking I notice that under HKLM\system\services\currentcoltrolset\w32time that some server have time.windows.com,0x1 as the NtpServer - is thi sby deault, of has hapenned since my issues? Should I correct this key? My understanding is that devices sync with local DC, local DC syncs with PDCe, PDCe syncs with external time source (in this instance time.windows.com) Hello Andrew, If you have ...

Copy and Paste formatting problems
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Hi, <br><br>I'm &quot;selecting all&quot; and &quot;copying&quot; from one document and need to &quot;paste&quot; into a 2nd document. But when I paste into the 2nd document the text is not formatted - all the lines are jumbled up together. Any advice would be helpful, thank you. I need a bit more detail to be able to answer this: * Are both documents Word documents? * Which file format? * What do the documents contain? * How were they formatted? * What are the...

Boot Ini Problem
Hi, I am getting the following error message: Invalid Boot Ini Booting from C:/Windows So I research this problem and create a new Boot Ini file and when I reboot I still get this error. I have not attempted yet to do a repair using my XP media, is this what I need to do to fix this problem? Or is there a less painful way to fix this? Thank you. Maybe this will help. You will be interested mainly in the Bootcfg command. http://support.microsoft.com/kb/314058 "AIANDAS" <AIANDAS@discussions.microsoft.com> wrote in message news:9E04022F-4DC2-...

Not having any problem at all
I'm running M2004 and I don't have any problem getting into my file at all with passport. Maybe I'm just lucky but if this is a system wide problem wouldn't everyone be having the problem? I'd hate for Bill to stumble upon someone from this newsgroup! :) Zach "Zach Rose" <meoge@hotmail.com> wrote in message news:n0FNc.172401$%_6.124775@attbi_s01... > I'm running M2004 and I don't have any problem getting into my file at all > with passport. Maybe I'm just lucky but if this is a system wide problem > wouldn't everyone be ha...

Font problem with Outlook 2003, please read.
Basically in a nutshell I want to read all of my e-mail messages in font Verdana size 9. I have it set up so that most of the messages come in with Verdana size 9 but some get through with Arial and various other fonts. How do I accomplish having every single e-mail come through always in Verdana size 9? Thank you so much in advance. You can try setting Outlook to read all your emails in text format (Options | Preferences | Email Options | Read all standard mail....). Once you've done that, you can set your plain text font to verdana 9. Ok that worked but what if I want to ke...