Solved

Question on Accelerator

Posted on 1998-11-14
10
210 Views
Last Modified: 2013-11-20
Hi there,
         I've assigned a virtual key "Ctrl + A" to try to bring up a dialog box but however, the dialog box doesn't apppear after I pressed "Ctrl + A"... why is this so?? How can I solve it?

Any help offered is very much appreciated!!!
0
Comment
Question by:justinng
  • 6
  • 4
10 Comments
 
LVL 1

Accepted Solution

by:
atari earned 50 total points
ID: 1324686
You have to define a virtual key in your accelerator list in the resource, I think, that is what you have implemented.
ID                                       Key         Type
CM_SHOW_DIALOG     Ctrl+A     VIRTUAL

Then in your resource.h-file you have to manually type in the following line:
#define CM_SHOW_DIALOG 101 // or any other ID-number

Then in the class where you want to show the dialog box from, you have to implement in the .cpp-file a message-handler like this

BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
      //{{AFX_MSG_MAP(CMainFrame)
      ON_COMMAND(CM_SHOW_DIALOG,OnShowDialog)
      //}}AFX_MSG_MAP
END_MESSAGE_MAP()

Then in your .cpp-file declare the member function that shows your dialog:

void CMainFrame::OnShowDialog()
{
  CYourDialog dlg;
  if (dlg.DoModal())
{
 // do what you want
}
}

and in your .h-file you have to declare this member-function:
//{{AFX_MSG(CMainFrame)
    afx_msg void OnAlleItemsSelektieren();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()

That's it,
bye
atari
0
 

Author Comment

by:justinng
ID: 1324687
Hi atari... when I tried to compile it.... it shows me an error at the code segment shown below:
------------------------
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
   //{{AFX_MSG_MAP(CMainFrame)
   ON_COMMAND(CM_SHOW_DIALOG,OnShowDialog)
   //}}AFX_MSG_MAP
   END_MESSAGE_MAP()
------------------------
By the way, my ID for the dialog box, that I wanted it to pop up by pressing Ctrl+A, is
IDD_MY_DIALOG so I replaced CM_SHOW_DIALOG by IDD_MY_DIALOG and I think this should be fine. But the error occur at ON_COMMAND(IDD_MY_DIALOG, OnShowDialog) and the error message is something about undeclared stuffs.... Please
help thanks! I don't quite understand the last code segment also, care to explain? :)
0
 
LVL 1

Expert Comment

by:atari
ID: 1324688
Hi, justinng,
give me your email-address and I will send you a small code snippet by email.

I don't know what you have made wrong, don't know the compiler error message, my code is correct, putting your ID-number as first parameter of ON_COMMAND is wrong, because I only connect the Ctrl-A with an self defined ID (called CM_SHOW_DIALOG) declared in the resource file. This ID is an ID for a message handler, that has nothing to do with the ID of your dialog box. I only want, that the program goes into the routine OnShowDialog() if I press Ctrl+A and nothing more. Then in OnShowDialog() I can do what I want to do, show the dialog or something else. If your code were correct, then you could only show the dialog box but nothing else, you couldn't test, what the user has done within the dialog box, that's what I have done. You can't do all things you want to do with class wizard, sometimes you have to change the resource file manually and put the ID-numbers you wish in there.

Send me your email-address and I will send you a zip-file, that will describe everything.

Bye,
atari
0
 

Author Comment

by:justinng
ID: 1324689
ic... okie thanks! my email address is justinng@singnet.com.sg
0
 
LVL 1

Expert Comment

by:atari
ID: 1324690
Hello, good morning from germany,
I will send you in the next twenty minutes a small project, that I write for you, only to show you the Ctrl-A stuff. It will show you the About dialog as .zip-file.

Bye,
atari
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:justinng
ID: 1324691
Good evening from Singapore... heheee..... your help is very much appreciated!!!
0
 

Author Comment

by:justinng
ID: 1324692
okie I know my mistakes hehee.... by the way I have successfully compiled my codes but when I pressed Ctrl+A the dialog did not pop up. The pop-up dialog is modeless.... does it matter?? And I have a menu which also associates with the dialog box. So the user either call up the dialog box from the menu or pressing Ctrl+A. Please help, I'm almost there... hehe... thanks!
0
 

Author Comment

by:justinng
ID: 1324693
Adjusted points to 50
0
 
LVL 1

Expert Comment

by:atari
ID: 1324694
How about send me your code as .zip and explain exactly what you wanted to do.

My email address mkuelsh@aol.com

I've been looking on this page in a few hours again.

Bye,
atari

But don't think, that I explain the whole project for you. This discussion board is only for single questions, not for whole projects. That was, what I have to learn first, when I entered this discussion board for the first time.

Bye,
atari
0
 

Author Comment

by:justinng
ID: 1324695
hehee.. thanks! I've solved the problem!!!! heheee... thanks alot!!!!!!
Cya around!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Host to IP 7 73
while loop over for loop 7 79
post4 challenge 28 81
Fibonacci challenge 11 82
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now