 |

04-23-2012, 09:57 PM
|
Ultimate Contributor
|
|
Join Date: Apr 2003
Location: Texas, USA
Posts: 1,623
|
|
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.
Any help is appreciated.
|
|

04-24-2012, 01:39 AM
|
 |
Bald Mountain Survivor
Retired Moderator * Expert *
|
|
Join Date: Aug 2003
Location: Oregon, USA - deceased
Posts: 6,440
|
|
1) This is a Visual Basic forum. Do not be suprised if no one answers.
2) Any time you find your self duplicating code you should write one procedure instead and call it when ever you need it.
|
__________________
Burn the land and boil the sea
You can't take the sky from me
~T
|

04-24-2012, 05:53 AM
|
 |
Fabulous Florist
Forum Leader * Guru *
|
|
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
|
|
3) When your question is "What is different?" and you don't post any of your source, the answer is "I don't know."
|
|

04-24-2012, 10:24 AM
|
Ultimate Contributor
|
|
Join Date: Apr 2003
Location: Texas, USA
Posts: 1,623
|
|
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.
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|