I think I found a bug when working with the MS6.0 NiButton control under VC++ 6.0. I'm running win2000 if that matters. Anyway, if you do the following you'll see what I'm talking about:
a.) Drag a CNiButton control off of you tool bar and onto your dialog.
b.) Change the style to command button or toggle button.
c.) Set it to 'Switch until released'.
d.) Double click it and put AfxMessageBox("hello"); as the only line of code.
e.) Run the program.
When you click on the button you get hello on the screen. If you come back at any time and move the pointer over the control so that it comes into focus you get hello on the screen again. How come? Is it supposed to run twice? I use command buttons for everything, basically, and I don't
want things running twice, especially without me knowing it. If I use a toggle button instead of a command button and set it to 'Switch until relased' it behaves similarly. If you change to 'Switch when pressed' then it actually says hello when you click on it but the button stays on until you click it again which prints hello on the screen and turns the button off again.
I thought that the difference between 'Switch until released' and 'Switch when pressed' is similar to the CVI idea of either a toggle button or a command button. In CVI command buttons have one state and toggles have two. That seems to make sense. Why do I want a command button with two states?
One work around is to handle the 'Click' event on these buttons rather then the 'Value Changed' event. This runs the routine once which seems to be the desired result. However I like to be able to double click on my dialog buttons and go to the code and you can't do that unless you use the default routine which h
andles the 'ValueChanged' event.
Hope I'm not just wasting your time. Please let me know if I'm doing something wrong.
Thanks,
Grant
Grant M. Johnson
Project Engineer
LECO Corporation