书上例子代码有这个属性,说是不让对话框显示在任务栏,但是编译不过去,也没查到有这个属性
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Forms;
using System.Drawing;
class SimpleDialog : Form
{
string strDisplay = "";
public static void Main()
{
Application.Run(new SimpleDialog());
}
public SimpleDialog()
{
Text = "Simple Dialog";
Menu = new MainMenu();
Menu.MenuItems.Add("&Dialog", new EventHandler(MenuOnClick));
}
void MenuOnClick(object obj, EventArgs ea)
{
SimpleDialogBox dlg = new SimpleDialogBox();
dlg.ShowDialog();
strDisplay = "Dialog box terminatated with " + dlg.DialogResult + "!";
Invalidate();
}
protected override void OnPaint(PaintEventArgs pea)
{
Graphics grfx = pea.Graphics;
grfx.DrawString(strDisplay, Font, new SolidBrush(ForeColor), 0, 0);
}
}
class SimpleDialogBox : Form
{
public SimpleDialogBox()
{
Text = "Simple Dialog boxes";
//standard stuff for dialog boxes
FormBorderStyle = FormBorderStyle.FixedDialog;
ControlBox = false;
MaximizeBox = false;
MinimizeBox = false;
//ShowlnTaskbar = false;
//creae ok button
Button btn = new Button();
btn.Parent = this;
btn.Text = "ok";
btn.Location = new Point(50, 50);
btn.Size = new Size(10 * Font.Height, 2 * Font.Height);
btn.Click += new EventHandler(ButtonOkOnClick);
//create cancel button
btn = new Button();
btn.Parent = this;
btn.Text = "cancel";
btn.Location = new Point(50, 100);
btn.Size = new Size(10 * Font.Height, 2 * Font.Height);
btn.Click+=new EventHandler(ButtonCancelOnClick);
}
void ButtonOkOnClick(object obj, EventArgs ea)
{
this.DialogResult = DialogResult.OK;
}
void ButtonCancelOnClick(object obj, EventArgs ea)
{
DialogResult = DialogResult.Cancel;
}
}
解决方案
20
l和I