zoukankan      html  css  js  c++  java
  • BCB6 图片在某一区域里拖动代码

    //---------------------------------------------------------------------------
    
    #include <vcl.h>
    #pragma hdrstop
    
    #include "Unit1.h"
    //---------------------------------------------------------------------------
    #pragma package(smart_init)
    #pragma link "pngimage"
    #pragma link "pngextra"
    #pragma resource "*.dfm"
    TForm1 *Form1;
    bool MouseDownBZ;		//鼠标按下标志(自行加入) 
    int MouseX;			//鼠标坐标(自行加入)
    int MouseY;			//鼠标坐标(自行加入) 
    //---------------------------------------------------------------------------
    __fastcall TForm1::TForm1 (TComponent * Owner):
    TForm (Owner)
    {
    }
    
    //---------------------------------------------------------------------------
    void
      __fastcall
    TForm1::Image1MouseDown (TObject * Sender,
    			 TMouseButton Button, TShiftState Shift, int X, int Y)
    {
      MouseDownBZ = true;
      MouseX = X;
      MouseY = Y;
    }
    
    //---------------------------------------------------------------------------
    void __fastcall
    TForm1::Image1MouseMove (TObject * Sender, TShiftState Shift, int X, int Y)
    {
      int MinXMove = 0;
      int MinYMove = 0;
      int MaxXMove = Panel1->Width - Image1->Width;
      int MaxYMove = Panel1->Height - Image1->Height;
      int LSXMove = Image1->Left + (X - MouseX);
      int LSYMove = Image1->Top + (Y - MouseY);
      if (MouseDownBZ == true)
        {
          if ((LSXMove >= MinXMove) && (LSXMove <= MaxXMove)
    	  && (LSYMove >= MinYMove) && (LSYMove <= MaxYMove))
    	{
    	  Image1->Left = LSXMove;
    	  Image1->Top = LSYMove;
    	}
        }
    }
    
    //---------------------------------------------------------------------------
    void __fastcall
    TForm1::Image1MouseUp (TObject * Sender, TMouseButton Button,
    		       TShiftState Shift, int X, int Y)
    {
      MouseDownBZ = false;
      MouseX = X;
      MouseY = Y;
    }
    
    //---------------------------------------------------------------------------
    void __fastcall
    TForm1::FormCreate (TObject * Sender)
    {
      Image1->Parent->DoubleBuffered = true;
    }
    
    //---------------------------------------------------------------------------
    
    

    http://down.qiannao.com/space/file/meetrice/-6211-7684-8f6f-4ef6/dragimginarea.rar/.page

  • 相关阅读:
    9- 遍历map集合的方法
    linux下修改了tomcat端口之后无法访问
    汪汪
    无题
    python之禅
    kettle连接oracle出现Error connecting to database: (using class oracle.jdbc.driver.OracleDriver)
    Android camera
    网站部署,网站要求需要支持mb_substring
    oracle笔记
    CSS jQuery 图片全屏切换
  • 原文地址:https://www.cnblogs.com/meetrice/p/1771540.html
Copyright © 2011-2022 走看看