您好,
1.我想要实现如下功能,请问该怎么作: 输入一个数字,比如 5, 就会生成 5 个可以用来输入字符串的 edit控件。 也就是说, 在我程序开始运行时, 先让操作者输入一个数字,然后再生成相应数目的edit控件 来让操作者再输入其它内容。
请问该怎样实现?? 谢谢您。 2.进程通信的问题:(两个程序如何通信?)
比如有两个程序:
1 个 只有一个 form,一个 输入框(edit),一个按钮;
另一个: 只有一个form,一个文本控件(label)
我想要实现:
在程序1 edit1中输入的内容在 程序2的label 中显示出来。 请问我该怎样用sendmessage 和 postmessage 处理? 初学,最好能给一些代码。
1.我想要实现如下功能,请问该怎么作: 输入一个数字,比如 5, 就会生成 5 个可以用来输入字符串的 edit控件。 也就是说, 在我程序开始运行时, 先让操作者输入一个数字,然后再生成相应数目的edit控件 来让操作者再输入其它内容。
请问该怎样实现?? 谢谢您。 2.进程通信的问题:(两个程序如何通信?)
比如有两个程序:
1 个 只有一个 form,一个 输入框(edit),一个按钮;
另一个: 只有一个form,一个文本控件(label)
我想要实现:
在程序1 edit1中输入的内容在 程序2的label 中显示出来。 请问我该怎样用sendmessage 和 postmessage 处理? 初学,最好能给一些代码。
解决方案 »
- QReport打印多份时,如何记录打印份数的序号??
- 怎样向数据库中存入JPG图片啊,项目急用,在线等.
- win2000下做的程序为什么在win98下提示错误“[DBNMPNTW]”拒绝访问--急在线等待
- 高分求四则运算式的处理?
- 运行IntraWeb 开发的程序无法用“后退”键??
- SQL Server 中主键和外键的真真好处有哪些?如何最大限度发挥其作用。
- 帮我看一看,可不可以?
- 为大家共享了一批书,要的来下载;
- 请问大伙,我把字符串放在qa.res中了,如何调用呢呢?????????急急。例子??
- 关于TADOConnection 控件的使用
- 为什么用Delphi6自带的indy组件的idHttp上传文件,在文件较大时会丢失后面的部分?
- 请问有谁能告诉我最新的大富翁离线浏览包(CHM格式)的下载地址?
int num=StrToInt(Edit1->Text);
for (int i=1;i<=num;i++) {
TEdit *Edit=new TEdit(this);
Edit->Parent=Form1;
Edit->Name="Edit"+IntToStr(i+1);
Edit->Left=20;
Edit->Top=i*30;
}
好象还是需要设置一个Edit数组
begin
with tedit.create(nil) do
begin
name:='...';
...
parent:=...;
end;
end;
我这样创建了。
望大家继续指导(尤其第二个问题),谢谢
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
Label1: TLabel;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
protected
procedure WndProc(Var Message : Tmessage); override;
end;var
Form1: TForm1;
WM_MY_WINDOW_MESSAGE : Integer;implementation{$R *.DFM}{ TForm1 }procedure TForm1.WndProc(var Message: Tmessage);
Var
sBuf : Array [0..255] of char;
begin
if (Message.Msg = Cardinal(WM_MY_WINDOW_MESSAGE )) then
begin
if (GlobalGetAtomName(Message.wParam,@sBuf[0],255) > 0) then
begin
// ShowMessage(StrPas(@sbuf[0]));
Label1.caption := sbuf;
GlobalDeleteAtom(Message.Wparam);
end;
end;
inherited;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
WM_MY_WINDOW_MESSAGE := RegisterWindowMessage('MyMessage');
end;end.unit PassString;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
Edit1: TEdit;
procedure FormCreate(Sender: TObject);
procedure Edit1Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
WM_MY_WINDOW_MESSAGE : Integer;implementation{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject);
begin
WM_MY_WINDOW_MESSAGE := RegisterWindowMessage('MyMessage');end;procedure TForm1.Edit1Change(Sender: TObject);
Var
iReceive : Integer;
hWindow : Hwnd;
begin
iReceive := GlobalAddAtom(pchar(Edit1.text));
hWindow := FindWindow(0,'Receive String');
if hWindow = 0 then exit;
if iReceive > 0 then
begin
PostMessage(hWindow ,WM_MY_WINDOW_MESSAGE,iReceive,0);
//HWND_BROADCAST
end;
end;end.
//动态创建控件******************************************************************
//==============================================================================
function DynaCreateComponent(Owner: TComponent; CompType: TControlClass; CompName: String; Left,Top,Width,Height:Integer): TControl;
begin
if (Owner.FindComponent(CompName)<>nil) and not(Owner.FindComponent(CompName) is TControl) then
begin
Result := nil;
exit;
end;
Result := Owner.FindComponent(CompName) as TControl;
if Result=nil then
begin
Result := CompType.Create(Owner);
with Result do
begin
if Owner is TwinControl then
begin
SetBounds(Left,Top,Width,Height);
Parent := TwinControl(Owner);{如果是可视构件,则显示之}
if Owner is TForm then TForm(Owner).ActiveControl := TWinControl(Result);{设置窗口焦点}
end;
end;
Result.Name := CompName;
end
else {Result<>Nil}
if not(Result is CompType) then
begin
Result := nil;
Exit;
end;
Result.Visible := True;
end;
{ 对于未知数量的控件组,利用TList
var ControlList: Tlist; CreateNum: integer;
const CreateClass : TControlClass = TButton;//可以任意修改TControlClass = TEdit或TPanel等。效果一样。
var i:integer; APoint: Pointer;
ControlList := TList.Create;
ControlList.Clear;
CreateNum := 10;
for i:=1 to CreateNum do
begin
APoint := Pointer(DynaCreateComponent(self,CreateClass,'Button_' + IntToStr(i),0,i*20+1,60,20));//创建
ControlList.Add(APoint);
end;
TButton(ControlList.Items[i]).Caption := 'XXXX';}
a: Tbutton;
begin
a:= Tbutton.Create(form1);
a.Caption := 'aa';
a.left := 0;
a.parent := form1;
a.Visible := True;
http://www.csdn.net/expert/topic/1066/1066599.xml?temp=.2060816var
a: Tedit;
i: integer;
begin
for i := 1 to 5 do
begin
a:= TEdit.Create(form1);
a.text := '测试';
a.top := i*30;
a.parent := form1;
a.Visible := True;
end;