?? 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 + -