我要对多个串口进行编程,如何象VB一样在窗体上放一个MSComm控件,然后设定index为0,在窗体生成的时候Load MScomm(i),当下位机有数据上传时,通过MSComm_onComm的事件进行处理,在Delphi如何实现(动态生成控件)?
解决方案 »
- 请问各位大虾关于打印的一个小问题!
- 请高手指点一下,怎样从DLL中返回string型的二维数组
- VC中可以选择Release来去除调试信息,Delphi中用什么办法使程序变小?
- 又个关于Access 系统表 MSYSOBJECTS 的连接的问题
- 如何将已打开的word文档文件导入Stream中?
- 为什么调用CreateOleObject这个出错
- 请问有什么办法在我自画TBUTTON时,自画的字不会被覆盖?
- 请教《delphi深度历险》上的一个问题
- 重金请教-文件夹加密!!!
- 请问下各位前辈学delphi要那些基础语言。
- StringGrid到底可不可以和Edit一样可以输入信息然后保存到数据库表里啊?
- 菜单问题
{New一个Application,copy代码覆盖原代码,在对象监视器(Object Inspector)
中通过下拉选择,设置Form1的OnCreate事件为FormCreate,然后直接运行就可看到效果}
interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure MyClick(Sender:TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
a: array[1..100] of tbutton;implementation{$R *.dfm}procedure TForm1.MyClick(Sender: TObject);
var
i: integer;
nam: string;
begin
i := strtoint(Trim(Copy(TButton(Sender).Name,7,3)));
TButton(Sender).Visible := not TButton(Sender).Visible;
i := i + 1;
nam := 'button' + inttostr(i);
if i <= 100 then
TButton(FindComponent(nam)).Visible := not TButton(FindComponent(nam)).Visible
end;procedure TForm1.FormCreate(Sender: TObject);
var
i: integer;
begin
for i := 1 to 100 do
begin
a[i] := tbutton.Create(self);
with a[i] do
begin
Top := (i-1) div 10 * 20;
Left := (i-1) mod 10 * 20;
Height := 20;
Width := 20;
Name := 'button' + inttostr(i);
Caption := '';
Parent := Form1;
OnClick := MyClick;
end;
end;
end;end.
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Mask, DBCtrls, ExtCtrls;type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure test(sender : TObject);
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
var
t : Tdbedit;
begin
t :=Tdbedit.create(application);
with t do begin
parent := self;
width := 100;
height := 29;
name := 'text001';
top := 100;
left := 50;
onclick := test;
OnMouseMove:=text001MouseMove;
show;
end;
end;
procedure TForm1.test(sender: TObject);
begin
showmessage(Tdbedit(sender).name);
end;
begin if (Components[j] is TMSComm) then
(Components[j] as TMSComm).; //在这做你要做的操作 end;