Click to See Complete Forum and Search --> : Controls Buttons
newnick
October 10th, 2007, 04:17 PM
Hello,
How do I enable/disable control buttons( minimize, maxmize, 'x') ?
Is it possible to set some custom tool tips for these buttons?
Thanks,
MadHatter
October 10th, 2007, 05:08 PM
1. with the boolean minimize and maximize property on the form.
2. not out of the box.
jmcilhinney
October 11th, 2007, 02:01 AM
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
MatthiasD
October 11th, 2007, 02:08 AM
Hi,
below is the code I came up with in order to display the
desired tooltips.
Regards,
Matthias.
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);
}
}
}
}
newnick
October 12th, 2007, 10:29 AM
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..
Talikag
October 12th, 2007, 10:53 AM
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):
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.
MatthiasD
October 15th, 2007, 01:23 AM
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.
newnick
October 15th, 2007, 12:38 PM
You're Right.. I am working with .NET 1.1 and it doesn't support Show() method.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.