做一个启动时无焦点的窗体来显示信息就可以了。可以参考如下: public partial class Form1 : Form { public Form1() { InitializeComponent(); } protected override bool ShowWithoutActivation { get { return true; } } protected override void OnLoad(EventArgs e) { base.OnLoad(e); Rectangle rect = Screen.FromControl(this).WorkingArea; this.StartPosition = FormStartPosition.Manual; this.Location = new Point(rect.Right - this.Width, rect.Bottom - this.Height); } } 显示窗体:
baidu上搜索msn提示框就会有一大推的代码!
ajax右下角弹出框角本//定义XMLHttp实例 var xmlHttp; function createXMLHttpRequest(){ //开始初始化XMLHttpRequest对象 if(window.ActiveXObject){ //IE浏览器 xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }else if(window.XMLHttpRequest){ //Mozilla浏览器 xmlHttp = new XMLHttpRequest(); } if(xmlHttp){ //设置请求地址 xmlHttp.open("GET","message.do?cmd=get",true); xmlHttp.onreadystatechange=setState;//设置回调函数 xmlHttp.send(null); } } //回调函数 function setState(){ if(xmlHttp.readyState == 4){ if(xmlHttp.status == 200){ parseResults(xmlHttp.responseXML) } } } /*处理XML*/ function parseResults(xmlDOM) { try{ var root = xmlDOM.documentElement; var info = root.getElementsByTagName('message'); var out = ""; var message = null; var current = null; for(var i=0;i<info.length;i++){ message = info[i]; id = message.getElementsByTagName("id")[0].firstChild.data; title = message.getElementsByTagName("title")[0].firstChild.data; outout=out+(i+1)+"."+"<a style=\"font-size:12px; color: #6D93C8; face: Tahoma\" title='内容提要:\n" +title +"\n时间:" +title +"'"+" href=# >" +title +"</a><BR>"; } popmsg("<BR>"+out); }catch(exception){ // alert("出错了!"); } }
/*右下角提示框*/ var oPopup = window.createPopup(); var popTop=50; function popshow(){ oPopup.show(screen.width-250,screen.height-popTop,241,172); } function pophide(){ oPopup.hide(); } function popmsg(msgstr){
{
public Form1()
{
InitializeComponent();
}
protected override bool ShowWithoutActivation
{
get
{
return true;
}
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
Rectangle rect = Screen.FromControl(this).WorkingArea;
this.StartPosition = FormStartPosition.Manual;
this.Location = new Point(rect.Right - this.Width, rect.Bottom - this.Height);
}
}
显示窗体:
var xmlHttp;
function createXMLHttpRequest(){
//开始初始化XMLHttpRequest对象
if(window.ActiveXObject){
//IE浏览器
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}else if(window.XMLHttpRequest){
//Mozilla浏览器
xmlHttp = new XMLHttpRequest();
}
if(xmlHttp){
//设置请求地址
xmlHttp.open("GET","message.do?cmd=get",true);
xmlHttp.onreadystatechange=setState;//设置回调函数
xmlHttp.send(null);
}
}
//回调函数
function setState(){
if(xmlHttp.readyState == 4){
if(xmlHttp.status == 200){
parseResults(xmlHttp.responseXML)
}
}
}
/*处理XML*/
function parseResults(xmlDOM) {
try{
var root = xmlDOM.documentElement;
var info = root.getElementsByTagName('message');
var out = "";
var message = null;
var current = null;
for(var i=0;i<info.length;i++){
message = info[i];
id = message.getElementsByTagName("id")[0].firstChild.data;
title = message.getElementsByTagName("title")[0].firstChild.data;
outout=out+(i+1)+"."+"<a style=\"font-size:12px; color: #6D93C8; face: Tahoma\" title='内容提要:\n"
+title
+"\n时间:"
+title
+"'"+" href=# >"
+title
+"</a><BR>";
}
popmsg("<BR>"+out);
}catch(exception){
// alert("出错了!");
}
}
/*右下角提示框*/
var oPopup = window.createPopup();
var popTop=50;
function popshow(){
oPopup.show(screen.width-250,screen.height-popTop,241,172);
}
function pophide(){
oPopup.hide();
}
function popmsg(msgstr){
var winstr="<table valign=\"top\" style=\"border: 1 solid #6D93C8\" width=\"241\" height=\"172\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" >";
winstr+="<tr><td bgcolor=\"#BCCCDF\" onClick=\"parent.pophide();\" valign=\"top\" align=\"center\" height=\"20\" style=\"font-size:14px; color: #6D93C8; face: Tahoma;filter:Blur(add=1,direction=45,strength=8) \">你有新短消息:</td></tr><tr><td valign=\"top\" align=\"center\"><table valign=\"top\" width=\"90%\" height=\"110\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
winstr+="<tr><td valign=\"top\" style=\"font-size:12px; color: #6D93C8; face: Tahoma\">"+msgstr+"</td></tr></table></td></tr></table>";
oPopup.document.body.innerHTML = winstr;
popshow();
setInterval('window.focus()',0); //让IE重获取焦点
}
/*提示间隔时间*/
var secs=5;//第一次提示时间秒
function checkServer(secs){
for(i=1;i<=secs;i++) {
window.setTimeout("update(" + i + ")", i * 1000);
}
}
function update(num) {
if(num == secs) {
createXMLHttpRequest();
secs=1*60;//提示时间秒
for(i=1;i<=secs;i++) {
window.setTimeout("update(" + i + ")", i * 1000);
}
}
else {
printnr = secs-num;
}
}
checkServer(secs);
<head>
<title>HTMLPage1</title>
<meta name=vs_defaultClientScript content=JavaScript>
<meta name=vs_targetSchema content=http://schemas.microsoft.com/intellisense/ie5>
<meta name=GENERATOR content=Microsoft Visual Studio .NET 7.1>
<meta name=ProgId content=VisualStudio.HTML>
<meta name=Originator content=Microsoft Visual Studio .NET 7.1>
</head>
<script language =javascript>
var titlePopup
var len;
function InitMsgBox()
{ len = 0;
titlePopup=window.createPopup();
var titlePopupBody = titlePopup.document.body;
titlePopupBody.style.border =solid black 1px;
var titleContent = ;
titleContent = titleContent + <table cellPadding=5 bgcolor=#65c1ff width=100% height=100% border=0 cellspacing=0 cellpadding=0>;
titleContent = titleContent + <tr><td align=center><font size = 2>新闻提醒</font></td></tr>;
titleContent = titleContent + <tr><td><font size = 2>内容</td></font></tr>;
titleContent = titleContent + <tr><td><font size = 2>内容</td></font></tr>;
titleContent = titleContent + <tr><td><font size = 2>日期</td></font></tr>;
titleContent = titleContent + </table>;
titlePopupBody.innerHTML = titleContent;
ShowMsgBox();
}
function MsgBox()
{
len += 4;
if (len > 110)
else
{//170固定了新闻提醒框的宽度
titlePopup.show(document.body.clientWidth - 170, document.body.clientHeight - len, 170, len, top.document.body);
}
}
var tID
function ShowMsgBox()
{
tID = window.setInterval(MsgBox(),15);
}
</script>
<body MS_POSITIONING=GridLayout>
<INPUT onclick=InitMsgBox() id=Button1 style=Z-INDEX: 101; LEFT: 296px; POSITION: absolute; TOP: 344px type=button
value=Button name=Button1>
</body>
</html>