Launching Window via Menu Click versus Keyboard Shortcut
Inside a large program, written in VC++ .Net (2010), I have added a feature where I open a dialog box that displays information to the user. I have made two ways that this dialog box could be opened by the user: a click on a menu item, or a keyboard shortcut (namely “Ctrl+d”). Both ways should do the same thing, that is open the dialog and trigger the code inside the run (get and display the information for the user).
The problem I am having is that, for some reason, it seems that when I launch the dialog box via the keyboard shortcut the code works fine (no errors), but when I click on the menu item the dialog pops up but then it throws an error. The error that it throws is related to how it retrieves certain bits of data from an attached device. I am pretty certain that the line of code that throws the error is fine, if there is a problem it is problem how I go about calling it. But I do not understand how the same code could work fine via the keyboard shortcut, but throw errors when clicking on the menu item…I would think both ways should trigger the same actions.
I can get more specific about the error it throws if need be, but right now my question is about how these two ways of launching a dialog box are in some way different.
Yes, you are right, I posted in the wrong forum, my mistake, sorry.
I think I figured out the problem. It had to do with how I was declaring my variables in the header file. I am not very experienced in VC++, so I was just adding on to an existing program, and adding my new variables below the declaration of the existing ones. But for some reason it seems like it was ‘grouping’ (for lack of a better word) the variables together, so that when I passed the old variables into the function call, it also saw the new ones too…despite the fact that they had different names. Effectively I solved this by declaring my new variables at the top of the list, instead of the bottom, in their own “Public:” block, and it works. Surely there is a reasonable explanation for this behavior, but I am too inexperienced in VC++ know it right now.