VS2003。NET    WIN CE 平台   
用户登陆成功后,登陆窗体关闭,主窗体运行,但是主窗体是最小化的,怎么才能让主窗体运行是最大化的?
主窗体的WindowState设置成Maximized也不行啊?
登陆窗体
private void Btn_OK_Click(object sender, System.EventArgs e)
{
this.DialogResult = DialogResult.OK;
}主窗体
static void Main()
{
LoginForm lf = new LoginForm();
lf.ShowDialog();
if(lf.DialogResult ==DialogResult.OK )
{
Application.Run(new MainForm(lf.GetID,lf.GetName));
}

解决方案 »

  1.   

    直接修改窗体的Size把。好像那个属性是没用。跟os版本有关。
      

  2.   

    没明白楼上的意思,我的Size已经设置了自己的大小
      

  3.   

    楼主是不是没表达清楚?你这样的代码我也一开始这么写,因为pc上这样写是对的,但wince上呢,不能这样,需要把
    LoginForm lf = new LoginForm();
    lf.ShowDialog();
    写到主窗体的Load事件里。否则主窗体将不会得到焦点,不论是你如何操作。但应该不是最小化吧。
      

  4.   

    LoginForm lf = new LoginForm();
    lf.ShowDialog();
    写到主窗体的Load事件里    这个方法不行,程序直接就退出了
      

  5.   

    楼主能否不要这么冲,总说我不行??????是你不行还是我不行啊。贴全给你看。
    //一下是Form2,也就是弹出来的第一个窗体
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;namespace JustTest
    {
    /// <summary>
    /// Form2 的摘要说明。
    /// </summary>
    public class Form2 : System.Windows.Forms.Form
    {
    private System.Windows.Forms.Button button1;

    public Form2()
    {
    //
    // Windows 窗体设计器支持所必需的
    //
    InitializeComponent(); //
    // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
    //
    } /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    base.Dispose( disposing );
    } #region Windows 窗体设计器生成的代码
    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    this.button1 = new System.Windows.Forms.Button();
    // 
    // button1
    // 
    this.button1.Location = new System.Drawing.Point(68, 48);
    this.button1.Size = new System.Drawing.Size(68, 24);
    this.button1.Text = "button1";
    this.button1.Click += new System.EventHandler(this.button1_Click);
    // 
    // Form2
    // 
    this.ClientSize = new System.Drawing.Size(202, 123);
    this.Controls.Add(this.button1);
    this.Text = "Form2";
    this.Closed += new System.EventHandler(this.Form2_Closed); }
    #endregion private bool blResult = false;
    private void button1_Click(object sender, System.EventArgs e)
    {
    blResult = true;
    } private void Form2_Closed(object sender, System.EventArgs e)
    {
    this.DialogResult = blResult?DialogResult.OK:DialogResult.Cancel;
    }
    }
    }
      

  6.   

    //以下是form1,作为主窗体using System;
    using System.Drawing;
    using System.Collections;
    using System.Windows.Forms;
    using System.Data;namespace JustTest
    {
    /// <summary>
    /// Form1 的摘要说明。
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
    public Form1()
    {
    //
    // Windows 窗体设计器支持所必需的
    //
    InitializeComponent(); //
    // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
    //
    }
    /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    base.Dispose( disposing );
    }
    #region Windows 窗体设计器生成的代码
    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    // 
    // Form1
    // 
    this.ClientSize = new System.Drawing.Size(266, 163);
    this.Text = "Form1";
    this.Load += new System.EventHandler(this.Form1_Load); }
    #endregion /// <summary>
    /// 应用程序的主入口点。
    /// </summary> static void Main() 
    {
    Application.Run(new Form1());
    } private void Form1_Load(object sender, System.EventArgs e)
    {
    Form2 frm = new Form2();
    if(frm.ShowDialog()!=DialogResult.OK)
    {
    Application.Exit();
    }
    }
    }
    }
      

  7.   

    using System;
    using System.Windows.Forms;namespace SmartDeviceApplication1
    {
    /// <summary>
    /// Summary description for main.
    /// </summary>
    public class main
    {
    /// <summary>
    /// the main entry point of the application
    /// </summary>
    static void Main()
    {
     
    Application.Run(new MainForm ());
     
    }
    }
    }
    主窗体:
    private void MainForm_Load(object sender, System.EventArgs e)
    {
    dialog d = new dialog();
    DialogResult dr = d.ShowDialog();
    if(d.DialogResult == DialogResult.OK)
    {
                                     //这里就是你MainForm load的时候要做的事。
    }
    } private void button1_Click(object sender, System.EventArgs e)
    {
    this.DialogResult = DialogResult.OK;
    }登陆窗体
    private void Btn_OK_Click(object sender, System.EventArgs e)
    {
    this.DialogResult = DialogResult.OK;
    }如wuyazhe(我的宝贝叫阿刺)缩说的。
      

  8.   

    这里的思路跟你原来的有点不一样。你的代码上的是先弹出登陆的,再进主窗体,但是可能在WinCE中不支持这种用发,或者说支持的不好。后一种是直接弹出主窗体。在主窗体前面ShowDialog一个登陆窗体。实践上这时候,主窗体已经载入,等登陆OK后,登陆的关闭,主窗体就显示出来了。