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
Solved

Get Chosed Menu ID. F1 help problem

Posted on 1998-12-08
8
289 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Shell script to login to remote m/c and execute commands 10 78
difference between String.subString() and String.subSequence() 6 235
post4 challenge 28 104
sumHeights  challenge 17 74
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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.

860 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