Get Chosed Menu ID. F1 help problem

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
tko092397Asked:
Who is Participating?
 
McCrearyConnect With a Mentor Commented:
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
 
wyy_cqCommented:
when F1 press ,CWinApp::OnHelp(...) will be called

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

0
 
tko092397Author Commented:
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
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
tko092397Author Commented:
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
 
wyy_cqCommented:
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
 
tko092397Author Commented:
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
 
tko092397Author Commented:
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
 
McCrearyCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.