CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Jul 2002
    Location
    Princeton, NewJersey, US
    Posts
    817

    Controls Buttons

    Hello,
    How do I enable/disable control buttons( minimize, maxmize, 'x') ?

    Is it possible to set some custom tool tips for these buttons?

    Thanks,
    GOOD DAY..!

    NICK.

    E-MAIL : [email protected]

  2. #2
    Join Date
    Mar 2004
    Location
    33°11'18.10"N 96°45'20.28"W
    Posts
    1,808

    Re: Controls Buttons

    1. with the boolean minimize and maximize property on the form.

    2. not out of the box.

  3. #3
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    1,080

    Re: Controls Buttons

    As MadHatter says, The MinimizeBox and MaximizeBox properties of the form control whether the Minimize and Maximize buttons are visible and enabled. Set one or the other to False and the corresponding button is disabled. Set them both to False and they will be removed altogether.

    Note that those buttons correspond to items in the system menu. Those items will also be disabled and removed along with the buttons.

    There is no managed property that does the same for the Close button and menu item though. You can set the ControlBox property to False but then you lose the whole lot. You can use unmanaged code to disabled the Close button and menu item though.

    http://www.vbforums.com/showthread.php?t=351533
    Tutorials: Home & Learn | Start VB.NET | Learn VB.NET | C# Station | GotDotNet | Games in VB.NET 101 Samples: 2002 | 2003 | 2005 | More .NET 2.0 (VB.NET, C#) Articles: VB.NET | C# | ASP.NET | MoreFree Components: WFC | XPCC | ElementsEx | VBPP | Mentalis | ADO.NET/MySQL | VisualStyles | Charting (NPlot, ZedGraph) | iTextSharp (PDF) | SDF (CF) ● Free Literature: VB 2005 (eBook) | VB6 to VB.NET (eBook) | MSDN Magazine (CHM format) ● Bookmarks: MSDN | WinForms .NET | ASP.NET | WinForms FAQ | WebForms FAQ | GotDotNet | Code Project | DevBuzz (CF) ● Code Converter: C#/VB.NET | VB.NET/C# | VS 2005 add-in

  4. #4
    Join Date
    Oct 2007
    Posts
    11

    Re: Controls Buttons

    Hi,

    below is the code I came up with in order to display the
    desired tooltips.


    Regards,

    Matthias.

    Code:
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Windows.Forms;
    using System.Drawing;
    
    
    namespace Whatever
    {
      internal class HitTestForm : Form
      {
        /* constants taken from winuser.h */
        
        /* hit test message id */ 
        const int WM_NCHITTEST   = 0x0084;
        
        /* hit test constants */ 
        const int HTERROR        =   -2;
        const int HTTRANSPARENT  =   -1;
        const int HTNOWHERE      =   0;
        const int HTCLIENT       =   1;
        const int HTCAPTION      =   2;
        const int HTSYSMENU      =   3;
        const int HTGROWBOX      =   4;
        const int HTSIZE         =   HTGROWBOX;
        const int HTMENU         =   5;
        const int HTHSCROLL      =   6;
        const int HTVSCROLL      =   7;
        const int HTMINBUTTON    =   8;
        const int HTMAXBUTTON    =   9;
        const int HTLEFT         =   10;
        const int HTRIGHT        =   11;
        const int HTTOP          =   12;
        const int HTTOPLEFT      =   13;
        const int HTTOPRIGHT     =   14;
        const int HTBOTTOM       =   15;
        const int HTBOTTOMLEFT   =   16;
        const int HTBOTTOMRIGHT  =   17;
        const int HTBORDER       =   18;
        const int HTREDUCE       =   HTMINBUTTON;
        const int HTZOOM         =   HTMAXBUTTON;
        const int HTSIZEFIRST    =   HTLEFT;
        const int HTSIZELAST     =   HTBOTTOMRIGHT;
        const int HTOBJECT       =   19;
        const int HTCLOSE        =   20;
        const int HTHELP         =   21;
        
        ToolTip _ncToolTip = new ToolTip();
        
        protected override void WndProc(ref Message m)
        {
          base.WndProc(ref m);
    
          if(m.Msg == WM_NCHITTEST)
          {
            string text;
            int lParam  = m.LParam.ToInt32();
            int res     = m.Result.ToInt32();
            int x       = lParam & 0xffff;
            int y       = (int)((lParam & 0xffff0000) >> 16);
            Point p     = new Point(x,y);
    
            p = PointToClient(p);
    
            switch(res)
            {
              case HTMAXBUTTON:
                text = "Maximize button";
              break;
              case HTMINBUTTON:
                text = "Minimize button";
              break;
              case HTCLOSE:
                text = "Close button";
              break;
              case HTSYSMENU:
                text = "System menu";
              break;
              case HTCAPTION:
                text = "Titlebar";
              break;
              default:
                text = "";
              break;
            }
    
              _ncToolTip.Show(text,this, p);
    
          }
    
        }
    
      }
    }

  5. #5
    Join Date
    Jul 2002
    Location
    Princeton, NewJersey, US
    Posts
    817

    Re: Controls Buttons

    Thanks for your reply.

    I think Show() is not a member of ToolTip Class. Thats what its complaining.

    _ncToolTip.Show(text,this, p);

    As per your sample code, how do I display the tool tips.?


    Thanks again..
    GOOD DAY..!

    NICK.

    E-MAIL : [email protected]

  6. #6
    Join Date
    Jan 2007
    Posts
    491

    Re: Controls Buttons

    About your first quesion... You can make all the control buttons disappear, but your can disable only the MaximizeBox and the MinimizeBox.
    If you'll want to hide the control buttons, do something like that (from inside your form):
    Code:
    this.ControlBox = false;
    I'm not quite sure it's ControlBox. Maybe it's ControlsBox or something like that.
    Anyway... you can find it easily with the properties list in the disign mode.

    You can also create your own class for form, which willl inherit from the System.Windows.Forms.Form class and change it as you need if you know how to.

    HTH, Tal.

  7. #7
    Join Date
    Oct 2007
    Posts
    11

    Re: Controls Buttons

    Hi,


    well, I compiled and tested the above code, so obviously there must be
    a Show() method.

    According to the documentation, thw Show() method is supported since .Net 2.0 .
    If you are required to work with an older version of the framework, you'll
    have to adjust the code.


    Regards,

    Matthias.

  8. #8
    Join Date
    Jul 2002
    Location
    Princeton, NewJersey, US
    Posts
    817

    Re: Controls Buttons

    You're Right.. I am working with .NET 1.1 and it doesn't support Show() method.
    GOOD DAY..!

    NICK.

    E-MAIL : [email protected]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured