📄 chap31.htm
字号:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<title>滑鼠事件的处理</title>
<link rel="stylesheet" href="../../../include/style.css">
</head>
<body>
<font SIZE="2">
<p><a href="../../../index.htm">首页</a> >> <a href="../../program.htm">程序设计</a>
>> <a href="../cbuilder.htm">C++ Builder</a><small> >>
</small>具体而微的绘图程式·滑鼠事件的处理</p>
<p align="left"><!--webbot bot="ImageMap" rectangle="(40,1) (71, 23) chap32.htm" rectangle="(4,1) (36, 23) chap03.htm" src="../ch1/NextBack.gif" width="72" height="24" alt="NextBack.gif (743字节)" border="0" startspan --><MAP NAME="FrontPageMap"><AREA SHAPE="RECT" COORDS="40, 1, 71, 23" HREF="chap32.htm"><AREA SHAPE="RECT" COORDS="4, 1, 36, 23" HREF="chap03.htm"></MAP><a href="../../../_vti_bin/shtml.exe/program/C++/ch3/chap31.htm/map"><img ismap usemap="#FrontPageMap" border="0" height="24" alt="NextBack.gif (743字节)" src="../ch1/NextBack.gif" width="72"></a><!--webbot bot="ImageMap" endspan i-checksum="23055" --></p>
</font><p><font SIZE="2"></font><font color="#FF0000" SIZE="2">·02滑鼠事件的处理</font></p><font SIZE="2">
<p>当C++ Builder应用程式侦测到物件滑鼠事件时,它会检查你是否定义该物件相对应的滑鼠事件处理程式,然後呼叫该函数,将相关参数传给它。以OnMouseDown事件为例,它的事件处理程式模版如下:</p>
<p>void __fastcall TForm1::FormMouseDown(TObject *Sender, TMouseButton Button,</p>
<p>TShiftState Shift, int X, int Y)</p>
<p>{</p>
<p>}</p>
<p> </p>
<p>它总共接收了以下几个参数:</p>
<p>Sender 引发该事件的软体元件。</p>
<p>Button 表示滑鼠的按键。它的值可为mbLeft(左键),mbRight(右键),mbMiddle(中间键)。</p>
<p>Shift 用以表示事件发生的同时Alt,Shift及Ctrl叁键的状态。</p>
<p>X,Y 用以表示事件发生时之座标位置。</p>
<p>在大多数的情况下,滑鼠事件的(X,Y)座标值是我们最为感兴趣的项目,不过,有时候我们也需要靠Button键来判断滑鼠的按键,或是需要利用Shift来取得特殊键的状态,而做一些额外的程式处理。</p>
<p align="right"><!--webbot bot="ImageMap" rectangle="(40,1) (71, 23) chap32.htm" rectangle="(0,0) (32, 22) chap03.htm" src="../ch1/NextBack.gif" width="72" height="24" alt="NextBack.gif (743字节)" border="0" startspan --><MAP NAME="FrontPageMap1"><AREA SHAPE="RECT" COORDS="40, 1, 71, 23" HREF="chap32.htm"><AREA SHAPE="RECT" COORDS="0, 0, 32, 22" HREF="chap03.htm"></MAP><a href="../../../_vti_bin/shtml.exe/program/C++/ch3/chap31.htm/map1"><img ismap usemap="#FrontPageMap1" border="0" height="24" alt="NextBack.gif (743字节)" src="../ch1/NextBack.gif" width="72"></a><!--webbot bot="ImageMap" endspan i-checksum="41267" --></p>
<p>·<a href="../../../index.htm">首页</a> >> <a href="../../program.htm">程序设计</a>
>> <a href="../cbuilder.htm">C++ Builder</a> >><small>
</small>具体而微的绘图程式·滑鼠事件的处理</p>
</font>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -