Sunday, May 28, 2006

tagPOINT type

tagPOINT 是一個結構型資料型態, 剛剛費了一點力氣把原始宣告的程式碼從

C:\Program Files\Borland\CBuilder6\Include\Vcl\

中給找出來, 我是在 types.hpp 這個檔案中找到宣告的程式碼的:

struct TPoint : public POINT
{
TPoint() {}
TPoint(int _x, int _y) { x=_x; y=_y; }
TPoint(POINT& pt) { x = pt.x; y = pt.y; }
};
typedef TPoint tagPoint;

也就是說, 由於 BCB 透過 vcl.h 將這段程式碼放到程式的開頭, 所以我們寫程式時, 只要前面有加上

#include < vcl.h >

就可以使用這個 tagPOINT 資料型態了。

但, 要怎麼使用呢?

宣告部份:

tagPOINT ptCurrent;
/* 當滑鼠的位置點在 (X, Y) 時, 我們就可以把這個座標存到 ptCurrent 這個變數之中。*/

程式部份:
ptCurrent.x = X; ptCurrent.y = Y;

同學們可以先試試使用 tagPOINT 這個資料型態, 然後嘗試把 tagPOINT 與 stack 的用法結合起來。

No comments:

Post a Comment