停留在原地

山人不念经

 

2007年8月1日

删除Cookie无效的办法

发现针对Cookie的删除操作都会失效,不知道是否ASP.NET没有支持对Cookie的删除呢?

解决方案:

Cookie.Expires = DateTime.Now.AddYears(-100);

让Cookie过期,倒减一百年。

不知为何ASP.NET的Response.Cookies.Remove方法无效?

posted @ 2007-08-01 19:58 伤口 阅读(177) | 评论 (0)编辑

2007年7月30日

如何有效的过滤SQL注入

SQL注入一直是网站开发者头疼的事情,不管代码写的再精辟,过滤的再安全,还是要动用大量的人力、时间。如果不写一个字母呢?

的确可以做到,这种方法无论ASP, ASP.NET 或和其它开发系统也可以做到,就是采用参数执行SQL语句,而不是构造SQL语句。

posted @ 2007-07-30 00:18 伤口 阅读(89) | 评论 (0)编辑

2007年7月21日

如何用flash创建全屏播放影片

如何用flash创建全屏播放影片

这段时间在做flash开发,遇到全屏播放的问题。找遍了国内大小网站都没找到相应解决方法,最后只好求助于google(en),在一个名为Julian Pscheid的外国友人的blog上找到这篇文章,故翻译过来为国人享用。

【原文地址】Julian Pscheid[http://julian.empiregn.com/2007/2/22/How-to-create-true-fullscreen-movies-with-Flash ]

【译文如下】PPP[http://madinsect.blogbus.com]

Flash Player 9.0.28版本是第一个支持真正意义全屏播放的flash player版本,不幸的是这完美的特性在Flash 9出来之前都没有得到完全的支持,不过只需要细微的修改,您就可以在Flash 8上使用这个特性了。下面简单的指南将帮助您用Flash8实现正真的全屏。

在开始之前,请确定您正在使用的flash player是最新的9.0.28版,先前版本的Flash Player 9 (9,0,16,0 &9,0,20,0)还不支持这一特性。你需要升级至9.0.28.0, 他也是第一个可以在Vista上运行的版本。

这一性特性的关键之处在于使用到ActionScriptSatge对象的一个新属性'displayState',这一属性有两个值:

'fullScreen': 设置舞台全屏播放。

'normal': 默认值。

在您开始使用该属性之前,您还需要在您的Flash 8的安装文件中做一些修改,在你的安装环境下找到下列文件

Flash 8enFirst RunClassesFP8Stage.as

打开文件,把这条语句加进去:static var displayState:String;如下所示:

intrinsic class Stage

{

static var displayState:String;

static var align:String;

static var height:Number;

static var scaleMode:String;

static var showMenu:Boolean;

static var width:Number;

static function addListener(listener:Object):Void;

static function removeListener(listener:Object):Boolean;

}

现在你可以在flash中设置displayState这个属性的值了。出于安全考虑,flash之允许displayState这个属性在与用户交互的过程中被设置,意思就是:你不能让影片一全屏模式打开。你需要添加一个按钮或其他元件来捕获用户的操作以便把影片切换至全屏状态。在我的例子里,我就简单的创建了一个按钮。

toggle_btn.onRelease = function(){

if(Stage.displayState == "fullScreen"){

Stage.displayState = "normal";

}

else{

Stage.displayState = "fullScreen"

}

}

If you want to detect that fullscreen mode has been entered or exited, you can use a new event listener function, onFullScreen:

如果你想要获取全屏模式是否被激活或者退出,你可以使用一个新的事件监听程序,onFullScreen:

EventListener = new Object;

EventListener.onFullScreen = function( bFull:Boolean ){

// change to fullscreen mode has been detected

if(bFull){

v_mc.vtxt = "You are in Full Screen Mode";

}

else{

v_mc.vtxt = "Everything is back to normal";

}

}

Stage.addListener( EventListener );

最后还有一个需要注意的地方,另一个安全的限制需要在EMBED标签中添加一个型的属性“allowFullScreen”,你要设置他为true:

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"

codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"

width="320" height="240" id="fullscreen_flash" align="middle">

<param name="movie" value="fullscreen_flash.swf" />

<param name="quality" value="high" />

<param name="allowFullScreen" value="true" />

<param name="bgcolor" value="#ffffff" />

<embed src="fullscreen_flash.swf" allowfullscreen="true" quality="high"

bgcolor="#ffffff" width="320" height="240" name="fullscreen_flash" align="middle"

type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />

</object>

Update: UFO does support the new attribute in version 3.21. Be sure to use the set the lowercase variable allowfullscreen:"true". SWFObject also supports it via so.addParam("allowFullScreen", "true").

点击下载

posted @ 2007-07-21 18:49 伤口 阅读(524) | 评论 (1)编辑

气愤:.NET 2.0 无法在继承窗体中修改新增的所有2.0控件。

昨晚一个项目用到继承窗体,基窗体中用到DataGridView控件,并且该控件的Modifier属性为Protected,在特定的几个派生窗体中需要修改该控件的几个属性,然而IDE总是给我灰色的无法编辑状态。 一番查找得知,MS根本没有对这些控件做派生编辑开发,MS的回答是将会在以后的版本中提供这种功能。 不成熟的开发环境,真是害人不浅。。。

posted @ 2007-07-21 10:57 伤口 阅读(92) | 评论 (0)编辑

2007年7月12日

清理MS SQL日志和压缩数据库

DUMP TRANSACTION DATABASE_NAME WITH NO_LOG DBCC SHRINKDATABASE (DATABASE_NAME) 指定数据库名称就可以了,第一句是清理日志,第二句压缩数据库。

posted @ 2007-07-12 14:13 伤口 阅读(68) | 评论 (0)编辑

2007年6月19日

NTFS文件系统 + IIS + ASP.NET 搭建安全访问环境

这是基础知识的整合,原因在昨晚搭建WIN2003 .NET WEB服务器遇到的。 首先在某文件系统为NTFS的X盘下建立网站目录,设置权限仅为管理员和SYSTEM访问,指定IIS的虚拟目录到目标物理路径。 通过IE访问该网站发现出现网站服务不可用的错误,从事件管理器获知如下信息: 未能初始化 AppDomain:/LM/W3SVC/1/Root Exception: System.IO.FileLoadException Message: 未能加载文件或程序集“System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”或它的某一个依赖项。拒绝访问。 稍微有基础的人一看就知道是某帐户被文章目录访问拒绝,需要添加该帐户,但具体应该添加哪一个帐户成了问题。搜遍很多文章都只是说添加ASP.NET帐户,始终无法解决问题。 最终还是在GOOGLE的知识海洋里面搜索到了要添加IIS_WPG帐户,对于这个帐户微软的解释是:该帐户是IIS进程组,只在IIS6.0可用。

posted @ 2007-06-19 11:13 伤口 阅读(154) | 评论 (0)编辑

2007年5月17日

可以包含在文档体

原以为<script>标记在w3c标准下是不能被包含在文档体<body>内的,刚刚做了一份测试html文档,提交到w3c在线验证系统,却成功通过了验证。

posted @ 2007-05-17 08:53 伤口 阅读(22) | 评论 (1)编辑

2007年5月14日

使用CSS创建可改变大小的图像

图片也可以通过CTRL+滚轮移动而改变大小,你知道吗?

<div class="resize2"><img src="image.jpg" alt="" /></div>

对应的CSS:

.resize2 {
  border
: 3px double #333;
  float
: left;
  height
: 12em;
  margin
: .2em 1em 1em 0;
  overflow
: hidden;
  width
: 12em;
}


.resize2 img 
{
  margin
: -220px 0 0 -210px;
  padding
: 6em 0 0 6em;
}

posted @ 2007-05-14 13:13 伤口 阅读(168) | 评论 (0)编辑

javascript分页

<xml id="users"> 
<userGroup> 
  
<user id="1"> 
    
<userid>user 1</userid> 
    
<name>name 1</name> 
  
</user> 
  
<user id="2"> 
    
<userid>user 2</userid> 
    
<name>name 2</name> 
  
</user> 
  
<user id="3"> 
    
<userid>user 3</userid> 
    
<name>name 3</name> 
  
</user> 
  
<user id="4"> 
    
<userid>user 4</userid> 
    
<name>name 4</name> 
  
</user> 
  
<user id="5"> 
    
<userid>user 5</userid> 
    
<name>name 5</name> 
  
</user> 
  
<user id="6"> 
    
<userid>user 6</userid> 
    
<name>name 7</name> 
  
</user> 
  
<user id="7"> 
    
<userid>user 7</userid> 
    
<name>name 7</name> 
  
</user> 
  
<user id="8"> 
    
<userid>user 8</userid> 
    
<name>name 8</name> 
  
</user> 
  
<user id="9"> 
    
<userid>user 9</userid> 
    
<name>name 9</name> 
  
</user> 
</userGroup> 
</xml> 
<table id="datatable" datasrc="#users" DATAPAGESIZE="3" width="400" border="1"> 
<thead> 
    
<th>数据 userid</th> 
    
<th>数据 name</th> 
    
<th>属性 id</th> 
</thead> 
<tr> 
    
<td><span datafld="userid"></span></td> 
    
<td><span datafld="name"></span></td> 
    
<td><span datafld="id"></span></td> 
</tr> 
</table> 
<button onclick="document.all.datatable.previousPage()">Previous Page</button> 
<button onclick="document.all.datatable.nextPage()">Next Page</button>
直接复制成.htm就行

如果你的xml在外部,则要引用xml

如( 

<xml id="users" src="user.xml"></xml>
如果你要添加超链接在(td)文本中,则使用


<datafld="useid" onmouseover="if(this.changged ==  null) { this.href ='###.aspx?'+this.href; this.changed=true}"><span datafld="name"></sapn></a>

posted @ 2007-05-14 13:12 伤口 阅读(25) | 评论 (0)编辑

2007年5月8日

Customizing a Control's Appearance Using Custom Draw

Custom Draw is not a common control; it is a service that many common controls provide. Custom Draw services allow an application greater flexibility in customizing a control's appearance. Your application can harness custom draw notifications to easily change the font used to display items or manually draw an item without having to do a full owner draw.

About Custom Draw

This section contains general information about custom draw functionality and provides a conceptual overview of how an application can support custom draw.

Currently, the following controls support custom draw functionality:

  • Header controls
  • List-view controls
  • Rebar controls
  • Toolbar controls
  • ToolTip controls
  • Trackbar controls
  • Tree-view controls
Note   Custom draw is implemented in version 4.70 and later of Comctl32.dll for all the controls previously listed. Custom draw is also supported for button controls if you are running Windows XP and have an application manifest to ensure that Comctl32.dll version 6 is available.

About Custom Draw Notification Messages

All common controls that support custom draw send NM_CUSTOMDRAW notification messages at specific points during drawing operations. These notifications describe drawing operations that apply to the entire control as well as drawing operations specific to items within the control. Like many notification messages, NM_CUSTOMDRAW notifications are sent as WM_NOTIFY messages.

The lParam parameter of a custom draw notification message will be the address of an NMCUSTOMDRAW structure or a control-specific structure that contains an NMCUSTOMDRAW structure as its first member. The following table illustrates the relationship between the controls and the structures they use.

Structure Used by
NMCUSTOMDRAW Rebar, trackbar, and header controls
NMLVCUSTOMDRAW List-view controls
NMTBCUSTOMDRAW Toolbar controls
NMTTCUSTOMDRAW ToolTip controls
NMTVCUSTOMDRAW Tree-view controls

Paint Cycles, Drawing Stages, and Notification Messages

Like all Microsoft Windows applications, common controls periodically paint and erase themselves based on messages received from the system or other applications. The process of a control painting or erasing itself is called a paint cycle. Controls that support custom draw send NM_CUSTOMDRAW notification messages periodically through each paint cycle. This notification message is accompanied by an NMCUSTOMDRAW structure or another structure that contains an NMCUSTOMDRAW structure as its first member.

One piece of information that the NMCUSTOMDRAW structure contains is the current stage of the paint cycle. This is referred to as the draw stage and is represented by the value in the structure's dwDrawStage member. A control informs its parent about four basic draw stages. These basic, or global, draw stages are represented in the structure by the following flag values (defined in Commctrl.h).

Global draw stage values Description
CDDS_PREPAINT Before the paint cycle begins.
CDDS_POSTPAINT After the paint cycle is complete.
CDDS_PREERASE Before the erase cycle begins.
CDDS_POSTERASE After the erase cycle is complete.

Each of the preceding values can be combined with the CDDS_ITEM flag to specify draw stages specific to items. For convenience, Commctrl.h contains the following item-specific values.

Item-specific draw stage values Description
CDDS_ITEMPREPAINT Before an item is drawn.
CDDS_ITEMPOSTPAINT After an item has been drawn.
CDDS_ITEMPREERASE Before an item is erased.
CDDS_ITEMPOSTERASE After an item has been erased.
CDDS_SUBITEM Shell and Common Controls Versions 4.71. Flag combined with CDDS_ITEMPREPAINT or CDDS_ITEMPOSTPAINT if a subitem is being drawn. This will only be set if CDRF_NOTIFYITEMDRAW is returned from CDDS_PREPAINT.

Your application must process the NM_CUSTOMDRAW notification message and then return a specific value that informs the control what it must do. See the following sections for more information about these return values.

Taking Advantage of Custom Draw Services

The key to harnessing custom draw functionality is in responding to the NM_CUSTOMDRAW notification messages that a control sends. The return values your application sends in response to these notifications determine the control's behavior for that paint cycle.

This section contains information about how your application can use NM_CUSTOMDRAW notification return values to determine the control's behavior.

Details are broken into the following topics:

Responding to the prepaint notification

At the beginning of each paint cycle, the control sends the NM_CUSTOMDRAW notification message, specifying the CDDS_PREPAINT value in the dwDrawStage member of the accompanying NMCUSTOMDRAW structure. The value that your application returns to this first notification dictates how and when the control sends subsequent custom draw notifications for the rest of that paint cycle. Your application can return a combination of the following flags in response to the first notification.

Return value Effect
CDRF_DODEFAULT The control will draw itself. It will not send additional NM_CUSTOMDRAW notifications for this paint cycle. This flag cannot be used with any other flag.
CDRF_NOTIFYITEMDRAW The control will notify the parent of any item-specific drawing operations. It will send NM_CUSTOMDRAW notification messages before and after it draws items.
CDRF_NOTIFYPOSTPAINT The control will send an NM_CUSTOMDRAW notification when the painting cycle for the entire control is complete.
CDRF_SKIPDEFAULT The control will not perform any painting at all.
CDRF_DOERASE The control will only draw the background.
CDRF_SKIPPOSTPAINT The control will not draw the focus rectangle around an item.

Requesting item-specific notifications

If your application returns CDRF_NOTIFYITEMDRAW to the initial prepaint custom draw notification, the control will send notifications for each item it draws during that paint cycle. These item-specific notifications will have the CDDS_ITEMPREPAINT value in the dwDrawStage member of the accompanying NMCUSTOMDRAW structure. You can request that the control send another notification when it is finished drawing the item by returning CDRF_NOTIFYPOSTPAINT to these item-specific notifications. Otherwise, return CDRF_DODEFAULT and the control will not notify the parent window until it starts to draw the next item.

Drawing the item yourself

If your application draws the entire item, return CDRF_SKIPDEFAULT. This allows the control to skip items that it does not need to draw, thereby decreasing system overhead. Keep in mind that returning this value means the control will not draw any portion of the item.

Changing fonts and colors

Your application can use custom draw to change an item's font. Simply select the HFONT you want into the device context specified by the hdc member of the NMCUSTOMDRAW structure associated with the custom draw notification. Since the font you select might have different metrics than the default font, make sure you include the CDRF_NEWFONT bit in the return value for the notification message. For more information on using this functionality, see the sample code in Using Custom Draw. The font that your application specifies is used to display that item when it is not selected. Custom draw does not allow you to change the font attributes for selected items.

To change text colors for all controls that support custom draw except for the list view and tree view, simply set the desired text and background colors in the device context supplied in the custom draw notification structure with the SetTextColor and SetBkColor functions. To modify the text colors in the list view or tree view, you need to place the desired color values in the clrText and clrTextBk members of the NMLVCUSTOMDRAW or NMTVCUSTOMDRAW structure.

Note   Prior to Version 6.0 of the common controls, toolbars ignore the CDRF_NEWFONT flag. Version 6.0 supports the CDRF_NEWFONT flag, and you can use it to select a different font for the toolbar. However, you cannot change a toolbar's color when a visual style is active. To change a toolbar's color in Version 6.0, you must first disable visual styles by calling SetWindowTheme and specifying no visual style:
SetWindowTheme (hwnd, "", "");

Custom Draw With List-View and Tree-View Controls

Most common controls can be handled in essentially the same way. However, the list-view and tree-view controls have some features that require a somewhat different approach to custom draw.

For Version 5.0, these two controls may display clipped text if you change the font by returning CDRF_NEWFONT. This behavior is necessary for backward compatibility with earlier versions of the common controls. If you want to change the font of a list-view or tree-view control, you will get better results if you send a CCM_SETVERSION message with the wParam value set to 5 before adding any items to the control. For an example of a tree-view control that uses custom draw see Knowledge Base article SAMPLE: CustDTv Illustrates Custom Draw in a TreeView (Q248496) World Wide Web link.

Custom Draw With List-View Controls

Because list-view controls have subitems and multiple display modes, you will need to handle the NM_CUSTOMDRAW notification somewhat differently than for the other common controls.

For report mode:

  1. The first NM_CUSTOMDRAW notification will have the dwDrawStage member of the associated NMCUSTOMDRAW structure set to CDDS_PREPAINT. Return CDRF_NOTIFYITEMDRAW.
  2. You will then receive an NM_CUSTOMDRAW notification with dwDrawStage set to CDDS_ITEMPREPAINT. If you specify new fonts or colors and return CDRF_NEWFONT, all subitems of the item will be changed. If you want instead to handle each subitem separately, return CDRF_NOTIFYSUBITEMDRAW.
  3. If you returned CDRF_NOTIFYSUBITEMDRAW in the previous step, you will then receive an NM_CUSTOMDRAW notification for each subitem with dwDrawStage set to CDDS_SUBITEM | CDDS_ITEMPREPAINT. To change the font or color for that subitem, specify a new font or color and return CDRF_NEWFONT.

For the large icon, small icon, and list modes:

  1. The first NM_CUSTOMDRAW notification will have the dwDrawStage member of the associated NMCUSTOMDRAW structure set to CDDS_PREPAINT. Return CDRF_NOTIFYITEMDRAW.
  2. You will then receive an NM_CUSTOMDRAW notification with dwDrawStage set to CDDS_ITEMPREPAINT. You can change the fonts or colors of an item by specifying new fonts and colors and returning CDRF_NEWFONT. Because these modes do not have subitems, you will not receive any additional NM_CUSTOMDRAW notifications.

An example of a list-view NM_CUSTOMDRAW notification handler is given in the next section.

Using Custom Draw

The following code fragment is a portion of a WM_NOTIFY handler that illustrates how to handle custom draw notifications sent to a list-view control:

LPNMLISTVIEW  pnm    = (LPNMLISTVIEW)lParam;
switch (pnm->hdr.code){
...
case NM_CUSTOMDRAW:
LPNMLVCUSTOMDRAW  lplvcd = (LPNMLVCUSTOMDRAW)lParam;
switch(lplvcd->nmcd.dwDrawStage) {
case CDDS_PREPAINT :
return CDRF_NOTIFYITEMDRAW;
case CDDS_ITEMPREPAINT:
SelectObject(lplvcd->nmcd.hdc,
GetFontForItem(lplvcd->nmcd.dwItemSpec,
lplvcd->nmcd.lItemlParam) );
lplvcd->clrText = GetColorForItem(lplvcd->nmcd.dwItemSpec,
lplvcd->nmcd.lItemlParam);
lplvcd->clrTextBk = GetBkColorForItem(lplvcd->nmcd.dwItemSpec,
lplvcd->nmcd.lItemlParam);
/* At this point, you can change the background colors for the item
and any subitems and return CDRF_NEWFONT. If the list-view control
is in report mode, you can simply return CDRF_NOTIFYSUBITEMREDRAW
to customize the item's subitems individually */
...
return CDRF_NEWFONT;
//  or return CDRF_NOTIFYSUBITEMREDRAW;
case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
SelectObject(lplvcd->nmcd.hdc,
GetFontForSubItem(lplvcd->nmcd.dwItemSpec,
lplvcd->nmcd.lItemlParam,
lplvcd->iSubItem));
lplvcd->clrText = GetColorForSubItem(lplvcd->nmcd.dwItemSpec,
lplvcd->nmcd.lItemlParam,
lplvcd->iSubItem));
lplvcd->clrTextBk = GetBkColorForSubItem(lplvcd->nmcd.dwItemSpec,
lplvcd->nmcd.lItemlParam,
lplvcd->iSubItem));
/* This notification is received only if you are in report mode and
returned CDRF_NOTIFYSUBITEMREDRAW in the previous step. At
this point, you can change the background colors for the
subitem and return CDRF_NEWFONT.*/
...
return CDRF_NEWFONT;
}
...
}

The first NM_CUSTOMDRAW notification has the dwDrawStage member of the NMCUSTOMDRAW structure set to CDDS_PREPAINT. The handler returns CDRF_NOTIFYITEMDRAW to indicate that it wishes to modify one or more items individually.

If CDRF_NOTIFYITEMDRAW was returned in the previous step, the next NM_CUSTOMDRAW notification has dwDrawStage set to CDDS_ITEMPREPAINT. The handler retrieves the current color and font values. At this point, you can specify new values for small icon, large icon, and list modes. If the control is in report mode, you can also specify new values that will apply to all subitems of the item. If you have changed anything, return CDRF_NEWFONT. If the control is in report mode and you want to handle the subitems individually, return CDRF_NOTIFYSUBITEMREDRAW.

The final notification is only sent if the control is in report mode and you returned CDRF_NOTIFYSUBITEMREDRAW in the previous step. The procedure for changing fonts and colors is the same as that step, but it only applies to a single subitem. Return CDRF_NEWFONT to notify the control if the color or font was changed.

Related Topics

 

posted @ 2007-05-08 14:03 伤口 阅读(387) | 评论 (0)编辑

导航

统计

与我联系

搜索

 

常用链接

留言簿

随笔档案

最新评论

阅读排行榜

评论排行榜