国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > 綜合 > 正文

C#開發(fā)windows程序技巧

2024-07-21 02:26:53
字體:
供稿:網(wǎng)友

1.一個應用程序只能被用戶打開一次
 process mobj_pro =process.getcurrentprocess();
            process[] mobj_prolist=process.getprocessesbyname(mobj_pro.processname);
            if(mobj_prolist.length>1)
            {
                messagebox.show("當前的應用程序已打開!", "系統(tǒng)提示", messageboxbuttons.ok, messageboxicon.exclamation, messageboxdefaultbutton.button1);
                return;
            }
2.一個框架窗口下只打開一個子窗口
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>
        /// 判斷窗口是否存在
        /// </summary>
        /// <param name="ps_windowname">窗口的名稱</param>
        /// <returns>存在返回此窗口的實例 不存在返回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.彈出式窗口顯示漸變效果
在頁面上添加一個timer控件fadetimer,interval設為50
類的實例變量為
private m_showing=true;
在form_load中寫:
opacity = 0.0;
            activate();
            refresh();
            fadetimer.start();
            refresh();    在timer控件的tick事件中寫:

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.在控件textbox中實現(xiàn)按回車鍵相當于tab鍵的作用
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}");
                }
            }
        }

    }

  
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 叙永县| 平舆县| 靖远县| 平江县| 稷山县| 卫辉市| 铜山县| 青铜峡市| 深泽县| 类乌齐县| 浏阳市| 林西县| 太仆寺旗| 乐山市| 进贤县| 岢岚县| 洛宁县| 酒泉市| 永济市| 延川县| 衡山县| 余姚市| 馆陶县| 泸定县| 乌兰浩特市| 虎林市| 祥云县| 徐州市| 交口县| 环江| 莫力| 通榆县| 湘乡市| 慈溪市| 襄汾县| 衡阳市| 彭山县| 贡嘎县| 甘谷县| 开江县| 习水县|