Using help for custom checkbox in CFileDialog

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.
vgandhi2003Asked:
Who is Participating?
 
akalmaniConnect With a Mentor Commented:
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
 
akalmaniCommented:
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
 
vgandhi2003Author Commented:
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
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
akalmaniCommented:
>>>//  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
 
akalmaniCommented:
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
 
akalmaniCommented:
I gave it a try it does not work..please ignore my comments.
0
 
akalmaniCommented:
Take a look and see if you can implement something like this..

http://support.microsoft.com/default.aspx?scid=kb;en-us;117563
0
 
akalmaniCommented:
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
 
vgandhi2003Author Commented:
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
 
akalmaniCommented:
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
 
vgandhi2003Author Commented:
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
 
vgandhi2003Author Commented:
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
 
vgandhi2003Author Commented:
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
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.