转入BCB半年,因为有大家的关心和帮助,脚本写得异常顺利和开心。提个问题,散点分略表谢意。

G66606495 2006-01-11 03:45:45
因为曾做过文本数据库,所以在此异想天开:程序运行后能不能实现用鼠标全选FORM上的所有组件的
(LABLE的CAPTION、EDIT的TEXT 、MEMO的LINES等文字)进行复制操作。
...全文
202 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
icwin 2006-01-13
  • 打赏
  • 举报
回复
up
tanlim 2006-01-12
  • 打赏
  • 举报
回复
对于在本身程序内部,理论上有COMPONETS支持遍历所有组件。
但是因为TEXT等没有窗口句柄的组件,是没办法在现有的WIN32系统中选取的(运行时)(BCB6 IDE中原本就可以)。所有基本上估计无法可操作性实现。
这到是深层次的课题。
大家继续顶呀
yefu2000 2006-01-12
  • 打赏
  • 举报
回复
帮UP先~
caizhen2000_82 2006-01-12
  • 打赏
  • 举报
回复
没试过,学习!!
FengSC 2006-01-12
  • 打赏
  • 举报
回复
实现这个应该没什么问题,只要遍历Form上所有在选择区域里的控件,并将创建与其相同类型的对象,然后复制属性就OK了。
Waiting4you 2006-01-12
  • 打赏
  • 举报
回复
这是BCB里TClipboard的GetComponent, SetComponent例子,不知道行不行,反正偶没做过.
This example uses a button and a group box on a form. When the user clicks the button, the button is copied to the Clipboard and then retrieved from the Clipboard and placed in the new parent of the button, the group box. The name of the original button is changed to avoid having two components with the same name at the same time.

__fastcall TForm1::TForm1(TComponent* Owner): TForm(Owner)

{
// Register the TButton class so that the clipboard can
// read and write button objects
TMetaClass *MetaClass = __classid(TButton);
RegisterClasses(&MetaClass, 0);
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
// copy the button to the clipboard
Clipboard()->SetComponent(Button1);
// rename the button which is still on the form
Button1->Name = "OriginalButton";
// Now retrieve the button from the clipboard

// and add it to GroupBox1
// Note that the clipboard button is named Button1,
// while the source button has been renamed
// to "OriginalButton"
Clipboard()->GetComponent(Self, GroupBox1);
}
oldtab 2006-01-12
  • 打赏
  • 举报
回复
我是看到“散分”进来的。
rudolf_he 2006-01-12
  • 打赏
  • 举报
回复
学习一下
kwokwinglau 2006-01-12
  • 打赏
  • 举报
回复
老妖那个SPY连ComboBox下的没显示出来的所有Item都能取出来.所以取窗体上的文字是一定行滴.
kwokwinglau 2006-01-12
  • 打赏
  • 举报
回复
遍历窗体上的所有控件,根据不同的控件,取其不同的属性.
另外引用:
------求学者-----
但是因为TEXT等没有窗口句柄的组件,是没办法在现有的WIN32系统中选取的(运行时)(BCB6 IDE中原本就可以)。所有基本上估计无法可操作性实现。
------------------

不明白求学者所说Text等没有句柄的组件指的是哪些.


for(int i=0;i<ComponentCount;i++)
{
if(UpperCase((AnsiString)(Components[i]->ClassName()))== "TLABEL")
{
ShowMessage(dynamic_cast<TLabel *>(Components[i])->Caption);
}
if(UpperCase((AnsiString)(Components[i]->ClassName()))== "TEDIT")
{
ShowMessage(dynamic_cast<TEdit *>(Components[i])->Text);
}
if(UpperCase((AnsiString)(Components[i]->ClassName()))== "TMEMO")
{
ShowMessage(dynamic_cast<TMemo *>(Components[i])->Text);
}
}
kwokwinglau 2006-01-12
  • 打赏
  • 举报
回复
for(int i=0;i<ComponentCount;i++)
{
if(UpperCase((AnsiString)(Components[i]->ClassName()))== "TLABEL")
{
ShowMessage(dynamic_cast<TLabel *>(Components[i])->Caption);
}
if(UpperCase((AnsiString)(Components[i]->ClassName()))== "TEDIT")
{
ShowMessage(dynamic_cast<TEdit *>(Components[i])->Text);
}
if(UpperCase((AnsiString)(Components[i]->ClassName()))== "TMEMO")
{
ShowMessage(dynamic_cast<TMEMO *>(Components[i])->Text);
}
}
BCB2006 2006-01-12
  • 打赏
  • 举报
回复
收分
lurel 2006-01-12
  • 打赏
  • 举报
回复
接分嘿嘿
CACACACACA 2006-01-11
  • 打赏
  • 举报
回复

可以访问 Form 的 Components属性,

如下面代码:

int I;

TComponent *Temp;

for (I = Source->ComponentCount - 1; I >= 0; I--)

{
Temp = Source->Components[I];
// only move components that are not controls
if (dynamic_cast<TControl *>(Temp) == NULL)
{
Source->RemoveComponent(Temp);
Dest->InsertComponent(Temp);
}
}
XBox360 2006-01-11
  • 打赏
  • 举报
回复
运行之前到是可以,运行之后感觉不可以吧
kwokwinglau 2006-01-11
  • 打赏
  • 举报
回复
那不就是根據控件的類型取其caption,text,Memo-line?
「已注销」 2006-01-11
  • 打赏
  • 举报
回复
控件也能复制~~~~~~~~~~学习
futulove 2006-01-11
  • 打赏
  • 举报
回复
想想感觉应该可以,但没弄过
futulove 2006-01-11
  • 打赏
  • 举报
回复
一楼

13,822

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧