Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Dynamicly add accelerator keys to dynamic menu items

Posted on 2002-07-01
6
Medium Priority
?
516 Views
Last Modified: 2013-11-20
I cannot find a way to add new accelerator keys at run time.

I have a dynamic menu and i would like to assign accelerator keys to some of it's items.

So far i managed to Count the number of entries in the current table, allocate a buffer for the table, and then copy the table into the buffer.

HOWEVER, there is no function that will add new accelerator keys to the table.

I've using the 'Creating User-Editable Accelerators' article from the MSDN as a reference.


0
Comment
Question by:Michal080800
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 12

Accepted Solution

by:
migel earned 1200 total points
ID: 7121364
Hi!
show your code please:
// modified code from the article, mentoned above
{
///
                    haccelOld = haccel;
 
                    // Count the number of entries in the current
                    // table, allocate a buffer for the table, and
                    // then copy the table into the buffer.
 
                    cAccelerators = CopyAcceleratorTable(
                        haccelOld, NULL, 0);
// adding new accelerator
// !!!! note +1
                    lpaccelNew = (LPACCEL) LocalAlloc(LPTR, (cAccelerators+1)*sizeof(ACCEL));
 
                    if (lpaccelNew != NULL)
                    {
                        CopyAcceleratorTable(haccel, lpaccelNew,
                            cAccelerators);
                    }

// !!! add your own accelerator at the table end
                    lpaccelNew[cAccelerators].fVirt = fAccelFlags;
                    lpaccelNew[cAccelerators].key = wVKCode;
 
                    // Create the new accelerator table, and
                    // destroy the old one.
 
                    DestroyAcceleratorTable(haccelOld);
// !!! note +1
                    haccel = CreateAcceleratorTable(lpaccelNew, cAccelerators+1);
///
}
0
 

Author Comment

by:Michal080800
ID: 7121369
Thanks for the quick response.

I'll try this now.

0
 

Author Comment

by:Michal080800
ID: 7121393
Hi Migel,

How do i compute the value of wVKCode.

For example i want to add an accelerator Ctrl+F to a menu item.
The fAccelFlags is easily computed, but i'm not sure how to compute the wVKCode for the 'F' char.

(btw, i've increased the points for this question as you have been so helpful and i am very greatful).

Thanks,

Michal.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:Michal080800
ID: 7121398
Hi Migel,

How do i compute the value of wVKCode.

For example i want to add an accelerator Ctrl+F to a menu item.
The fAccelFlags is easily computed, but i'm not sure how to compute the wVKCode for the 'F' char.

(btw, i've increased the points for this question as you have been so helpful and i am very greatful).

Thanks,

Michal.
0
 
LVL 12

Expert Comment

by:migel
ID: 7121496
Hi!
you can use virtual key codes

/* VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */
/* VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */
and set FVIRTKEY flag in the fVirt field;
or use just character code 'F'
0
 

Author Comment

by:Michal080800
ID: 7121498
Thank you very much.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

610 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