Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2006-11-13
6
Medium Priority
?
1,076 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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

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.

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…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Integration Management Part 2
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

971 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