用BCB插入了兩張不一樣的dxf圖,疊加在一起顯示,如何讓其中一張圖跟著滑鼠移動,而另一張保持不動呢??


uj5u.com熱心網友回復:
這是一個滑鼠拖動影像的例子,希望對你這個有幫助:
代碼://---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "MainForm.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
iXStart=0;
iYStart=0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ImageMouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
iXStart=X;
iYStart=Y;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ImageMouseMove(TObject *Sender, TShiftState Shift,
int X, int Y)
{
int iX, iY;
if(Shift.Contains(ssLeft))
{
iX=X-iXStart;
iY=Y-iYStart;
if(iY)
Image1->Left+=iX;
if(iY)
Image1->Top+=iY;
}
}
//---------------------------------------------------------------------------
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/237328.html
標籤:基礎類
下一篇:一個極速MD5實作的代碼
