⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dt980112.html

📁 对于学习很有帮助
💻 HTML
字号:
<html>
<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb_2312-80">
<meta NAME="Generator" CONTENT="Microsoft Word 97">
<title>Delphi Tips</title>
</head>
<body>

<b><i><font SIZE="3"><p ALIGN="JUSTIFY">Delphi Tips</p>
</b><p ALIGN="JUSTIFY">From The Cobb Group</p>
</font><font FACE="宋体" LANG="ZH-CN" SIZE="3"><p ALIGN="JUSTIFY">翻译</font><font SIZE="3">:</font><font FACE="宋体" LANG="ZH-CN" SIZE="3">傅贵</p>
</i><p ALIGN="JUSTIFY"> </p>
</font><font SIZE="3"><p ALIGN="JUSTIFY">98.1.12:</font><font FACE="宋体" LANG="ZH-CN" SIZE="3">如何根据权限简单的动态改变菜单</font><font SIZE="3"> (Delphi 3, 2.0 and 1.0)</p>
<p ALIGN="JUSTIFY">Don't make enabling and disabling menu items harder than it has to be. For instance, when users of different access levels run your program, you want menu item availablity  to dynamically change. One technique for doing this involves the Tag property of menu  items and the user's access level.</p>
<p ALIGN="JUSTIFY">Create your menu as you normally would. Then go back and assign the Tag properties the values of your access levels. For example, the Tag property of File|Open and  File|Close is assigned the value of 2. The Tag property of File|New, File|Save and  File|Print is assigned the value of 3.</p>
<p ALIGN="JUSTIFY">In the OnCreate event of your form, add the following code: </p><dir>

<p ALIGN="JUSTIFY">for i := 0 to MainMenu1.Items.Count -1 do</p>
<p ALIGN="JUSTIFY">begin</p><dir>

<p ALIGN="JUSTIFY">if UserLevel &lt; MainMenu1.Items[i].Tag then</p><dir>
<dir>

<p ALIGN="JUSTIFY">MainMenu1.Items[i].Visible := False</p></dir>
</dir>

<p ALIGN="JUSTIFY">else</p><dir>
<dir>

<p ALIGN="JUSTIFY">MainMenu1.Items[i].Visible := True;</p>
<p ALIGN="JUSTIFY">for j := 0 to MainMenu1.Items[i].Count -1 do </p><dir>

<p ALIGN="JUSTIFY">if UserLevel &lt; MainMenu1.Items[i].Items[j].Tag then</p><dir>

<p ALIGN="JUSTIFY">MainMenu1.Items[i].Items[j].Visible := False</p></dir>

<p ALIGN="JUSTIFY">else </p><dir>

<p ALIGN="JUSTIFY">MainMenu1.Items[i].Items[j].Visible := True;</p></dir>
</dir>
</dir>
</dir>

<p ALIGN="JUSTIFY">end;</p></dir>
</dir>

<p ALIGN="JUSTIFY">The code compares the user's access rights, UserLevel, to the Tag property value. If the  user doesn't have access greater or equal to the Tag value, the menu item is not  displayed. </p>
</font><font FACE="宋体" LANG="ZH-CN" SIZE="3"><p ALIGN="JUSTIFY"> </p></font></body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -