Solved

using Help.ShowHelp ... how to maximize and or close help window??

Posted on 2006-11-13
6
1,043 Views
Last Modified: 2012-06-21
I am opening Help using C# built in help, such as
Help.ShowHelp(this, "help.chm");

Is there a way to mazimize the help window that opens, and how do I close it?
0
Comment
Question by:shmitnols
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
6 Comments
 
LVL 15

Expert Comment

by:ozymandias
ID: 17932715
I don't think there's an easy way because the method does not return a window handle.
You could use the findwindow api asing the lpClassName of "HH Parent" which is what the help uses.
once you have the window handle you should be able to maximise and/or close it.
0
 
LVL 15

Expert Comment

by:ozymandias
ID: 17932741
DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

0
 
LVL 15

Expert Comment

by:ozymandias
ID: 17932789
Sorry forgot the other two :

[DllImport("user32.dll")]
static extern bool SetWindowPlacement(IntPtr hWnd,   [In] ref WINDOWPLACEMENT lpwndpl);

Can be used to maximise window.

[DllImport("user32.dll")]
static extern bool CloseWindow(IntPtr hWnd);


Can be used to close window.


0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 15

Expert Comment

by:ozymandias
ID: 17933089
Fisrt you need to define these :

      [StructLayout(LayoutKind.Sequential)]
      public struct WINDOWPLACEMENT {
            public int length;
            public int flags;
            public int showCmd;
            public POINT ptMinPosition;
            public POINT ptMaxPosition;
            public RECT rcNormalPosition;
      }

      [StructLayout( LayoutKind.Sequential )]
      public struct POINT {
            public int X;
            public int Y;

            public POINT( int x, int y ) {
                  this.X = x;
                  this.Y = y;
            }

            public static implicit operator System.Drawing.Point( POINT p ) {
                  return new System.Drawing.Point( p.X,  p.Y );
            }

            public static implicit operator POINT( System.Drawing.Point p ) {
                  return new POINT( p.X, p.Y );
            }
      }

      [Serializable, StructLayout(LayoutKind.Sequential)]
      public struct RECT {
            public int Left;
            public int Top;
            public int Right;
            public int Bottom;

            public RECT(int left_, int top_, int right_, int bottom_) {
                  Left = left_;
                  Top = top_;
                  Right = right_;
                  Bottom = bottom_;
            }

            public int Height { get { return Bottom - Top; } }
            public int Width { get { return Right - Left; } }
            public Size Size { get { return new Size(Width, Height); } }

            public Point Location { get { return new Point(Left, Top); } }

            public Rectangle ToRectangle() {
          return Rectangle.FromLTRB(Left, Top, Right, Bottom); }

            public static RECT FromRectangle(Rectangle rectangle) {
                  return new RECT(rectangle.Left, rectangle.Top, rectangle.Right, rectangle.Bottom);
            }

            public override int GetHashCode() {
                  return Left ^ ((Top << 13) | (Top >> 0x13))
                        ^ ((Width << 0x1a) | (Width >> 6))
                        ^ ((Height << 7) | (Height >> 0x19));
            }

            #region Operator overloads

            public static implicit operator Rectangle( RECT rect ) {
                  return Rectangle.FromLTRB(rect.Left, rect.Top, rect.Right, rect.Bottom);
            }

            public static implicit operator RECT( Rectangle rect ) {
                  return new RECT(rect.Left, rect.Top, rect.Right, rect.Bottom);
            }

            #endregion
      }

      public enum SHOWWINDOW : uint {
            SW_HIDE         = 0,
            SW_SHOWNORMAL       = 1,
            SW_NORMAL       = 1,
            SW_SHOWMINIMIZED    = 2,
            SW_SHOWMAXIMIZED    = 3,
            SW_MAXIMIZE     = 3,
            SW_SHOWNOACTIVATE   = 4,
            SW_SHOW         = 5,
            SW_MINIMIZE     = 6,
            SW_SHOWMINNOACTIVE  = 7,
            SW_SHOWNA       = 8,
            SW_RESTORE      = 9,
            SW_SHOWDEFAULT      = 10,
            SW_FORCEMINIMIZE    = 11,
            SW_MAX          = 11,
      }
0
 
LVL 15

Expert Comment

by:ozymandias
ID: 17933100
Finally these three functions :

            private void ShowHelp_Click(object sender, System.EventArgs e) {
                  Help.ShowHelp(this, @"path_to_your_chm_file");
            }

            private void CloseHelp_Click(object sender, System.EventArgs e) {
                  IntPtr hWnd = FindWindow("HH Parent", null);
                  if (hWnd.ToInt32() != 0){
                        CloseWindow(hWnd);
                  }
            }

            private void MaxHelp_Click(object sender, System.EventArgs e) {
                  IntPtr hWnd = FindWindow("HH Parent", null);
                  if (hWnd.ToInt32() != 0){
                        WINDOWPLACEMENT WP = new WINDOWPLACEMENT();
                        WP.length = Marshal.SizeOf(typeof(WINDOWPLACEMENT));
                        WP.showCmd = (int)SHOWWINDOW.SW_MAXIMIZE;
                        SetWindowPlacement(hWnd, ref WP);
                  }
            }
0
 
LVL 15

Accepted Solution

by:
ozymandias earned 500 total points
ID: 17933118
Sorry, the middle step was of course to add these but for some reason it didn't post :

            [DllImport("user32.dll", SetLastError = true)]
            static extern IntPtr FindWindow(string lpClassName, string lpWindowName);


            [DllImport("user32.dll")]
            static extern bool SetWindowPlacement(IntPtr hWnd,   [In] ref WINDOWPLACEMENT lpwndpl);


            [DllImport("user32.dll")]
            static extern bool CloseWindow(IntPtr hWnd);
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses

623 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