Help Provider always on top

  • Thread starter Thread starter Dennis C. Drumm
  • Start date Start date
D

Dennis C. Drumm

When HelpProvider and HelpNavigator are started from my application, they
are always on top. The application it was started from cannot be moved on
top of the help.

How can I reconfigue this so that the user can swith between the two?

Thanks,

Dennis
 
Hi Dennis,

Based on my understanding, you use the .Net HelpProvider class to provide
the help function for your control. You find that the help file was always
on the top of the main Form, you want to suppress this feature.

Actually, this is by the design of HelpProvider class. After show up the
help file window, the main window will intercept the help file window's
message and always keep the help file on the top of the main form.

I have provided a sample to prove this. In the sample, I use Win32 API
SetWindowPos function to make the main Form become the current top most
window of the Windows(through HWND_TOPMOST flag), like this:

private System.Windows.Forms.HelpProvider helpProvider1;
private System.Windows.Forms.TextBox textBox1;
private void Form1_Load(object sender, System.EventArgs e)
{
helpProvider1.HelpNamespace = "mspaint.chm";
helpProvider1.SetShowHelp(this.textBox1, true);
}

[DllImport("user32.dll")]
public static extern int SetWindowPos(IntPtr hwnd,IntPtr
hWndInsertAfter,int x,int y,int cx,int cy,int wFlags);

public IntPtr HWND_TOPMOST =(IntPtr)(-1);
public IntPtr HWND_NOTOPMOST =(IntPtr)(-2);
public int SWP_NOSIZE = 0x1;

private void button1_Click(object sender, System.EventArgs e)
{
SetWindowPos(this.Handle, HWND_TOPMOST, this.Left, this.Top, this.Left+
this.Width, this.Top+ this.Height, SWP_NOSIZE);
}

private void button2_Click(object sender, System.EventArgs e)
{
SetWindowPos(this.Handle, HWND_NOTOPMOST, this.Left, this.Top, this.Left+
this.Width, this.Top+ this.Height, SWP_NOSIZE);
}

The button2 will remove the top-most feature of the main form.

After press F1 in textBox1, the mspaint.chm is showed, then if you press
Button1 to make the main form top-most, you will find the main Form is
really on the top of the mspaint.chm window. But if you drag the main form
and then drop, you will find that the help file will on the top of the main
form again(Even though the main form is "top-most").

So, you will know that the .Net will re-set the help file to the top of the
main form, which means that .Net does not recommand you to move the main
form to the top of the help file.

Actually, the main form will intercept the messages of the help files
window, and ensure that if the main form is closed, the help file window is
also closed. As I think, this is a reasonable design.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Thanks Jeffrey,

I figured this was by design, but that design can be pretty tuff on people
who have small screens that do not have enough room to fit both the
application and its help on the screen at the same time. This forces them to
print out help topics in order to follow help topics while using the
program. It is not a design that meets all needs.

Dennis



"Jeffrey Tan[MSFT]" said:
Hi Dennis,

Based on my understanding, you use the .Net HelpProvider class to provide
the help function for your control. You find that the help file was always
on the top of the main Form, you want to suppress this feature.

Actually, this is by the design of HelpProvider class. After show up the
help file window, the main window will intercept the help file window's
message and always keep the help file on the top of the main form.

I have provided a sample to prove this. In the sample, I use Win32 API
SetWindowPos function to make the main Form become the current top most
window of the Windows(through HWND_TOPMOST flag), like this:

private System.Windows.Forms.HelpProvider helpProvider1;
private System.Windows.Forms.TextBox textBox1;
private void Form1_Load(object sender, System.EventArgs e)
{
helpProvider1.HelpNamespace = "mspaint.chm";
helpProvider1.SetShowHelp(this.textBox1, true);
}

[DllImport("user32.dll")]
public static extern int SetWindowPos(IntPtr hwnd,IntPtr
hWndInsertAfter,int x,int y,int cx,int cy,int wFlags);

public IntPtr HWND_TOPMOST =(IntPtr)(-1);
public IntPtr HWND_NOTOPMOST =(IntPtr)(-2);
public int SWP_NOSIZE = 0x1;

private void button1_Click(object sender, System.EventArgs e)
{
SetWindowPos(this.Handle, HWND_TOPMOST, this.Left, this.Top, this.Left+
this.Width, this.Top+ this.Height, SWP_NOSIZE);
}

private void button2_Click(object sender, System.EventArgs e)
{
SetWindowPos(this.Handle, HWND_NOTOPMOST, this.Left, this.Top, this.Left+
this.Width, this.Top+ this.Height, SWP_NOSIZE);
}

The button2 will remove the top-most feature of the main form.

After press F1 in textBox1, the mspaint.chm is showed, then if you press
Button1 to make the main form top-most, you will find the main Form is
really on the top of the mspaint.chm window. But if you drag the main form
and then drop, you will find that the help file will on the top of the
main
form again(Even though the main form is "top-most").

So, you will know that the .Net will re-set the help file to the top of
the
main form, which means that .Net does not recommand you to move the main
form to the top of the help file.

Actually, the main form will intercept the messages of the help files
window, and ensure that if the main form is closed, the help file window
is
also closed. As I think, this is a reasonable design.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi Dennis,

Thanks for your feedback.

Yes, I see your concern. If you still want to change the default design of
HelpProvider, I think you may give up the HelpProvider class and show the
help file youself.

For example, you may use Process class to invoke the .chm file in TextBox's
KeyDown event, like this:

private void textBox1_KeyDown(object sender,
System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyCode ==Keys.F1)
{
System.Diagnostics.Process.Start(@"C:\WINDOWS\Help\mspaint.chm");
}
}

But this can only show the user a simple help file, to provide more control
to the help file, you should use HTML Help API Function: HtmlHelp()

This API will give you a full control over the html file, like keyword,
show up style, etc..

Fore more information, please refer to the child topics of "HTML Help API
Reference":
http://msdn.microsoft.com/library/en-us/htmlhelp/html/vsconApiref.asp

In "HTML Help API Overview" section, you will see that "The help window is
owned by the window you specify. As an owned window, a help window
automatically stays on top of its owner and closes when the owner is
closed.". So if you specify your main form as parent window, you will get
the same effect as HelpProvider. I think you should set the desktop as
parent window of the help file.

To use the Unmanaged HTML Help API in C#, you should do P/invoke, the below
article tells you how to get this done in details:
http://support.microsoft.com/?kbid=317406

To encapsulate your class as the same usage as HelpProvider, you may
implement it as an extend provider, for more information, please refer to:
"Custom Provider Controls"
http://msdn.microsoft.com/msdnmag/issues/03/11/CuttingEdge/

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi Dennis,

Does my reply make sense to you?

If you still have any concern, please feel free to feedback. I will help
you. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top