<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html xmlns:mshelp=http://msdn.microsoft.com/mshelp>
<head>
<title>oncontextmenu event sample</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta name="author" content="inetsdk">
<meta name="ms.locale" content="en-us">
<meta name="robots" content="noindex">
<!--设置菜单的背景样式-->
<style>
.menuitem {font-family:sans-serif;font-size:10pt;width:100;padding-left:20;
background-color:menu;color:black}
.highlightitem {font-family:sans-serif;font-size:10pt;width:100;padding-left:20;
background-color:highlight;color:white}
.clickablespan {padding:4;width:500;background-color:blue;color:white;border:5px gray solid}
</style>
<script>
//<!--
//弹出菜单:
function displaymenu() {
whichdiv=event.srcelement;
menu1.style.leftpos+=10;
menu1.style.posleft=event.clientx;
menu1.style.postop=event.clienty;
menu1.style.display="";
menu1.setcapture();
}
//高亮显示鼠标移上是菜单的背景
function switchmenu() {
el=event.srcelement;
if (el.classname=="menuitem") {
el.classname="highlightitem";
} else if (el.classname=="highlightitem") {
el.classname="menuitem";
}
}
//点击菜单相应项时触发相应的事件
function clickmenu() {
menu1.releasecapture();
menu1.style.display="none"; //点击后隐藏菜单
el=event.srcelement;
if (el.id=="mnured") {
whichdiv.style.backgroundcolor="red";
} else if (el.id=="mnugreen") {
whichdiv.style.backgroundcolor="green"; //选择green时背景变为绿色
} else if (el.id=="mnublue") {
whichdiv.style.backgroundcolor="blue"; //选择blue时背景变为蓝色
} else if (el.id=="mnuyellow") {
whichdiv.style.backgroundcolor="yellow"; //选择yellow时背景变为黄色
}
}
//-->
</script>
<!-- sample_style_start -->
<link rel="stylesheet" href="/workshop/basicsdkie4.css" type="text/css">
<!-- sample_style_end -->
<link rel="stylesheet" type="text/css" href="ms-help://hx/hxruntime/hxlink.css"><style type="text/css">
pre.clscode { font-size:110%; }
pre.clssyntax { font-size:100%; }
td div.clsbeta { display:none;}
mshelp\:link {
color:#0000ff;
text-decoration:underline;
cursor:hand;
hovercolor:#3366ff;
filterstring: ;}
</style>
</head>
<!-- toolbar_start -->
<!-- toolbar_exempt -->
<!--toolbar_end-->
<body topmargin=0 leftmargin=0 bgproperties="fixed" bgcolor="#ffffff"
link="#000000" vlink="#808080" alink="#000000">
<blockquote class="body">
<!-- contents_start -->
<h1>oncontextmenu event sample</h1>
<p>this sample shows how to use the <b>oncontextmenu</b> event handler, available in microsoft® internet explorer 5 and later, to display both standard and custom context menus and prevent context menus from displaying. experiment with each of the following boxes to see how you can apply different methods either to display or to inhibit context menus. each box provides instructions for you to follow.
</p>
<span class="clickablespan">
1. the default context menu always displays when you right-click in this box.
<b><br>code: </b>
//no code necessary
</span><br><br>
<span class="clickablespan" oncontextmenu="return event.ctrlkey">
2. the default context menu displays only if you right-click in this box while holding down the ctrl key. this is useful for developing and debugging purposes.
<b><br>code: </b>
oncontextmenu="return event.ctrlkey"
</span><br><br>
<span class="clickablespan" oncontextmenu="return false">
3. a context menu never displays when you right-click in this box.
<b><br>code: </b>
oncontextmenu="return false"
</span><br><br>
<span class="clickablespan" oncontextmenu="displaymenu();return false">
4. a custom context menu displays when you right-click in this box.
<b><br>code: </b>
oncontextmenu="showmenu();return false;"
</span><br><br>
<span class="clickablespan" oncontextmenu="if (!event.ctrlkey){displaymenu();return false;}">
5. a custom menu displays when you right-click in this box. if you right-click while holding down the ctrl key, the default context menu displays.
<b><br>code: </b>
oncontextmenu="if (!event.ctrlkey){displaymenu();return false;}"
</span><br>
<div id=menu1 onclick="clickmenu()" onmouseover="switchmenu()" onmouseout="switchmenu()" style="position:absolute;display:none;width:100;background-color:menu; border: outset 3px gray">
<div class="menuitem" id=mnured>red</div>
<div class="menuitem" id=mnugreen>green</div>
<div class="menuitem" id=mnublue>blue</div>
<div class="menuitem" id=mnuyellow>yellow</div>
</div>
<!-- contents_end -->
<!-- start_page_footer -->
<br><br><br>
<mshelp:link xmlns:mshelp="http://msdn.microsoft.com/mshelp" keywords="msdn_copyright" tabindex="0">© 2003 microsoft corporation. all rights reserved.</mshelp:link>.
<!-- end_page_footer -->
</blockquote>
</body>
</html>
没有合适的资源?快使用搜索试试~ 我知道了~
VC++ 外壳扩展编程之windows右键菜单
共2个文件
txt:2个
1星 需积分: 12 16 下载量 178 浏览量
2011-07-28
11:45:21
上传
评论
收藏 3KB ZIP 举报
温馨提示
VC++ 外壳扩展编程之windows右键菜单VC++ 外壳扩展编程之windows右键菜单VC++ 外壳扩展编程之windows右键菜单VC++ 外壳扩展编程之windows右键菜单VC++ 外壳扩展编程之windows右键菜单VC++ 外壳扩展编程之windows右键菜单
资源推荐
资源详情
资源评论
收起资源包目录
资源管理器.zip (2个子文件)
资源管理器
新建 文本文档 (2).txt 5KB
资源管理器.txt 297B
共 2 条
- 1
资源评论
- maruia62017-05-20只有几行无用的连接的txt文件,
- lyl852012-05-22只提供了几个链接,不是源码。
wjhxiguanyouni
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功