我是新手!各位大哥有没有用过cport这个串口通讯控件的.进来改一下小弟程序的错误.!!(50分)

  • 主题发起人 主题发起人 weihua200205
  • 开始时间 开始时间
W

weihua200205

Unregistered / Unconfirmed
GUEST, unregistred user!
程序:
unit ComMainForm;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, cPort, CPortCtl;

type
TForm1 = class(TForm)
Memo: TMemo;
Button_Open: TButton;
Button_Settings: TButton;
Edit_Data: TEdit;
Button_Send: TButton;
NewLine_CB: TCheckBox;
Panel1: TPanel;
Bt_Store: TButton;
Bt_Load: TButton;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label1: TLabel;
Label6: TLabel;
procedure Button_OpenClick(Sender: TObject);
procedure Button_SettingsClick(Sender: TObject);
procedure Button_SendClick(Sender: TObject);
procedure ComPortOpen(Sender: TObject);
procedure ComPortClose(Sender: TObject);
procedure ComPortRxChar(Sender: TObject; Count: Integer);
procedure Bt_LoadClick(Sender: TObject);
procedure Bt_StoreClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button_OpenClick(Sender: TObject);
begin
if ComPort.Connected then
ComPort.Close
else
ComPort.Open;
end;

procedure TForm1.Button_SettingsClick(Sender: TObject);
begin
ComPort.ShowSetupDialog;
end;

procedure TForm1.Button_SendClick(Sender: TObject);
var
Str: String;
begin
Str := Edit_Data.Text;
if NewLine_CB.Checked then
Str := Str + #13#10;
ComPort.WriteStr(Str);
end;

procedure TForm1.ComPortOpen(Sender: TObject);
begin
Button_Open.Caption := 'Close';
end;

procedure TForm1.ComPortClose(Sender: TObject);
begin
if Button_Open <> nil then
Button_Open.Caption := 'Open';
end;

procedure TForm1.ComPortRxChar(Sender: TObject; Count: Integer);
var
Str: String;
begin
ComPort.ReadStr(Str, Count);
Memo.Text := Memo.Text + Str;
end;

procedure TForm1.Bt_LoadClick(Sender: TObject);
begin
ComPort.LoadSettings(stRegistry, 'HKEY_LOCAL_MACHINE/Software/Dejan');
// ComPort.LoadSettings(stIniFile, 'e:/Test.ini');
end;

procedure TForm1.Bt_StoreClick(Sender: TObject);
begin
// ComPort.StoreSettings(stIniFile, 'e:/Test.ini');
ComPort.StoreSettings(stRegistry, 'HKEY_LOCAL_MACHINE/Software/Dejan');
end;

end.
错误列表:
Build
[Error] ComMainForm.pas(49): Undeclared identifier: 'ComPort'
[Error] ComMainForm.pas(57): Missing operator or semicolon
[Error] ComMainForm.pas(60): Statement expected but 'PROCEDURE' found
[Error] ComMainForm.pas(67): Undeclared identifier: 'ComPort'
[Error] ComMainForm.pas(85): Undeclared identifier: 'ComPort'
[Error] ComMainForm.pas(91): Undeclared identifier: 'ComPort'
[Error] ComMainForm.pas(98): Undeclared identifier: 'ComPort'
[Error] ComMainForm.pas(27): Unsatisfied forward or external declaration: 'TForm1.Button_SettingsClick'
[Fatal Error] ComExample.dpr(5): Could not compile used unit 'ComMainForm.pas'
 
www.source520.com 再次更新近3万代码,全部免费免注册狂下载
 
后退
顶部