Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Get Chosed Menu ID. F1 help problem

Posted on 1998-12-08
8
Medium Priority
?
310 Views
Last Modified: 2013-11-20
Hi,

If user puch F1, I go to OnHelp procedure. But I have
no help documents, and I dont want to display such.
I only want to set a message: 'You pushed F1'.
But now, the program say that some help files are not
found. It gives 2 such warnings. I can take tha warnings
away by changing the procedure name to OnTestHelp.
This is working, but I get my message 2 times.

I would also like to get the chosed menu ID. I know it
is possible to check a 'Help' flick in the resource
window for each menu item name, but I dont know how
to use this correctly. Is there a way to get the chosed
menu ID, even if I have a dialog that popped up by
chosing a menu item. So, if I see a dialog, and puch F1,
I will see the ID of the menu item that bringed up the
dialog.

Thank You, Tomas
0
Comment
Question by:tko092397
  • 4
  • 2
  • 2
8 Comments
 
LVL 2

Expert Comment

by:wyy_cq
ID: 1325906
when F1 press ,CWinApp::OnHelp(...) will be called

you need to redefine the CWinApp::OnHelp(...) in your class

0
 

Author Comment

by:tko092397
ID: 1325907
Yes, I know that OnHelp will be called when I press F1.
I even know so mutch that if I use ID_HELP in ON_COMMAND,
I can define whatewer name instead of OnHelp.

So, you suggest that I need to redefine OnHelp. How can I redefine
it, so I dont get the error messages that help files is missing?

And How can I get the ID number for the menu item chosed, like Help-About?

Please ansver to these.
0
 

Author Comment

by:tko092397
ID: 1325908
Yes, I know that OnHelp will be called when I press F1.
I even know so mutch that if I use ID_HELP in ON_COMMAND,
I can define whatewer name instead of OnHelp.

So, you suggest that I need to redefine OnHelp. How can I redefine
it, so I dont get the error messages that help files is missing?

And How can I get the ID number for the menu item chosed, like Help-About?

Please ansver to these.
0
Industry Leaders: 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!

 
LVL 2

Expert Comment

by:wyy_cq
ID: 1325909
if you are talking about context help , MFC provide many function for you.

but i guess you have a few menu item,
suppose one is "Help a"
one is "Help b".

now when the user selects the a menu item , your application know which item is selected by user.

you can treat all the menu item of help as common menu.

define message map for every menu item , when it is selected the message will be send to your window.

i don't know my hypothesis correct, if it is correct.
you may do like this:

defien two ID for menu item.
IDM_1  for help A
IDM_2  for help B

map the message .
ON_COMMAND(IDM_1,OnMenu1)
ON_COMMAND(IDM_2,OnMenu2)

when IDM_1 selected the OnMenu1 will be called.
when IDM_2 selected the OnMenu2 will be called.

0
 

Author Comment

by:tko092397
ID: 1325910
Thanks. Now, I think I get the idea of my menu problem.

I have only one more problem. If I use ON_COMMAND(ID_HELP,OnHelp) , I get
2 error messages that some help doc is not found.
If I use ON_COMMAND(ID_HELP, OnMyHelp), the program jump to
OnMyHelp 2 times when I press F1. If I have a dialog popped up, and
pres F1, the program jumps to OnMyHelp one time (correct).
So, I want that when I push F1, OnMyHelp is called only one
time. If there is a way to get OnHelp to work 'one time jump' without
error messages, it is also good for me.
So, please give some suggestion for this.

Thanks, Tomas
0
 

Accepted Solution

by:
McCreary earned 400 total points
ID: 1325911
You do NOT use ON_COMMAN(ID_HELP,OnHelp) what you do is write

void CYourApp::WinHelp(DWORD dwData, UINT nCmd) {} in Your.cpp, with

void WinHelp(DWORD dwData, UINT nCmd = HELP_CONTEXT); in the application header Your.h.  The CWinApp class which CYourApp inheirates from has a virtual function
virtual void CWinApp::WinHelp(DWORD dwData, UINT nCmd=HELP_CONTEXT) which you will override.  This way you may decided exactly what you want to do when the user presses the F1 key and you do NOT need to call CWinApp::WinHelp if you don't want to.  The DWORD dwData will the ID of menu items plus an offset of 0x10000, or an IDR plus an offset of 0x20000.

0
 

Author Comment

by:tko092397
ID: 1325912
I can not use WinHelp, becouse I dont know how. I newer jump into
void CYourApp::WinHelp(...){}
And the F1 hotkey is active only if I defined the ON_COMMAND(ID_HELP, OnHelp)
By using the mentioned ON_COMMAND with OnHelp procedure, it works
but I get 2 calls to OnHelp procedure if I am in the root window, i.e., no dialog
is active. If a dialog is active I get one call to OnHelp.

So, I cant override WinHelp, becouse it is never called.

If you could suggest some method to always call a procedure XXX only once
when pressing F1 it would be great. I dont want anymore the menu ID, becouse
it is solved.
0
 

Expert Comment

by:McCreary
ID: 1325913
Are you using MFC?  Have you set your project up for contact sensitive help?  WinHelp should always be called when the user presses F1 because this is the interface between your application and the Microsoft help engine, which usually reads and processes the application's .hlp file.   Perhaps I just don't understand your situation.
0

Featured Post

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.

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 …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

772 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