Solved

Using help for custom checkbox in CFileDialog

Posted on 2004-04-05
13
552 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
 
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Login Script to Copy Folders 12 21
Expand LInux Boot partition remotly 3 78
sumNumber challenge 16 98
Window placement 17 64
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

708 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

17 Experts available now in Live!

Get 1:1 Help Now