Victor 串口控制元件包中的Example檔案夾里的SendFile單獨運行的時候沒有問題,但是當用Project | Add to Porject 命令將其添加到另一個Form1 的時候運行報錯。
預設的是通過點Form1里的一個Button來將SendFile作為子表單呼叫,其中TForm中的Button函式是這么寫的。
void __fastcall TForm1::ButtonSendFileClick(TObject *Sender)
{
TFormSendFile* FormSendFile=new TFormSendFile(this);
FormSendFile-> ShowModal();
delete FormSendFile;
}
說明:
1.SendFile.h已經添加到Form1的頭檔案中。
2.已設定為

3.include Path里已包含SendFile所在的檔案夾
報錯如下:

三個錯誤分別對應上面的三行
UnitSendFile.h完整代碼如下:
//---------------------------------------------------------------------------
// 串口控制元件演示程式,Copyright (C) Victor Chen
#ifndef UnitSendFileH
#define UnitSendFileH
//---------------------------------------------------------------------------
#include <Buttons.hpp>
#include <Classes.hpp>
#include <ComCtrls.hpp>
#include <Controls.hpp>
#include <Dialogs.hpp>
#include <StdCtrls.hpp>
#include "VictorFSM.h"
#include "YbCommDevice.h"
//---------------------------------------------------------------------------
class TFormSendFile : public TForm
{
__published: // IDE-managed Components
TYbCommDevice *YbCommDevice1;
TButton *ButtonSend;
TProgressBar *ProgressBar1;
TMemo *Memo1;
TButton *ButtonSet;
TVictorFSM *VictorFSM1;
TOpenDialog *OpenDialog1;
void __fastcall YbCommDevice1Package(TObject *Sender, int NotifyType);
void __fastcall ButtonSetClick(TObject *Sender);
void __fastcall VictorFSM1ProcessState(TObject *Sender);
void __fastcall ButtonSendClick(TObject *Sender);
private: // User declarations
AnsiString _sReceivePath;
HANDLE _hSendFile, _hReceiveFile;
void __fastcall ShowInfo(AnsiString s);
unsigned char _ucPkgID;
unsigned char _ucTryTimes;
long _lBytesToReceive;
TDateTime _dtReceiveFileTime;
AnsiString _sUploadFileName;
long _lUploadDataPos, _lUploadDataSize, _lUploadFileSize;
TVictorFsmStateT<bool> _bReceivingFile;
void ReceivePackage(TMyFinfoPkg &finfo );
void ReceivePackage(TMyFdataPkg &fdata );
void ReceivePackage(TMyStatusPkg &fstatus);
void PrepareSendFile (void);
void SendFileInfoReq (void);
void SendFileInfoWait(void);
void SendFileDataReq (void);
void SendFileDataWait(void);
void SendFileDone (void);
public: // User declarations
__fastcall TFormSendFile(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TFormSendFile *FormSendFile;
//---------------------------------------------------------------------------
#endif
請問如何解決
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/49192.html
標籤:VCL組件使用和開發
上一篇:用C++編程控制程控儀器,控制儀器后怎么重Buffer上讀取儀器顯示的值
下一篇:c++ 類之間成員指標呼叫問題
