Tuesday, December 26, 2006

WinForm判断窗口是如何关闭的

Private Sub Form1_Closing()Sub Form1_Closing(ByVal sender As Object,ByVal e As System.ComponentModel.CancelEventArgs) _
Handles MyBase.Closing
Dim O As System.Diagnostics.StackTrace = _
New System.Diagnostics.StackTrace(True)
Dim F As System.Diagnostics.StackFrame

F = O.GetFrame(7)

Select Case F.GetMethod.Name.ToString
Case "SendMessage"
MsgBox("你用me.close()来关的吧.")
Case "CallWindowProc"
MsgBox("你点X按钮了吧")
'在这里加你的代码
Case "DispatchMessageW"
MsgBox("你用任务管理器来关的吧")
Case Else
MsgBox("不晓得你是怎么关的")
End Select
End Sub

验证身份证校验码

很早以前(2003)年的时候做的一个小东西了,验证身份证校验码的程序。
具体的身份证校验码算法就不在这里贴了,放狗搜一下就出来了。
下载地址

Saturday, December 23, 2006

一个可以锁定表头和表尾的style

这里可见效果
表头的行应用locked

tr.locked

{

position:relative;

top:
expression(document.getElementById("divgrid").scrollTop); /*IE5+
only*/

}



表尾的行应用lockedfoot

tr.lockedfoot

{

position:relative;
top:expression(
document.getElementById("divgrid").scrollHeight<=document.getElementById("divgrid").clientHeight)?
0
:
document.getElementById("divgrid").scrollTop-
(document.getElementById("divgrid").scrollHeight-document.getElementById("divgrid").clientHeight));


/*IE5+ only*/

}



这个用法只有IE5+支持,在Firefox
2.0里面没有用,表头和表尾还在老地方。

例子如下:



<head>

</head>

<body>

<div id="divgrid" style="width: 420px;height:
200px;overflow: auto;scrollbar-base-color:#ffeaff;">

<table class="Grid" cellspacing="0" rules="all"
UseAccessibleHeader="True" border="1" id="DataGrid1"
style="border-collapse:collapse;word-wrap: normal;;">

<tr style="background-color: navy;color:
white;border: 2px solid silver;position:relative;top:
expression(document.getElementById('divgrid').scrollTop-2);">


<td>Name</td><td>Address</td><td>City</td><td>State</td><td>Zip</td><td>Random
Babble</td>

</tr><tr>

<td
nowrap="nowrap">Head</td><td
nowrap="nowrap">Head</td><td
nowrap="nowrap">Head</td><td
nowrap="nowrap">Head</td><td
nowrap="nowrap">Head</td><td
nowrap="nowrap">Head</td>

</tr><tr>

<td
nowrap="nowrap">1</td><td nowrap="nowrap">ma la ge
bi</td><td nowrap="nowrap">圣诞节</td><td
nowrap="nowrap">shanghai</td><td
nowrap="nowrap">43230</td><td
nowrap="nowrap">adfkasdfasdfsdfa sadfa dfa aksdjfkasajskdfjaf
kasdjfakfjdfkjaklsdf adksfjkalsfd</td>

</tr><tr>

<td
nowrap="nowrap">2</td><td nowrap="nowrap">ma la ge
bi</td><td nowrap="nowrap">圣诞节</td><td
nowrap="nowrap">shanghai</td><td
nowrap="nowrap">43230</td><td
nowrap="nowrap">adfkasdfasdfsdfa sadfa dfa aksdjfkasajskdfjaf
kasdjfakfjdfkjaklsdf adksfjkalsfd</td>

</tr><tr>

<td
nowrap="nowrap">3</td><td nowrap="nowrap">ma la ge
bi</td><td nowrap="nowrap">圣诞节</td><td
nowrap="nowrap">shanghai</td><td
nowrap="nowrap">43230</td><td
nowrap="nowrap">adfkasdfasdfsdfa sadfa dfa aksdjfkasajskdfjaf
kasdjfakfjdfkjaklsdf adksfjkalsfd</td>

</tr><tr>

<td
nowrap="nowrap">4</td><td nowrap="nowrap">ma la ge
bi</td><td nowrap="nowrap">圣诞节</td><td
nowrap="nowrap">shanghai</td><td
nowrap="nowrap">43230</td><td
nowrap="nowrap">adfkasdfasdfsdfa sadfa dfa aksdjfkasajskdfjaf
kasdjfakfjdfkjaklsdf adksfjkalsfd</td>

</tr><tr>

<td
nowrap="nowrap">5</td><td nowrap="nowrap">ma la ge
bi</td><td nowrap="nowrap">圣诞节</td><td
nowrap="nowrap">shanghai</td><td
nowrap="nowrap">43230</td><td
nowrap="nowrap">adfkasdfasdfsdfa sadfa dfa aksdjfkasajskdfjaf
kasdjfakfjdfkjaklsdf adksfjkalsfd</td>

</tr><tr>

<td
nowrap="nowrap">6</td><td nowrap="nowrap">ma la ge
bi</td><td nowrap="nowrap">圣诞节</td><td
nowrap="nowrap">shanghai</td><td
nowrap="nowrap">43230</td><td
nowrap="nowrap">adfkasdfasdfsdfa sadfa dfa aksdjfkasajskdfjaf
kasdjfakfjdfkjaklsdf adksfjkalsfd</td>

</tr><tr>

<td
nowrap="nowrap">7</td><td nowrap="nowrap">ma la ge
bi</td><td nowrap="nowrap">圣诞节</td><td
nowrap="nowrap">shanghai</td><td
nowrap="nowrap">43230</td><td
nowrap="nowrap">adfkasdfasdfsdfa sadfa dfa aksdjfkasajskdfjaf
kasdjfakfjdfkjaklsdf adksfjkalsfd</td>

</tr><tr>

<td
nowrap="nowrap">8</td><td nowrap="nowrap">ma la ge
bi</td><td nowrap="nowrap">圣诞节</td><td
nowrap="nowrap">shanghai</td><td
nowrap="nowrap">43230</td><td
nowrap="nowrap">adfkasdfasdfsdfa sadfa dfa aksdjfkasajskdfjaf
kasdjfakfjdfkjaklsdf adksfjkalsfd</td>

</tr><tr>

<td
nowrap="nowrap">9</td><td nowrap="nowrap">ma la ge
bi</td><td nowrap="nowrap">圣诞节</td><td
nowrap="nowrap">shanghai</td><td
nowrap="nowrap">43230</td><td
nowrap="nowrap">adfkasdfasdfsdfa sadfa dfa aksdjfkasajskdfjaf
kasdjfakfjdfkjaklsdf adksfjkalsfd</td>

</tr><tr>

<td
nowrap="nowrap">10</td><td nowrap="nowrap">ma la ge
bi</td><td nowrap="nowrap">圣诞节</td><td
nowrap="nowrap">shanghai</td><td
nowrap="nowrap">43230</td><td
nowrap="nowrap">adfkasdfasdfsdfa sadfa dfa aksdjfkasajskdfjaf
kasdjfakfjdfkjaklsdf adksfjkalsfd</td>

</tr><tr>

<td
nowrap="nowrap">11</td><td nowrap="nowrap">ma la ge
bi</td><td nowrap="nowrap">圣诞节</td><td
nowrap="nowrap">shanghai</td><td
nowrap="nowrap">43230</td><td
nowrap="nowrap">adfkasdfasdfsdfa sadfa dfa aksdjfkasajskdfjaf
kasdjfakfjdfkjaklsdf adksfjkalsfd</td>

</tr><tr style="background-color:
navy; color: white;border: 2px solid
silver;position:relative;top:
expression((document.getElementById('divgrid').scrollHeight <=
document.getElementById('divgrid').clientHeight)?0:document.getElementById('divgrid').scrollTop-(document.getElementById('divgrid').scrollHeight-document.getElementById('divgrid').clientHeight));">


<td>Foot</td><td>Foot</td><td>Foot</td><td>Foot</td><td>Foot</td><td> </td>


</tr>

</table>

</div>

</body>



Friday, December 01, 2006

啤酒许可证




今天玩MSN
Plus
的一个脚本rssreader的时候,发现了这个有趣的许可证协议----"THE
BEER-WARE LICENSE"



在那个
autoupdate.js
开头是这么写的

/*

*
----------------------------------------------------------------------------


* "THE BEER-WARE LICENSE" (Revision 42):

* <darktempler@gmail.com> wrote this file. As long as you
retain this notice you

* can do whatever you want with this stuff. If we meet some day,
and you think

* this stuff is worth it, you can buy me a beer in return Matt
Labrum (-dt-)

*
----------------------------------------------------------------------------


*/

意思就是说只要保留这个Notice你就可以对这些代码任意玩,如果你觉得这个软件有用,以后遇到作者了可以给他买杯啤酒作为回报
:-)

谈论 自动变换MSN昵称



我想做dll扩展它的功能呢,比如通过RSS读取新闻用来做我的MyPersonalMessage。
有没有人告诉我哪里有Windows下处理RSS的类库啊?最好是傻瓜型的,给个RSS地址就能拿出所有title和链接的那种。



另记JScript的文档:
http://msdn2.microsoft.com/zh-cn/library/72bd815a(VS.80).aspx



引用




自动变换MSN昵称



首先你的MSN一定要是8.0的。

然后去下载Messenger Plus 4.0(http://www.msgpluslive.com.tw/


安装好以后多出来一个“Plus”的菜单。进入“偏好设定--〉脚本”


这里就可以自己写JavaScript来实现自动变换MSN昵称的功能了。


下面是我实现的一个倒计时提醒器,提醒自己离某一个纪念日还有多少天。以及每隔1分钟自动更换自己的头像。






var picIndex = 1;

function OnEvent_Initialize(MessengerStart)

{

var myTimer1 = "myTimer1";

MsgPlus.AddTimer("myTimer1", 100);

}



function OnEvent_Uninitialize(MessengerExit)

{

}



function OnEvent_Timer(myTimer1)

{

var nowDate = new Date(); //现在时刻

var endDate = new Date(2007, 1 - 1, 1); //元旦

var interval = endDate .getTime() - nowDate .getTime();

var leftTime = interval / 1000 / 3600 / 24;

var leftHour = interval / 1000 / 3600 % 24;

var leftTimeString = String(leftTime);

var leftHourString = String(leftHour);

var leftDays = leftTimeString.substr(0, 2);

//去掉小数点

if (leftDays.indexOf(".") == 1) {

leftDays = leftDays.substr(0, 1);

}



leftHourString = leftHourString.substr(0, 5);



var Message = leftDays + "天" + leftHourString + "小时" +
"LEFT"



Message = MsgPlus.RemoveFormatCodes(Message);

Messenger.MyPersonalMessage = Message;



//循环显示图片

var picDir = "C:\\Documents and
Settings\\Administrator\\デスクトップ\\MyPicture\\";

Messenger.MyDisplayPicture = picDir + picIndex + ".jpg";



var maxPicNo = 16; // 图片数量

picIndex ++;

if (picIndex > maxPicNo ) {

picIndex = 1;

}



MsgPlus.AddTimer("myTimer1", 60000); //每60秒刷新一次

}





更多关于Messenger Plus所支持的脚本的信息,可参见
http://www.msgpluslive.com.tw/scripts/