自定義訊息對話方塊基於Dialog

2021-04-20 07:19:14 字數 1737 閱讀 2995

#region 訊息對話方塊

public class messageboxex : extform

this.topmost = true;

this.formborderstyle = formborderstyle.none;

this.visible = false;

this.width = screen.primaryscreen.bounds.width;

this.height = 100;

this.top = 0;

timer = new timer();

timer.interval = 20;

timer.tick += new eventhandler(timer_tick);

this.dialogresult = dialogresult.cancel;

}void timer_tick(object sender, eventargs e)

}internal override void changeorientation()

protected override void onpaint(painteventargs e)

else

_caption = language.s_messagebox_title;

}e.graphics.fillrectangle(new solidbrush(color.blue), rectcaption);

e.graphics.drawstring(_caption, font, new solidbrush(color.white), rectcaption, format);

if (_text != null && _text.trim().length > 0)

}if(_height < 0)

else if (this.controls.count == 1)

}base.onpaint(e);

}public dialogresult show(string text)

finally

}public dialogresult show(string text, string caption)

public dialogresult show(string text, string caption, messageboxbuttons buttons, messageboxdefaultbutton defaultbutton)

else

this.controls.add(btnok);

this.controls.add(btncancel);

if (defaultbutton == messageboxdefaultbutton.button2)

btncancel.focus();

else

btnok.focus();

}else

//啟動時鐘

timer.enabled = true;

//顯示視窗

tryfinally

}void btnok_click(object sender, eventargs e)

void btncancel_click(object sender, eventargs e)

void btnyes_click(object sender, eventargs e)

void btnno_click(object sender, eventargs e)

}#endregion

自定義對話方塊

public void normaldialog 對話方塊的 private dialoginte ce.onclicklistener mydialoglistener new dialoginte ce.onclicklistener alertdialog.builder對話方塊沒有類似fin...

全域性對話方塊透明對話方塊自定義對話方塊

為什麼會寫這玩意呢,對,是因為無聊,不過全域性對話方塊在專案中還是經常用到的,主要是記得新增許可權就好了,可能對剛入門的學弟學妹們可能有幫助 許可權 簡單的 快 public static void dialog context context,string dstr window window d...

android 自定義對話方塊

說到對話方塊你肯定會想到alertdialog.builder。當然這次不是用alertdialog.builder來實現的!而是dialog類 alertdialog.builder提供的方法有 settitle 給對話方塊設定title.seticon 給對話方塊設定圖示。setmessage ...