小弟不才,诚请各位大侠帮助解答!!并给于回报!!

fellowcheung 2001-09-25 10:58:26
加精
请问如何在C++Builder中,实现鼠标从一个区域托拽文件到另一个区域完成动态的复制功能?我知道使用剪贴板,但具体的一些事件(比如鼠标的一些时间)不太清楚。请大侠们帮助一下,最好提供具体的代码支持!!谢谢!
...全文
117 点赞 收藏 13
写回复
13 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
still_me 2001-11-11
自己编一个函数吧!
回复
fellowcheung 2001-10-28
给分!
回复
fellowcheung 2001-09-25
谢谢孙春阳朋友,但怎么这个问题它就没有C++Builder的呢?关注……
回复
Wingsun 2001-09-25
这儿有一段文字,不过是delphi的,而且还是英文的,你慢慢看哦

Drag and Drop Selected Text in between Memo Components - by Borland Developer Support Staff



Technical Information Database

TI4540D.txt - Drag and Drop Selected Text in between Memo Components

Category :VCL
Platform :All-32Bit
Product :All32Bit,

Description:
Without getting too deep into component creation, here's a very
simple way of accomplishing drag and drop of selected text.

Create a new component (TMyMemo) descending off of TMemo.

Make the type declaration look something like this:

type
TMyMemo = class(TMemo)
private
FLastSelStart : Integer;
FLastSelLength : Integer;
procedure WMLButtonDown(var Message: TWMLButtonDown);
message WM_LBUTTONDOWN;
published
property LastSelStart : Integer read FLastSelStart
write FLastSelStart;
property LastSelLength : Integer read FLastSelLength
write FLastSelLength;
end;

Make the implementation of WMLButtonDown look like this:

procedure TMyMemo.WMLButtonDown(var Message: TWMLButtonDown);
var
Ch : Integer;
begin
if SelLength > 0 then begin
Ch := LoWord(Perform(EM_CHARFROMPOS,0,
MakeLParam(Message.XPos,Message.YPos)));
LastSelStart := SelStart;
LastSelLength := SelLength;
if (Ch >= SelStart) and (Ch <= SelStart+SelLength-1) then
BeginDrag(True)
else
inherited;
end
else
inherited;
end;

Now, install this component into a package, start a brand new project
in Delphi 3 and drop two TMyMemos down.

Make them both have an OnDragOver event handler looking like this:

procedure TForm1.MyMemo1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
Accept := Source is TMyMemo;
end;

Make them both have an OnDragDrop event handler looking like this:

procedure TForm1.MyMemo1DragDrop(Sender, Source: TObject;
X, Y: Integer);
var
Dst, Src : TMyMemo;
Ch : Integer;
Temp : String;
begin
Dst := Sender as TMyMemo;
Src := Source as TMyMemo;
Ch := LoWord(Dst.Perform(EM_CHARFROMPOS,0,MakeLParam(X,Y)));

if (Src = Dst) and (Ch >= Src.LastSelStart) and
(Ch <= Src.LastSelStart+Src.LastSelLength-1) then
Exit;

Dst.Text := Copy(Dst.Text,1,Ch)+Src.SelText+
Copy(Dst.Text,Ch+1,Length(Dst.Text)-Ch);
Temp := Src.Text;
Delete(Temp,Src.LastSelStart+1,Src.LastSelLength);
Src.Text := Temp;
end;

Launch the app and put some text into the memos, and watch what
happens as you drag and drop inbetween the two memos, or even drag
and drop text from one location in one memo component to another
location in the same memo component.
回复
nofeal 2001-09-25
靠,又是要代码,我自己不上班了。刚吃完饭,
回复
fellowcheung 2001-09-25
都吃饭去了吗?望穿双眼盼代码…… :-(
回复
fellowcheung 2001-09-25
小弟求助,请帮助!!!
回复
fellowcheung 2001-09-25
请提供一个详细的例子支持。因为其中有几个难点:
1、涉及到一个区域进入的问题。
2、鼠标移动和托拽的问题。
3、文件复制过程中的异常处理问题。
请您给于一个虚拟的例子的代码支持!谢谢!:-)
回复
nofeal 2001-09-25
控件的
OnDragDrop() OnDragOver()事件
回复
hantao 2001-09-25
gz
回复
fellowcheung 2001-09-25
关注…… :_-(
回复
fellowcheung 2001-09-25
惭愧,小弟确实没有。那么请推荐一本店子文档(附源代码)的,哪里可以下载?
回复
maquanjun 2001-09-25
大部分bcb的书上都介绍的挺详细 ,你难道没有?
总不能照书给你敲一遍吧
回复
相关推荐
发帖
C++ Builder
创建于2007-08-02

1.3w+

社区成员

C++ Builder相关内容讨论区
申请成为版主
帖子事件
创建了帖子
2001-09-25 10:58
社区公告
暂无公告