在C++Builder 6中拖放图像
Drag and drop images in C++ Builder 6
我正在制作一个益智程序,现在我如何使用导航键移动图片部分,但我如何使用鼠标做到这一点?
我试过使用这个,但图片表现得像疯狂的
Image1->Top=Mouse->CursorPos.x;
Image1->Left=Mouse->CursorPos.y;
有什么帮助吗?
编辑:
我把这个放在计时器中,但图像开始同时在两个地方闪烁。。。
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;
我已经解决了我的问题。
我在OnMouseDown事件中做到了这一点:
difference_x=Form1->Image1->Left-Mouse->CursorPos.x;
difference_y=Form1->Image1->Top-Mouse->CursorPos.y;
Timer1->Enabled=true;
这个在Timer:上
int xxx=Mouse->CursorPos.x +difference_x ;
int yyy=Mouse->CursorPos.y +difference_y;
Image1->Top=yyy;
Image1->Left=xxx;
相关文章:
- 在组合框中拖放项目
- wxWidgets 拖放文件事件处理程序初始化问题(无效static_cast)
- 拖放我的MDI被CRichEditView拦截并在CRichEditView::GetDocument中崩溃 - 如何覆
- 在特定区域拖放 | Qt
- Qt - 在QGraphicScene中拖放时如何从项目中获取文本?
- Qt 模型拖放 - 无法保存类型 QJsonValue
- 如何在 2 个应用程序之间实现拖放?
- 在拖放 QML 列表中插入/删除项目使用 cpp 模型查看
- UI具有拖放功能
- 如何使用拖放功能和点击信号函数QT创建标签
- 使用MFC在对话框上拖放文件
- QListWidget通过setItemWidget使用自定义小部件集进行拖放
- 将拖放连接到QListWidget中的函数的最佳方法
- QTextEdit-根据QCursor位置进行条件拖放
- 如果使用Qt::DecorationRole,则在拖放时崩溃
- 用代码模拟窗口拖放
- Ole 拖放故障排除
- 基于文本的角色扮演游戏拖放和保留物品功能
- 在C++Builder 6中拖放图像
- Qt拖放-改变图像显示,而拖动