在C ++ Builder 6中拖放图像 [英] Drag and drop images in C++ Builder 6

查看:172
本文介绍了在C ++ Builder 6中拖放图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在制作Puzzle程序,现在我如何使用导航键移动图片部分,但是如何使用鼠标?



我试过

  Image1-> Top = Mouse-> CursorPos.x; 
Image1-> Left = Mouse-> CursorPos.y;

有任何帮助吗?



/ p>

我把它放在Timer中,但Image开始在两个位置闪烁...

 code> int difference_x = Form1-> Image1-> Left  -  Mouse  - > CursorPos.x; 
int difference_y = Form1-> Image1->顶部 - 鼠标 - > CursorPos.y;

int xxx = Mouse-> CursorPos.x - difference_x;
int yyy = Mouse-> CursorPos.y - 26 - difference_y;
// 26是游标高度

Image1-> Top = yyy;
Image1-> Left = xxx;


解决方案

我卖掉了我的问题。



我在OnMouseDown事件中做到了:

  difference_x = Form1-& > Left-Mouse-> CursorPos.x; 
difference_y = Form1-> Image1-> Top-Mouse-> CursorPos.y;
Timer1-> Enabled = true;

此计时器:

  int xxx = Mouse-> CursorPos.x + difference_x; 
int yyy = Mouse-> CursorPos.y + difference_y;

Image1-> Top = yyy;
Image1-> Left = xxx;


I'm making a Puzzle program and I now how to move the picture parts with navigation keys but how do I do that using mouse ?

I've tried using this but picture is acting like crazy

Image1->Top=Mouse->CursorPos.x;
Image1->Left=Mouse->CursorPos.y;

Any help?

Edit:

I put this in Timer but Image started blinking in two places at once...

    int difference_x=Form1->Image1->Left - Mouse->CursorPos.x;
    int difference_y=Form1->Image1->Top  - Mouse->CursorPos.y;

    int xxx=Mouse->CursorPos.x - difference_x ;
    int yyy=Mouse->CursorPos.y - 26 - difference_y;
                              // 26 is Cursor height

    Image1->Top=yyy;
    Image1->Left=xxx;

解决方案

I've sold my problem.

I did this in OnMouseDown event:

difference_x=Form1->Image1->Left-Mouse->CursorPos.x;
difference_y=Form1->Image1->Top-Mouse->CursorPos.y;
Timer1->Enabled=true;

and this on Timer:

int xxx=Mouse->CursorPos.x +difference_x ;
int yyy=Mouse->CursorPos.y +difference_y;

Image1->Top=yyy;
Image1->Left=xxx;

这篇关于在C ++ Builder 6中拖放图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆