日期:2014-05-20  浏览次数:20596 次

能否用C#实现窗体半透明
如题

------解决方案--------------------
ie下的,参考:

http://www.google.com/search?hl=zh-CN&newwindow=1&rls=com.microsoft%3Aen-US&q=css%E6%BB%A4%E9%95%9C+%E9%80%8F%E6%98%8E&btnG=Google+%E6%90%9C%E7%B4%A2&lr=lang_zh-CN%7Clang_zh-TW
------解决方案--------------------
filter:alpha(style=0,opacity=50);

任何一个TAG的STYLE加上filter:alpha属性,就会有半透明效果。
偶也正在寻找,没找到理想的代码,JS又不熟悉,下面双个代码参考一下吧。

//------------------beginning of code
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN ">
<html>
<head>
<title> New Document </title>
<meta http-equiv= "Content-Type " content= "text/html " charset= "gb2312 ">
</head>
<script language= "JavaScript ">
function showEdit(id){
document.all[ "bgLayer "].style.display= " ";
document.all[ "bgLayer "].style.height=document.body.scrollHeight;
}
</script>
<body leftmargin=0 topmargin=0>
test test test <br />
test test test <br />
<div id= "bgLayer " style= "position:absolute;background:#CCCCCC;top:0px;width:100%;height:100%;filter:alpha(style=0,opacity=50);display:none;z-index:9998; ">
</div>
<input type= "button " value= "Test " onClick= "javaScript:showEdit(); ">

</body>
</html>
//--------------------------------end of code


//------------------------beginning of code

<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<title> untitled </title>
<meta content= "MSHTML 6.00.2800.1586 " name= "GENERATOR "/>
</head>
<body>
<input onclick= "sAlert( '正在导入... <br/> 正在将Word文档导入到编辑器,请稍候... <br/> NEUSOFT '); " type= "button " value= "点击这里 "/>
<script language= "javascript " type= "text/javascript ">
//Author:Daviv
//Blog: <a href= " <a href= "http://blog.163.com/jxdawei " target= "_blank "> http://blog.163.com/jxdawei </a> " target= "_blank "> <a href= "http://blog.163.com/jxdawei " target= "_blank "> http://blog.163.com/jxdawei </a> </a>
//Date:2006-10-28
//Email:jxdawei@gmail.com
function sAlert(str){
var msgw,msgh,bordercolor;
msgw=400;//提示窗口的宽度
msgh=100;//提示窗口的高度
bordercolor= "#336699 ";//提示窗口的边框颜色
titlecolor= "#99CCFF ";//提示窗口的标题颜色

var sWidth,sHeight;
sWidth=document.body.offsetWidth;
sHeight=document.body.offsetHeight;

var bgObj=document.createElement( "div ");
bgObj.setAttribute( 'id ', 'bgDiv ');
bgObj.style.position= "absolute ";
bgObj.style.top= "0 ";
bgObj.style.background= "#777 ";
bgObj.style.filter= "progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75 ";
bgObj.style.opacity= "0.6 ";
bgObj.style.left= "0 ";
bgObj.style.width=sWidth + "px ";
bgObj.style.height=sHeight + "px ";
document.body.appendChild(bgObj);
var msgObj=document.createElement( "div ")
msgObj.setAttribute( "id ", "msgDiv ");