Go Back  Xtreme Visual Basic Talk > Other Languages > Miscellaneous Languages > Launching Window via Menu Click versus Keyboard Shortcut

Thread Tools Display Modes
Old 04-23-2012, 09:57 PM
mrjeffy321 mrjeffy321 is offline
Ultimate Contributor
Join Date: Apr 2003
Location: Texas, USA
Posts: 1,623
Default 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.
Reply With Quote
Old 04-24-2012, 01:39 AM
Gruff's Avatar
Gruff Gruff is offline
Bald Mountain Survivor

Retired Moderator
* Expert *
Join Date: Aug 2003
Location: Oregon, USA
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

Reply With Quote
Old 04-24-2012, 05:53 AM
AtmaWeapon's Avatar
AtmaWeapon AtmaWeapon is offline
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."
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
Old 04-24-2012, 10:24 AM
mrjeffy321 mrjeffy321 is offline
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.
Reply With Quote

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..