Solved

Get Chosed Menu ID. F1 help problem

Posted on 1998-12-08
8
273 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
 
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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 200 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

744 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

12 Experts available now in Live!

Get 1:1 Help Now