Why is it that ShowHelp causes the Help file to show up as some sort of
child to the main application? (I've tried this with MS help files and it
does the same, it isn't my help file per-say) You can't click on the
application without bring the help file to the front, you can't alt+Tab
between the help file and the application etc.

This is highly not a good thing. It should be a separate application for all
intents and purposes.

Anyone have any ideas?

Thanks,
James Hancock

Re: ShowHelp() and weird window behaviour by Tim

Tim
Tue Dec 16 15:04:13 CST 2003

This is a multi-part message in MIME format.

------=_NextPart_000_1111_01C3C3EE.4001D300
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I haven't really played around too much with the Help class, but the way =
that I've been showing a help file (in chm format) is to just run it in =
a separate process using the Process class. You can even take care of =
finding and showing the help process if the user already has the help =
file open. Code below:

[DllImport("User32.dll", EntryPoint=3D"SetForegroundWindow")]
private static extern bool SetForegroundWindow(IntPtr hWnd);

[DllImport("User32.dll")]
private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

private const int SW_RESTORE =3D 9;

-------------------------------------------------------------------------=
-----------

// private member to the main form.
private Process help;

// place this code in a method to handle showing the help.
if (help =3D=3D null)
{
help =3D new Process();
}
else
{
if (!help.HasExited)
{
ShowWindow(help.MainWindowHandle, SW_RESTORE);
SetForegroundWindow(help.MainWindowHandle);
return;
}
}
string helpFile =3D @"C:\Program Files\My App\Help\MyHelp.chm";
try
{
ProcessStartInfo processstartinfo =3D new ProcessStartInfo(helpFile);
help.StartInfo =3D processstartinfo;
help.Start();
}
catch (Exception ex)
{
help.Dispose();
help =3D null;
MessageBox.Show("An error was encountered while opening the help file =
\"" + helpFile + "\".\nAdditional Info: " + ex.Message, "Help Error", =
MessageBoxButtons.OK, MessageBoxIcon.Error);
}

HTH
--=20
Tim Wilson
.Net Compact Framework MVP

"James Hancock" <jamie@darwinconsulting.com> wrote in message =
news:u2cBPXBxDHA.3140@TK2MSFTNGP11.phx.gbl...
> Why is it that ShowHelp causes the Help file to show up as some sort =
of
> child to the main application? (I've tried this with MS help files and =
it
> does the same, it isn't my help file per-say) You can't click on the
> application without bring the help file to the front, you can't =
alt+Tab
> between the help file and the application etc.
>=20
> This is highly not a good thing. It should be a separate application =
for all
> intents and purposes.
>=20
> Anyone have any ideas?
>=20
> Thanks,
> James Hancock
>=20
>
------=_NextPart_000_1111_01C3C3EE.4001D300
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1276" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff background=3D"">
<DIV><FONT face=3DArial size=3D2>I haven't really played around too much =
with the=20
Help class, but the way that I've been showing a help file (in chm =
format) is to=20
just run it in a separate process using the Process class. You can even =
take=20
care of finding and showing the help process if the user already has the =
help=20
file open. Code below:<BR><BR>[DllImport("User32.dll",=20
EntryPoint=3D"SetForegroundWindow")]<BR>private static extern bool=20
SetForegroundWindow(IntPtr hWnd);</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT><BR><FONT face=3DArial=20
size=3D2>[DllImport("User32.dll")]<BR>private static extern bool =
ShowWindow(IntPtr=20
hWnd, int nCmdShow);</FONT></DIV><FONT face=3DArial =
size=3D2></FONT><FONT face=3DArial=20
size=3D2></FONT>
<DIV><BR><FONT face=3DArial size=3D2>private const int SW_RESTORE =3D=20
9;<BR></FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>----------------------------------------------------------------=
--------------------</FONT><FONT=20
face=3DArial size=3D2></DIV>
<DIV>&nbsp;</DIV>
<DIV>// private member to the main form.<BR>private Process =
help;<BR></DIV>
<DIV>// place this code in a method to handle showing the help.<BR>if =
(help =3D=3D=20
null)<BR>{<BR>&nbsp; help =3D new Process();<BR>}<BR>else<BR>{<BR>&nbsp; =
if=20
(!help.HasExited)<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp;=20
ShowWindow(help.MainWindowHandle, SW_RESTORE);<BR>&nbsp;&nbsp;&nbsp;=20
SetForegroundWindow(help.MainWindowHandle);<BR>&nbsp;&nbsp;&nbsp;=20
return;<BR>&nbsp; }<BR>}</DIV>
<DIV>string helpFile =3D @"C:\Program Files\My =
App\Help\MyHelp.chm";</DIV>
<DIV>try</DIV>
<DIV>{<BR>&nbsp; ProcessStartInfo processstartinfo =3D new=20
ProcessStartInfo(helpFile);<BR>&nbsp; help.StartInfo =3D=20
processstartinfo;<BR>&nbsp; help.Start();<BR>}<BR>catch (Exception=20
ex)<BR>{<BR>&nbsp; help.Dispose();<BR>&nbsp; help =3D null;<BR>&nbsp;=20
MessageBox.Show("An error was encountered while opening the help file =
\"" +=20
helpFile + "\".\nAdditional Info: " + ex.Message, "Help Error",=20
MessageBoxButtons.OK, MessageBoxIcon.Error);<BR>}<BR></DIV>
<DIV>HTH<BR>-- <BR>Tim Wilson<BR>.Net Compact Framework MVP</DIV>
<DIV><BR>"James Hancock" &lt;jamie@darwinconsulting.com&gt; wrote in =
message=20
news:u2cBPXBxDHA.3140@TK2MSFTNGP11.phx.gbl...<BR>&gt; Why is it that =
ShowHelp=20
causes the Help file to show up as some sort of<BR>&gt; child to the =
main=20
application? (I've tried this with MS help files and it<BR>&gt; does the =
same,=20
it isn't my help file per-say)&nbsp; You can't click on the<BR>&gt; =
application=20
without bring the help file to the front, you can't alt+Tab<BR>&gt; =
between the=20
help file and the application etc.<BR>&gt; <BR>&gt; This is highly not a =
good=20
thing. It should be a separate application for all<BR>&gt; intents and=20
purposes.<BR>&gt; <BR>&gt; Anyone have any ideas?<BR>&gt; <BR>&gt;=20
Thanks,<BR>&gt; James Hancock<BR>&gt; <BR>&gt; =
</FONT></DIV></BODY></HTML>

------=_NextPart_000_1111_01C3C3EE.4001D300--


Re: ShowHelp() and weird window behaviour by James

James
Tue Dec 16 16:15:37 CST 2003

This is a multi-part message in MIME format.

------=_NextPart_000_003E_01C3C3F8.38E84E00
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Ugh. OK. That's what I was afraid of.

Anyone have any ideas how to make the ShowHelp function work right?

James Hancock
"Tim Wilson [MVP]" <Tim_Wilson@[DieSpamDie]Rogers.com> wrote in =
message news:eDz%23ufBxDHA.1396@TK2MSFTNGP10.phx.gbl...
I haven't really played around too much with the Help class, but the =
way that I've been showing a help file (in chm format) is to just run it =
in a separate process using the Process class. You can even take care of =
finding and showing the help process if the user already has the help =
file open. Code below:

[DllImport("User32.dll", EntryPoint=3D"SetForegroundWindow")]
private static extern bool SetForegroundWindow(IntPtr hWnd);

[DllImport("User32.dll")]
private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

private const int SW_RESTORE =3D 9;

=
-------------------------------------------------------------------------=
-----------

// private member to the main form.
private Process help;

// place this code in a method to handle showing the help.
if (help =3D=3D null)
{
help =3D new Process();
}
else
{
if (!help.HasExited)
{
ShowWindow(help.MainWindowHandle, SW_RESTORE);
SetForegroundWindow(help.MainWindowHandle);
return;
}
}
string helpFile =3D @"C:\Program Files\My App\Help\MyHelp.chm";
try
{
ProcessStartInfo processstartinfo =3D new =
ProcessStartInfo(helpFile);
help.StartInfo =3D processstartinfo;
help.Start();
}
catch (Exception ex)
{
help.Dispose();
help =3D null;
MessageBox.Show("An error was encountered while opening the help =
file \"" + helpFile + "\".\nAdditional Info: " + ex.Message, "Help =
Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

HTH
--=20
Tim Wilson
.Net Compact Framework MVP

"James Hancock" <jamie@darwinconsulting.com> wrote in message =
news:u2cBPXBxDHA.3140@TK2MSFTNGP11.phx.gbl...
> Why is it that ShowHelp causes the Help file to show up as some sort =
of
> child to the main application? (I've tried this with MS help files =
and it
> does the same, it isn't my help file per-say) You can't click on =
the
> application without bring the help file to the front, you can't =
alt+Tab
> between the help file and the application etc.
>=20
> This is highly not a good thing. It should be a separate application =
for all
> intents and purposes.
>=20
> Anyone have any ideas?
>=20
> Thanks,
> James Hancock
>=20
>
------=_NextPart_000_003E_01C3C3F8.38E84E00
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1276" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff background=3D"">
<DIV><FONT face=3DArial size=3D2>Ugh. OK.&nbsp; That's what I was afraid =

of.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Anyone have any ideas how to make the =
ShowHelp=20
function work right?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>James Hancock</FONT></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Tim Wilson [MVP]" &lt;<A=20
=
href=3D"mailto:Tim_Wilson@[DieSpamDie]Rogers.com">Tim_Wilson@[DieSpamDie]=
Rogers.com</A>&gt;=20
wrote in message <A=20
=
href=3D"news:eDz%23ufBxDHA.1396@TK2MSFTNGP10.phx.gbl">news:eDz%23ufBxDHA.=
1396@TK2MSFTNGP10.phx.gbl</A>...</DIV>
<DIV><FONT face=3DArial size=3D2>I haven't really played around too =
much with the=20
Help class, but the way that I've been showing a help file (in chm =
format) is=20
to just run it in a separate process using the Process class. You can =
even=20
take care of finding and showing the help process if the user already =
has the=20
help file open. Code below:<BR><BR>[DllImport("User32.dll",=20
EntryPoint=3D"SetForegroundWindow")]<BR>private static extern bool=20
SetForegroundWindow(IntPtr hWnd);</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT><BR><FONT face=3DArial=20
size=3D2>[DllImport("User32.dll")]<BR>private static extern bool=20
ShowWindow(IntPtr hWnd, int nCmdShow);</FONT></DIV><FONT face=3DArial=20
size=3D2></FONT><FONT face=3DArial size=3D2></FONT>
<DIV><BR><FONT face=3DArial size=3D2>private const int SW_RESTORE =3D=20
9;<BR></FONT></DIV>
<DIV><FONT face=3DArial=20
=
size=3D2>----------------------------------------------------------------=
--------------------</FONT><FONT=20
face=3DArial size=3D2></DIV>
<DIV>&nbsp;</DIV>
<DIV>// private member to the main form.<BR>private Process =
help;<BR></DIV>
<DIV>// place this code in a method to handle showing the help.<BR>if =
(help =3D=3D=20
null)<BR>{<BR>&nbsp; help =3D new =
Process();<BR>}<BR>else<BR>{<BR>&nbsp; if=20
(!help.HasExited)<BR>&nbsp; {<BR>&nbsp;&nbsp;&nbsp;=20
ShowWindow(help.MainWindowHandle, SW_RESTORE);<BR>&nbsp;&nbsp;&nbsp;=20
SetForegroundWindow(help.MainWindowHandle);<BR>&nbsp;&nbsp;&nbsp;=20
return;<BR>&nbsp; }<BR>}</DIV>
<DIV>string helpFile =3D @"C:\Program Files\My =
App\Help\MyHelp.chm";</DIV>
<DIV>try</DIV>
<DIV>{<BR>&nbsp; ProcessStartInfo processstartinfo =3D new=20
ProcessStartInfo(helpFile);<BR>&nbsp; help.StartInfo =3D=20
processstartinfo;<BR>&nbsp; help.Start();<BR>}<BR>catch (Exception=20
ex)<BR>{<BR>&nbsp; help.Dispose();<BR>&nbsp; help =3D null;<BR>&nbsp;=20
MessageBox.Show("An error was encountered while opening the help file =
\"" +=20
helpFile + "\".\nAdditional Info: " + ex.Message, "Help Error",=20
MessageBoxButtons.OK, MessageBoxIcon.Error);<BR>}<BR></DIV>
<DIV>HTH<BR>-- <BR>Tim Wilson<BR>.Net Compact Framework MVP</DIV>
<DIV><BR>"James Hancock" &lt;jamie@darwinconsulting.com&gt; wrote in =
message=20
news:u2cBPXBxDHA.3140@TK2MSFTNGP11.phx.gbl...<BR>&gt; Why is it that =
ShowHelp=20
causes the Help file to show up as some sort of<BR>&gt; child to the =
main=20
application? (I've tried this with MS help files and it<BR>&gt; does =
the same,=20
it isn't my help file per-say)&nbsp; You can't click on the<BR>&gt;=20
application without bring the help file to the front, you can't=20
alt+Tab<BR>&gt; between the help file and the application etc.<BR>&gt; =

<BR>&gt; This is highly not a good thing. It should be a separate =
application=20
for all<BR>&gt; intents and purposes.<BR>&gt; <BR>&gt; Anyone have any =

ideas?<BR>&gt; <BR>&gt; Thanks,<BR>&gt; James Hancock<BR>&gt; <BR>&gt; =

</FONT></DIV></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_003E_01C3C3F8.38E84E00--


Re: ShowHelp() and weird window behaviour by Rick

Rick
Tue Dec 16 17:22:38 CST 2003

James,

Unfortunately this is the way the Help engine works. This happens not only
in .Net but in Win32 apps as well. The help file will pop up on top only the
first time it's loaded. After that it's activated in the current stack
location. I consider that a bug in the Help APIs. It behaves kind of similar
to the way IE behaves when you load things into the same window...

I think the approach that Tim showed (or something similar using just
FindWindow and SetForegroundWindow) is about the only way to make sure your
help pops ontop.

To make things worse the .Net Help Provider provides no hooks of any kind to
extend it either...

Help is one of the things that Microsoft is really bad with and this Help
API stinks and has been stale for 5+ years now with not even a clear vision
of how that's going to be improved in the next Windows version (all we got
was a horrible presentation at PDC)...

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/wwhelp/
http://www.west-wind.com/blog/
----------------------------------
Making waves on the Web


"James Hancock" <jamie@darwinconsulting.com> wrote in message
news:u2cBPXBxDHA.3140@TK2MSFTNGP11.phx.gbl...
> Why is it that ShowHelp causes the Help file to show up as some sort of
> child to the main application? (I've tried this with MS help files and it
> does the same, it isn't my help file per-say) You can't click on the
> application without bring the help file to the front, you can't alt+Tab
> between the help file and the application etc.
>
> This is highly not a good thing. It should be a separate application for
all
> intents and purposes.
>
> Anyone have any ideas?
>
> Thanks,
> James Hancock
>
>