Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Using help for custom checkbox in CFileDialog

Posted on 2004-04-05
13
Medium Priority
?
584 Views
Last Modified: 2013-11-20
Hello,
 I am using a class derived from CFileDialog. I have created a custom checkbox below the default one that comes with CFileDialog i.e. 'Open as read-only'. However when I try to associate help with that custom checkbox I get no help associated.
Here is the code I am using
------------------
CRect rectCheckbox;
GetParent()->GetDlgItem( chx1 )->GetWindowRect( rectCheckbox );

// Make the text window a little bigger
int nWindowWidth = rectCheckbox.Width() + 200;
int nWindowHeight = rectCheckbox.Height();
ScreenToClient( &rectCheckbox );

//  Create checkbox with style and font and location from the //read-only checkbox
CButton m_TestHelp;

m_TestHelp.Create( "TEST FOR HELP", WS_CHILD| WS_VISIBLE| BS_AUTOCHECKBOX | WS_EX_CONTEXTHELP,
rectCheckbox, GetParent(),IDC_TEST_HELP);

      
CWnd *pCtl = GetParent()->GetDlgItem( IDC_TEST_HELP );

pCtl->SetWindowPos( NULL, rectCheckbox.left, rectCheckbox.top+20, nWindowWidth, nWindowHeight,
SWP_NOACTIVATE );

pCtl->EnableWindow( TRUE );
pCtl->ShowWindow( SW_SHOW );
pCtl->SetWindowContextHelpId( HIDC_TEST_HELP);
      
So when I click on the question mark next to 'X' at the top of the dialog and drag it on the custon checkbox created I don't get the help id associated with HIDC_TEST_HELP. I get the default help id 28441/0x6f19 which says 'no help associated with this item'.
Please help.
Thanks.
0
Comment
Question by:vgandhi2003
  • 8
  • 5
13 Comments
 
LVL 3

Expert Comment

by:akalmani
ID: 10764384
Check this link, probably you need to override ON_WM_HELPINFO and display help. As per your code pasted I do not see anything which is done like this..

http://www.codeguru.com/Cpp/W-P/help/article.php/c6501/
0
 

Author Comment

by:vgandhi2003
ID: 10766579
Hi ,
 Thanks for your comment. I have the following method defined in the dialog but it doesn't even hit this method when I click on the question mark and drag it on the checkbox.

BOOL CCustomFileDialog::OnHelpInfo(HELPINFO* pHelpInfo)
{
      // TODO: Add your message handler code here and/or call default      
      return CFileDialog::OnHelpInfo(pHelpInfo);
}
So please let me know.
Thanks.
0
 
LVL 3

Expert Comment

by:akalmani
ID: 10772620
>>>//  Create checkbox with style and font and location from the //read-only checkbox
>>>CButton m_TestHelp;

Is m_TestHelp a member of the CCustomFileDialog or a local variable created in  CCustomFileDialog::OnInitDialog() ?

Create this as a member of CCustomFileDialog as it needs to persist until the dialog is destroyed.

Try this out ..
0
Technology Partners: 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 3

Expert Comment

by:akalmani
ID: 10772668
You can set up help on modal dialogs by changing their style. Dialog needs this properties. If you have created your own dialog resource for CCustomFileDialog, then set the Context Help property in the extended properties of the dialog resource.

If you are using the default dialog resource template then do the following...
ModifyStyleEx(0, WS_EX_CONTEXTHELP) in the on initdialog.
0
 
LVL 3

Expert Comment

by:akalmani
ID: 10772935
I gave it a try it does not work..please ignore my comments.
0
 
LVL 3

Expert Comment

by:akalmani
ID: 10772938
Take a look and see if you can implement something like this..

http://support.microsoft.com/default.aspx?scid=kb;en-us;117563
0
 
LVL 3

Expert Comment

by:akalmani
ID: 10773328
I serached a few MS KB articles...maybe this will give you some hints

http://support.microsoft.com/default.aspx?scid=kb;en-us;195034
0
 

Author Comment

by:vgandhi2003
ID: 10775535
Hey,
 Thanks  a lot for your help. Infact on the last link that you sent me
http://support.microsoft.com/default.aspx?scid=kb;en-us;195034
if you check out the context sensitive help support section it says
CCustomFileDialog::OnHelpInfo() is called when the WM_HELP message is generated by clicking the ? on the caption bar.
However if you download the files for this project and put a break point in the OnHelpInfo method it never hits it even though Microsoft claims that it will hit it if you click on the ?.
So is there something I might be missing? Let me know. thanks
0
 
LVL 3

Expert Comment

by:akalmani
ID: 10781784
In the final window which is shown from the above mentioned sample. Deselect "Explorer style" and select "Multi-Select". Then click "Go!". Set a break point on ON_WM_HELPINFO. See that it works and the function is called.

I am wondering if EXPLORER style is set then this function is not called. Maybe a bug in MFC.
0
 

Author Comment

by:vgandhi2003
ID: 10785281
Ok so now if I add the following line
      m_ofn.Flags &= ~(OFN_EXPLORER|OFN_HIDEREADONLY);
in the constructor and pass in the following flags
OFN_ENABLESIZING|OFN_READONLY|OFN_ALLOWMULTISELECT|OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR while creating the dialog

I get the multi select dialog with the onhelpinfo working but how do I add my custom checkbox ?
I don't have the id for the read-only checkbox so not sure how it would work?
Thanks
0
 

Author Comment

by:vgandhi2003
ID: 10787256
Also I investigated and found out that through SPY++ the WM_HELP message is generated when you click on the question mark but it doesn't get caught. I tried using hook procedure and through callback but doesn't get caught at all. Something in the middle eats it up.
0
 
LVL 3

Accepted Solution

by:
akalmani earned 525 total points
ID: 10840590
Hi I could get hold of one more link just have a look if it solves your problem

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfcnotes_tn028.asp
0
 

Author Comment

by:vgandhi2003
ID: 10843549
hey the solution is that u have to create a derived class.
make a component of that derived class
and in the dialog's oninit dialog
do the following

BOOL bSubclwhassed = m_wndTempDervivedmember.SubclassWindow(GetParent()->m_hWnd);
You'll be able to hit on the OnHelpInfo msg then.

Seems weird but thats the way.
Since you've really helped me a lot I'll give the points to you. Thanks.
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

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

578 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