• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 540
  • Last Modified:

Complex (for me) problem involving MFC

The situation is that I have a project comprised of multiple document (in a tabbed interface) with different views.  The underlying document is update dynamically via propertypage input.

I've implemented HTML Help that is accessed by a typical menu that is attached to the frame.

When the basic document view is activated, I post a int variable and a message string in the application control logic that can be referenced in the frame logic that initiates the help display via HtmlHelp(xx, text); statement.

When the user activates the propertypage(s), via a frame button, each page as it is activated posts its own int variable and message string in the application control logic, again, to make the information available to the frame logic so the user can click on the frame menu to activate the help call.  --> I'm doing a variation of context help, ergo the int variable (represents a link within the HTML Help file) and the text is text that I add to the menu so that the user sees the equivalent of, "click for help on xxxxxxxx".

Since the propertytpage implementation is modeless, the HTML Help viewer flashes, then disappears.

If I then click on the title bar of the propertypage dialog, the HTML Help viewer will appear under the propertypage dialog; that is great because then the user can drag it off to the side so he / she can read the help text that is specific to the displayed page.

So since that is what I want to achieve I need some way of simulating the click on the tiotle bar of the propertypage dialog or an equivalent.

This is really deep in the weeds for me and I haven't been able to arrive at a solution .

Any ideas or help would be appreciated.

  • 3
  • 3
1 Solution
satsumoSoftware DeveloperCommented:
I think I follow what happening.  Can you explain the bit more about 'the HTML help viewer flashes than disappears'?  Is the HTML help in a separate window, a modeless child window or something else?  When you say it disappears do you mean it drops behind the main window or is removed from the screen entirely?

HTML help doesn't normally disappear, it lives in its own window, somewhere in the window stack.  The behaviour you're describing is like a tooltip or a menu.  To make it disappear the program would have to explicitly hide or close it.
OnagerAuthor Commented:
The Help viewer is the viewer that is invoked by, for example,

HtmlHelp(20, HH_HELP_CONTEXT);

When any of those are executed it is executed in the main frame (CMainFrame) in response to a click on a dropdown menu item.  There is a document open in a view and a modeless propertysheet/page that is accepting input (this is a maintenance procedure) and that propertysheet/page logic is updating the underlying ocument, which in turn is updating the view of that document as a data item is entered and validated.

The problem only ocurs when the modeless propertysheet/page is up, the help viewer operates as I would have expected if I'm only dealing with a view.

Again, when I click on the menu item to activate Help, the Help viewer flashes then disappears immediately.  Your comment was on target, it actually disappears, hides would be a better description, behind the main window and will appear if I click on either the main window (anywhere) or on the active propertypage.  When it appears it shows up behind the propertysheet/page but in front of the main window.  Then a user can drag it off to the side and read the help information.  However, if instead of dragging the Help window off to the side the user clicks on anything on the help viewer window, it will hide behind the main window again.

I don't see anything that I am doing that would explicitly hide it, I think it is an anomoly when there's a modeless dialog involved.

I did try adding: this->Invalidate(); in the frame logic after HtmlHelp(xx, ccccc) to force repainting but that had no effect.  I thought that there might be a message I could post (WM_xxxxx) that might force the behavior I'm trying to get but I don't see anything that looks like it would work.

I appreciate your reply, hope you can get me closer to a solution.
satsumoSoftware DeveloperCommented:
It sounds like the HTML help window might not owned by your frame window, so it won't stay on top.  The property page is owned by the frame window and will stay on top.  It probably has the WS_EX_TOPMOST or WS_EX_TOOLWINDOW style. http://msdn.microsoft.com/en-us/library/windows/desktop/ff700543(v=vs.85).aspx

The problem appears to be that when you show the property page it gets the input focus, or is activated.  It causes the frame window to move up the z-order, which puts the HTML Help Window behind it.

The solution is to change the relationship between the HTML Help and the frame or the property page and the frame.  If you can make the HTML Help a child window, that would solve it.  If you can make the property window not change the z-order of the frame window that would help too.

The document of HtmlHelp() in MSDN allows you to specify an owning window.  You're examples don't have as many parameters.  Is there some other way to set the owner window in MFC? http://msdn.microsoft.com/en-us/library/windows/desktop/ms670172(v=vs.85).aspx

If you have a handle to the HTML Help window, another possibility is giving it the WS_EX_TOPMOST style.  That will mean it won't fall behind the frame window.  Unfortunately I use the Windows API directly, which gives control over everything.  I don't know MFC well enough to be able to tell you exactly how to do this.
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

OnagerAuthor Commented:

The information you gave me led me to the solution.  It was the comments regarding z-order.

"all" it took was adding:

      this->SetWindowPos(&CWnd::wndBottom, 0, 0, 0, 0,

To the CMainFrame logic immediately prior to the statement:
                    HtmlHelp(20, HH_HELP_CONTEXT);

I've not thoroughly tested all circumstances but the behavior so far is exactly what I was trying to achieve, the Help Viewer now shows up on top of the propertysheet/page and gives the user the ability to drag it off to the side.  Even more important, it stays on top of the main window, behind the propertysheet/page, while the user continues their maintenance task, making the help information as useful as I had intended (assuming they find the actual help text useful)

Thank you again!
OnagerAuthor Commented:
Nudged me in teh right direction, comments were spot on.
satsumoSoftware DeveloperCommented:
I'm very glad it helped.  I was pretty sure you could figure out how to make it work, even if I couldn't describe the specifics of MFC.  Like you, I can't say whether the solution you describe is the best way to do it or that it will work in all cases.  Still, I can't see any problem with your method and it appears to work.  If you find a case where I doesn't work you will have some idea have to solve it now.

Thanks for the points and the answer.  It makes EE worth the effort when people let you know that you helped.

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.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now