惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
MyScale Blog
MyScale Blog
F
Fortinet All Blogs
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Stack Overflow Blog
Stack Overflow Blog
MongoDB | Blog
MongoDB | Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Blog — PlanetScale
Blog — PlanetScale
Jina AI
Jina AI
T
Tenable Blog
S
Securelist
S
Schneier on Security
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tor Project blog
C
Cisco Blogs
The Hacker News
The Hacker News
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
O
OpenAI News
V
Vulnerabilities – Threatpost
V
Visual Studio Blog
Security Latest
Security Latest
T
Threatpost
博客园 - 三生石上(FineUI控件)
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
H
Hacker News: Front Page
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
IT之家
IT之家
I
InfoQ
博客园_首页
Apple Machine Learning Research
Apple Machine Learning Research
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
A
About on SuperTechFans
Know Your Adversary
Know Your Adversary
Martin Fowler
Martin Fowler
Forbes - Security
Forbes - Security
F
Full Disclosure
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Google DeepMind News
Google DeepMind News
Hacker News - Newest:
Hacker News - Newest: "LLM"
P
Privacy International News Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
C
CERT Recently Published Vulnerability Notes
N
News and Events Feed by Topic
V
V2EX
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Threat Research - Cisco Blogs
S
Secure Thoughts
量子位
博客园 - 【当耐特】

博客园 - 无之无

别了博客园! 即将没落的博客园?!!! SQL里ROWCOUNT的使用 阿里云的背后故事(希望别被关了) LINQ:是BUG还是~~~ 集合代理类的实现 WPF对绑定到数据的树初始化选择项 SilverLight中的数据绑定 [请教]关于 .NET 应用的几个问题请教!!!( 如何解决 自定义控件 构造被设计器删除? 遭遇品牌电脑的尴尬 面对VS2005,我遇到了BUG? FOREACH的遍历 该死的微软,该死的文档,该死的ExecuteCommand 怪异的Windows Form事件 MDI窗体关闭问题解决一例 .Net再发行包与强名称 托管与非托管的混合编程问题 关于WMI
Windows Form的初始化大小记录处理问题
无之无 · 2005-11-10 · via 博客园 - 无之无

要让系统记录在应用退出的时候主窗体的大小和状态,采取了WebMatrix中的实现技术:在窗体构造的时候从“记忆”中更新窗体的大小和状态,在窗体关闭的时候,把窗体的大小刷新到“记忆”中:

加载“记忆”:

   try
   
{
    
//设置窗体初始位置与大小状态
    string strInfo = this._applicationIdentity.GetSetting("WindowMaximized");
    
if ((strInfo != null&& strInfo.Equals("true"))
    
{
     
base.WindowState = FormWindowState.Maximized;
    }

    
else
    
{
     
base.WindowState = FormWindowState.Normal;
    }

    
//设置窗体大小区域
    strInfo = this._applicationIdentity.GetSetting("WindowLeft"false);
    
if ((strInfo != null&& (strInfo.Length != 0))
    
{
     
int iLeft = Convert.ToInt32(strInfo);
     strInfo 
= this._applicationIdentity.GetSetting("WindowTop"false);
     
int iTop = Convert.ToInt32(strInfo);
     strInfo 
= this._applicationIdentity.GetSetting("WindowWidth"false);
     
int iWidth = Convert.ToInt32(strInfo);
     strInfo 
= this._applicationIdentity.GetSetting("WindowHeight"false);
     
int iHeight = Convert.ToInt32(strInfo);
     
base.Bounds = new Rectangle(iLeft, iTop, iWidth, iHeight);
    }

    
else
    
{
     
base.Bounds = Screen.FromPoint(Cursor.Position).WorkingArea;
    }

    
base.StartPosition = FormStartPosition.Manual;
   }

   
catch (Exception err)
   
{
    MessageBox.Show(
this, err.Message);
   }



保存“记忆”:

  try
   
{
    
//保存窗体位置等状态信息
    if (base.WindowState == FormWindowState.Maximized)
    
{
     
this._applicationIdentity.SetSetting("WindowMaximized""true");
    }

    
else if (base.WindowState != FormWindowState.Minimized)
    
{
     
this._applicationIdentity.SetSetting("WindowMaximized"null);
     Rectangle rectangle1 
= base.Bounds;
     
this._applicationIdentity.SetSetting("WindowLeft", Convert.ToString(rectangle1.Left));
     
this._applicationIdentity.SetSetting("WindowTop", Convert.ToString(rectangle1.Top));
     
this._applicationIdentity.SetSetting("WindowWidth", Convert.ToString(rectangle1.Width));
     
this._applicationIdentity.SetSetting("WindowHeight", Convert.ToString(rectangle1.Height));
    }

   }

   
catch (Exception)
   
{
   }


现在发现一个问题:

我想把这两段代码写在基类中,结果出现问题:窗体在正常状态下的大小不会在加载时有效应用,分析原因就是基类的构造先执行而派生类的后执行,在设计派生类的时候,派生类在设计时有修改窗体尺寸的代码。

如果在派生类中把修改窗体大小的代码删除(在InitializeComponent中)是不现实的,于是想到“一招”:在窗体HandleCreated的时候进行处理,呵呵,正常状态的大小是解决了,但窗体再也没有办法在初始化的时候设置为最大化了,永远都是正常状态。

又一次狂晕!!