可以这么做:uses clipbrd;procedure tform1.button1click(sender:tobject); begin edit1.selectall; edit1.copytoclipboard; end;procedure tform1.button2click(sender:tobject); begin edit2.pastefromclipboard; end;单击Button1,edit1的Text将会复制进剪贴板 单击Button2,Edit2的Text将会被剪贴板的内容替掉 --------------------------------- 风过西窗客渡舟船无觅处 年年一川新草遥看却似旧
to WnEunfn(斯人不语):这种方法不行,我是过,ActionList中可以实现,但是还是得不到所选定的内容to toplor(霜天晓竹): 这种方法不行,因为不知道焦点是否在Edit1,具体说说我的过程: 是这样的,我做了一个系统,在主窗体上有工具栏,有复制、粘贴按钮,我想实现当选中某项文本时,点复制,执行Ctrl+C功能,然后粘贴到焦点所在的Edit、Memo或其他地方,系统中有几十个子窗体,现在的问题是我该怎么得到焦点所在的WinCtrol及选中的文本
我自己搞定了,是这样的 复制: if (Screen.ActiveControl is TCustomEdit) then (Screen.ActiveControl as TCustomEdit).CopyToClipboard; 粘贴: if (Screen.ActiveControl is TCustomEdit) then (Screen.ActiveControl as TCustomEdit).PasteFromClipboard; 分数只能给我自己了,呵呵
begin
edit1.selectall;
edit1.copytoclipboard;
end;procedure tform1.button2click(sender:tobject);
begin
edit2.pastefromclipboard;
end;单击Button1,edit1的Text将会复制进剪贴板
单击Button2,Edit2的Text将会被剪贴板的内容替掉
---------------------------------
风过西窗客渡舟船无觅处
年年一川新草遥看却似旧
Standard Action 是自動感知的﹐我試過了﹐沒有問題﹖(MDI下)
Email: [email protected]
Email: [email protected]
TClipboard,这个比较灵活,呵呵。
TClipboard,这个比较灵活,呵呵。
// 测试SendMessage(ComboBox1.Handle, WM_paste, 0, 0);
procedure TForm1.Button1Click(Sender: TObject);
begin
edit1.SetFocus;
sendmessage(edit1.haNdle,WM_CUT,0,0);
combobox1.SelectAll;
SendMessage(ComboBox1.Handle, WM_paste, 0, 0);
end;//将combobox中的文字粘贴到edit中
// SendMessage(Combobox1.Handle, WM_CUT, 0,0);
procedure TForm1.Button2Click(Sender: TObject);
begin
combobox1.SelectAll;
SendMessage(Combobox1.Handle, WM_CUT, 0,0);
edit1.SetFocus;
SendMessage(Edit1.Handle, WM_PASTE, 0, 0);
end;//清除combobox的文字
//测试 SendMessage(Combobox1.Handle, WM_CLEAR, 0,0);
procedure TForm1.Button3Click(Sender: TObject);
begin
combobox1.SelectAll;
SendMessage(Combobox1.Handle, WM_CLEAR, 0,0);
end;
// 测试SendMessage(ComboBox1.Handle, WM_paste, 0, 0);
procedure TForm1.Button1Click(Sender: TObject);
begin
edit1.SetFocus;
sendmessage(edit1.haNdle,WM_CUT,0,0);
combobox1.SelectAll;
SendMessage(ComboBox1.Handle, WM_paste, 0, 0);
end;//将combobox中的文字粘贴到edit中
// SendMessage(Combobox1.Handle, WM_CUT, 0,0);
procedure TForm1.Button2Click(Sender: TObject);
begin
combobox1.SelectAll;
SendMessage(Combobox1.Handle, WM_CUT, 0,0);
edit1.SetFocus;
SendMessage(Edit1.Handle, WM_PASTE, 0, 0);
end;//清除combobox的文字
//测试 SendMessage(Combobox1.Handle, WM_CLEAR, 0,0);
procedure TForm1.Button3Click(Sender: TObject);
begin
combobox1.SelectAll;
SendMessage(Combobox1.Handle, WM_CLEAR, 0,0);
end;
复制:
if (Screen.ActiveControl is TCustomEdit) then
(Screen.ActiveControl as TCustomEdit).CopyToClipboard;
粘贴:
if (Screen.ActiveControl is TCustomEdit) then
(Screen.ActiveControl as TCustomEdit).PasteFromClipboard;
分数只能给我自己了,呵呵