Solved

Get Chosed Menu ID. F1 help problem

Posted on 1998-12-08
8
285 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 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

10 Experts available now in Live!

Get 1:1 Help Now