Home > database >  Will the Delphi and pb in a favor
Will the Delphi and pb in a favor

Time:09-27

Now to do a connection of pb program evaluation, but only the Delphi example,,

Pb code: (I think should write)
Other events:
Constant long wm_copydata=https://bbs.csdn.net/topics/74//cact evaluation device sends back the message of evaluation

If the message. The number=wm_copydata then
Messagebox (', 'received')
End the if


Interface documentation written news channel in the wm_copydata message number 74, why didn't I order evaluation button when the code response?
And is there any way to find out the evaluation unit to the system message mechanism how? Under this back to Delphi, please friends see code:

Delphi code:

CactInterface. DLL and the communication between a host program is used Windows message mechanism, through the WM_CopyData method to send data to the host program, the specific usage is:
1, defined in a host program WMCopyData process, Delphi example:
Procedure WMCopyData (var Msg: TWMCopyData); The message WM_CopyData;
2, the corresponding program of WMCopyData process, Delphi example:
Procedure TFrmMain. WMCopyData (var Msg: TWMCopyData);
Var
SMsg: string;
The begin
SMsg:=StrPas (PChar (Msg. CopyDataStruct. ^ lpData));//Cact evaluation, send back the assessment information
MemMessage. Lines. Insert (0, sMsg);
end;
//Cact evaluation string format for sending back assessment information: yyyy - mm - dd hh: mm: ss, aaa, BBB, Appri_ccc;


Question: please go back to Delphi friends look at Delphi code, tell me about the news of the specific evaluation machine mechanism is what principle,

CodePudding user response:

Delphi code is not complete, window when load should be registered to monitor the message code;
Evaluation unit is connected to the PC through what way?

CodePudding user response:

Why is received in other events?

CodePudding user response:

reference 1st floor pb8 response:
Delphi code is not complete, window when load should be registered to monitor the message code;
Evaluation unit is connected to the PC through what way?


Evaluation to the PC via a usb connection and use the com
I give examples of evaluation unit of the Delphi code is posted, you help analysis,

The unit uniMain;

Interface

USES the
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

Type
TfrmMain=class (TForm)
Label1: TLabel;
BtnAppr: TButton;
BtnExit: TButton;
MemMessage: TMemo;
Label2: TLabel;
EdtComm: TEdit;
Label3: TLabel;
BtnWelcome: TButton;
Procedure FormShow (Sender: TObject);
Procedure btnApprClick (Sender: TObject);
Procedure btnExitClick (Sender: TObject);
Procedure btnWelcomeClick (Sender: TObject);
Private
{Private declarations}
Procedure WMCopyData (var Msg: TWMCopyData); The message WM_CopyData;
//Cact evaluation, send a host program evaluation data, contained in the Msg. The CopyDataStruct. ^ lpData,
Public
{Public declarations}
end;

Var
FrmMain: TfrmMain;

Implementation

{$R *. DFM}

The function CactInit (hMainProc: THandle; ComPort: string) : Boolean; Stdcall; External 'CactInterface. DLL';
//Cact evaluation device initialization function, initialization returns True on success, otherwise it returns False;
//hMainProc is a host program window handle, ComPort is Cact evaluation used by serial port,
The function StartWelcome: Boolean; Stdcall; External 'CactInterface. DLL';
//control Cact evaluation, tip: welcome to function, and returns True on success, otherwise it returns False,
The function StartAppraise: Boolean; Stdcall; External 'CactInterface. DLL';
//control Cact evaluation start evaluation function and returns True on success, otherwise it returns False,
The function CactQuit: Boolean; Stdcall; External 'CactInterface. DLL';
//Cact evaluation, exit interface Dll function,

Procedure TFrmMain. WMCopyData (var Msg: TWMCopyData);
Var
SMsg: string;
The begin
SMsg:=StrPas (PChar (Msg. CopyDataStruct. ^ lpData));//Cact evaluation, send back the assessment information
MemMessage. Lines. Insert (0, sMsg);
//Cact evaluation, send back the assessment information format for: yyyy - mm - dd hh: mm: ss, aaa, BBB, Appri_ccc;
//, respectively: evaluation time (19), seating card number (3) employees, evaluate implement device number (3), the evaluation results (greater than or equal to seven);
//which: Appri_Good representative evaluation is the first key, Appri_Gene representative evaluation is the second key, Appri_1 representative evaluation is the third key,
//Appri_2 representative evaluation, the fourth button, Appri_3 representative evaluation is the fifth key,
//Appri_4 representative evaluation, the sixth key, APPRI_NO on behalf of the customer not press evaluation button;
//the 21:19:52 2006-11-22, 017019, Appri_1 said:
//on November 22, 2006, 21, 19 minutes and 52 seconds, staff position card number is 017 employees in the device number is 019, on the evaluation of the bad attitude by the customer, and
end;

Procedure TfrmMain. FormShow (Sender: TObject);
The begin
MemMessage. The Clear;
COM2 edtComm. Text:=' ';
If CactInit (Handle, edtComm. Text) then//initializes the Cact evaluation,
The begin
BtnWelcome. Enabled:=True;
BtnAppr. Enabled:=True;
End
The else
The begin
MemMessage. Lines. Insert (0, 'a serial port equipment + edtComm Text +' initialization failed, the software can't normal use! ');
BtnWelcome. Enabled:=False;
BtnAppr. Enabled:=False;
end;
end;

Procedure TfrmMain. BtnWelcomeClick (Sender: TObject);
The begin
StartWelcome;//welcome to
end;

Procedure TfrmMain. BtnApprClick (Sender: TObject);
The begin
StartAppraise;//evaluation
end;

Procedure TfrmMain. BtnExitClick (Sender: TObject);
The begin
CactQuit;//close evaluation,
The Close;
end;

end.

CodePudding user response:

In addition to points,, ha ha, early to BBS ~

CodePudding user response:

The few function declarations and call up with respect to OK!

The function CactInit (hMainProc: THandle; ComPort: string) : Boolean; Stdcall; External 'CactInterface. DLL';
//Cact evaluation device initialization function, initialization returns True on success, otherwise it returns False;
//hMainProc is a host program window handle, ComPort is Cact evaluation used by serial port,
The function StartWelcome: Boolean; Stdcall; External 'CactInterface. DLL';
//control Cact evaluation, tip: welcome to function, and returns True on success, otherwise it returns False,
The function StartAppraise: Boolean; Stdcall; External 'CactInterface. DLL';
//control Cact evaluation start evaluation function and returns True on success, otherwise it returns False,
The function CactQuit: Boolean; Stdcall; External 'CactInterface. DLL';
//Cact evaluation, exit interface Dll function,

CodePudding user response:

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related