window| Program | tips
1. An application can only be opened once by the user
Process Mobj_pro =process.getcurrentprocess ();
Process[] Mobj_prolist=process.getprocessesbyname (Mobj_pro. ProcessName);
if (mobj_prolist.length>1)
{
MessageBox.Show ("The current application is open!") "," System hints ", MessageBoxButtons.OK, Messageboxicon.exclamation, Messageboxdefaultbutton.button1);
Return
}
2. Only one child window opens under a frame window
Customeradd Pobj_customeradd;
Form pobj_customeradd_return=checkisexit ("Customeradd");
if (pobj_customeradd_return==null)
{
Pobj_customeradd=new Customeradd ();
Opensheet (Pobj_customeradd);
}
Else
{
Opensheet ((Customeradd) pobj_customeradd_return);
}
void Opensheet (Form pobj_form)
{
Pobj_form. Mdiparent=this;
Pobj_form. Show ();
}
/**////<summary>
To determine whether a window exists
</summary>
<param name= "ps_windowname" > Window name </param>
<returns> existence returns the instance of this window does not exist return null</returns>
Form checkisexit (String ps_windowname)
{
for (int i=0;i<this. mdichildren.length;i++)
{
if (this. Mdichildren[i]. Name==ps_windowname)
{
return this. Mdichildren[i];
}
}
return null;
}
3. pop-up window to show the gradient effect
Add a Timer control to the page Fadetimer,interval set to 50
Class has an instance variable of
Private m_showing=true;
Write in Form_Load:
Opacity = 0.0;
Activate ();
Refresh ();
Fadetimer.start ();
Refresh (); Write in the Tick event of the timer control:
if (m_showing)
{
Double d = 1000.0/fadetimer.interval/100.0;
if (Opacity + D >= 1.0)
{
Opacity = 1.0;
Fadetimer.stop ();
}
Else
{
Opacity = D;
}
}
Else
{
Double d = 1000.0/fadetimer.interval/100.0;
if (opacity-d <= 0.0)
{
Opacity = 0.0;
Fadetimer.stop ();
}
Else
{
Opacity-= D;
}
}
4. In the control textbox, the function of pressing ENTER is equivalent to the TAB key
public class Ostextbox:textbox
{
Public Ostextbox ()
{
}
BOOL Mb_iskeyenter=true;
[
Category ("Data"),
DefaultValue (True),
Mergableproperty (False)
]
public bool Iskeyenter
{
Get
{
return mb_iskeyenter;
}
Set
{
Mb_iskeyenter=value;
}
}
protected override void OnKeyPress (KeyPressEventArgs e)
{
Base. OnKeyPress (e);
if (Mb_iskeyenter)
{
if (E.keychar = = (char) keys.enter)
{
Sendkeys.send ("{tab}");
}
}
}
}