码迷,mamicode.com
首页 > Windows程序 > 详细

WinCE\Window Mobile程序桌面化总结

时间:2015-02-11 18:33:17      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:

 

1、系统API处理

 

将桌面、移动API分开处理

 

2、一份代码,两个工程,分别编译

 

添加已有文件时,使用添加链接,而不是添加附本

 

3、桌面窗体出现位置不规律,样式不统一问题

 

首先,在窗体类成员加入两个成员变量

        publicForm parentForm;    

        privatebool inited;       

 

然后添加如下代码

 

        public ctor(Form parent)

            : this()

        {

            parentForm = parent;

        }

 

        protectedoverridevoid OnClosing(CancelEventArgs e)

        {

            if (parentForm != null)

            {

                parentForm.Location = this.Location;

                parentForm.Show();

            }

            base.OnClosing(e);

        }

 

        protectedoverridevoid OnActivated(EventArgs e)

        {

            if (!inited)

            {

                inited = true;

                parentForm.Hide();

            }

            base.OnActivated(e);

        }

 

        protectedoverridevoid OnLoad(EventArgs e)

        {

            if (parentForm != null)

            {

                if (Environment.OSVersion.Platform == PlatformID.WinCE)

                {

                    this.FormBorderStyle = FormBorderStyle.None;

                    this.ControlBox = false;

                }

                else

                {

                    bool tmp = this.Visible;

                    this.Visible = false;

                    this.FormBorderStyle = FormBorderStyle.FixedSingle;

                    this.ControlBox = true;

                    this.MaximizeBox = false;

                    this.MinimizeBox = true;

                    this.Visible = tmp;

                }

                this.Location = parentForm.Location;

                this.Size = parentForm.Size;

            }

            base.OnLoad(e);

        }

 

 

使用时,使用窗体类带有Form parent参数的构造

WinCE\Window Mobile程序桌面化总结

标签:

原文地址:http://www.cnblogs.com/hbhbice/p/4286643.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!