如何解决错误 LNK2019:未解析的外部符号“公共:__cdecl
在这里,我尝试使用作为 dll 创建的过敏模块到另一个 dll 模块,我是 MFC 和 VC++ 的新手,我试图调查此问题,但无法得到正确答案,请帮助我解决它。 请查看图片以了解可能的错误: AllergyDeatails.cpp 模块代码:
#include "stdafx.h"
#include "Allergy_Module.h"
#include "AllergyDetails.h"
#include "afxdialogex.h"
#include <string>
#include "../Patient_Module/Conversion.h"
#include "../Allergy_Module/Singleton.h"
IMPLEMENT_DYNAMIC(CAllergyDetails,CDialogEx)
CAllergyDetails::CAllergyDetails(CWnd* pParent /*=NULL*/)
: CDialogEx(IDD_ALLERGY_DETAILS,pParent)
{
}
CAllergyDetails::~CAllergyDetails()
{
}
BOOL CAllergyDetails::OnInitDialog()
{
CDialog::OnInitDialog();
CEdit* e = (CEdit*)GetDlgitem(IDC_ALLERGY_NAME);
e->SetFocus();
CWnd* pwnd = GetDlgitem(IDC_AN);
CFont* pfont = pwnd->GetFont();
LOGFONT lf; pfont->GetLogFont(&lf);
lf.lfWeight = 5000;
pfont->CreateFontIndirect(&lf);
pwnd->SetFont(pfont);
pwnd = GetDlgitem(IDC_CAT);
pwnd->SetFont(pfont);
pwnd = GetDlgitem(IDC_SEV);
pwnd->SetFont(pfont); // Todo: Add extra initialization here
pwnd = GetDlgitem(IDC_IS);
pwnd->SetFont(pfont);
pwnd = GetDlgitem(IDC_STAT);
pwnd->SetFont(pfont);
return FALSE; // return TRUE unless you set the focus to a control
}
void CAllergyDetails::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX,IDC_CATEGORY,m_CategoryCtrl);
DDX_Control(pDX,IDC_SEVERITY,m_SeverityCtrl);
DDX_Control(pDX,IDC_INFO_SOURCE,m_InfoSourceCtrl);
DDX_Control(pDX,IDC_STATUS,m_StatusCtrl);
DDX_Control(pDX,IDC_ALLERGY_NAME,m_AllergyNameCtrl);
}
BEGIN_MESSAGE_MAP(CAllergyDetails,CDialogEx)
ON_BN_CLICKED(IDADD,&CAllergyDetails::OnBnClickedAdd)
ON_EN_CHANGE(IDC_ALLERGY_NAME,&CAllergyDetails::OnEnChangeAllergyName)
ON_CBN_SELCHANGE(IDC_CATEGORY,&CAllergyDetails::OnCbnSelchangeCategory)
ON_CBN_SELCHANGE(IDC_SEVERITY,&CAllergyDetails::OnCbnSelchangeSeverity)
ON_CBN_SELCHANGE(IDC_INFO_SOURCE,&CAllergyDetails::OnCbnSelchangeInfoSource)
ON_CBN_SELCHANGE(IDC_STATUS,&CAllergyDetails::OnCbnSelchangeStatus)
END_MESSAGE_MAP()
// CAllergyDetails message handlers
CString sPersonId;
void CAllergyDetails::OnGetPatientId(CString personId)
{
sPersonId = personId;
}
void CAllergyDetails::OnBnClickedAdd()
{
// Todo: Add your control notification handler code here
UpdateData(TRUE);
if (m_AllergyNameCtrl.GetwindowTextLength() == 0 || m_CategoryCtrl.GetCurSel() < 0 || m_SeverityCtrl.GetCurSel() < 0 || m_InfoSourceCtrl.GetCurSel() < 0 || m_StatusCtrl < 0)
{
m_sMesssge.LoadString(IDS_WARNINGMESSAGE);
m_sCaption.LoadString(IDS_WARNINGCAPTION);
::MessageBox(NULL,m_sMesssge,m_sCaption,MB_ICONWARNING);
}
else
{
CString sAllergyName;
m_AllergyNameCtrl.GetwindowText(sAllergyName);
CString sAllergyCategory;
m_CategoryCtrl.GetwindowText(sAllergyCategory);
CString sAllergySeverity;
m_SeverityCtrl.GetwindowText(sAllergySeverity);
CString sAllergyInfoSource;
m_InfoSourceCtrl.GetwindowText(sAllergyInfoSource);
CString sAllergyStatus;
m_StatusCtrl.GetwindowText(sAllergyStatus);
CSingleton* stb;
stb = CSingleton::getInstance();
try
{
std::string ssqlString = "INSERT INTO allergies_table VALUES ('" + ConvertCStringToString(sAllergyName) + "','" + ConvertCStringToString(sAllergyCategory) + "','" + ConvertCStringToString(sAllergySeverity) + "','" + ConvertCStringToString(sAllergyInfoSource) + "','" + ConvertCStringToString(sPersonId) + "','" + ConvertCStringToString(sAllergyStatus) + "')";
stb->Executesql(ConvertStringToCString(ssqlString));
EndDialog(0);
}
catch (CDBException* e)
{
OutputDebugString(e->m_strError);
}
}
}
//****OnEnChangeAllergyName****
void CAllergyDetails::OnEnChangeAllergyName()
{
// Todo: Add your control notification handler code here
CWnd* pwnd = GetDlgitem(IDC_AN);
CFont* pfont = pwnd->GetFont();
LOGFONT lf; pfont->GetLogFont(&lf);
int nLength = m_AllergyNameCtrl.GetwindowTextLength();
if (nLength > 0)
{
lf.lfWeight = 500;
pfont->CreateFontIndirect(&lf);
pwnd->SetFont(pfont);
pwnd->SetwindowTextW(_T("Allergy Name:"));
}
else
{
lf.lfWeight = 5000;
pfont->CreateFontIndirect(&lf);
pwnd->SetFont(pfont);
pwnd->SetwindowTextW(_T("Allergy Name*:"));
}
}
void CAllergyDetails::OnCbnSelchangeCategory()
{
// Todo: Add your control notification handler code here
CWnd* pwnd = GetDlgitem(IDC_CAT);
CFont* pfont = pwnd->GetFont();
LOGFONT lf; pfont->GetLogFont(&lf);
int nPosition = m_CategoryCtrl.GetCurSel();
if (nPosition >= 0)
{
lf.lfWeight = 500;
pfont->CreateFontIndirect(&lf);
pwnd->SetFont(pfont);
pwnd->SetwindowTextW(_T("Category:"));
}
else
{
lf.lfWeight = 5000;
pfont->CreateFontIndirect(&lf);
pwnd->SetFont(pfont);
pwnd->SetwindowTextW(_T("Category*:"));
}
}
void CAllergyDetails::OnCbnSelchangeSeverity()
{
// Todo: Add your control notification handler code here
CWnd* pwnd = GetDlgitem(IDC_SEV);
CFont* pfont = pwnd->GetFont();
LOGFONT lf; pfont->GetLogFont(&lf);
int nPosition = m_SeverityCtrl.GetCurSel();
if (nPosition >= 0)
{
lf.lfWeight = 500;
pfont->CreateFontIndirect(&lf);
pwnd->SetFont(pfont);
pwnd->SetwindowTextW(_T("Severity:"));
}
else
{
lf.lfWeight = 5000;
pfont->CreateFontIndirect(&lf);
pwnd->SetFont(pfont);
pwnd->SetwindowTextW(_T("Severity*:"));
}
}
void CAllergyDetails::OnCbnSelchangeInfoSource()
{
// Todo: Add your control notification handler code here
CWnd* pwnd = GetDlgitem(IDC_IS);
CFont* pfont = pwnd->GetFont();
LOGFONT lf; pfont->GetLogFont(&lf);
int nPosition = m_CategoryCtrl.GetCurSel();
if (nPosition >= 0)
{
lf.lfWeight = 500;
pfont->CreateFontIndirect(&lf);
pwnd->SetFont(pfont);
pwnd->SetwindowTextW(_T("Info_Source:"));
}
else
{
lf.lfWeight = 5000;
pfont->CreateFontIndirect(&lf);
pwnd->SetFont(pfont);
pwnd->SetwindowTextW(_T("Info_Source*:"));
}
}
void CAllergyDetails::OnCbnSelchangeStatus()
{
// Todo: Add your control notification handler code here
CWnd* pwnd = GetDlgitem(IDC_STAT);
CFont* pfont = pwnd->GetFont();
LOGFONT lf; pfont->GetLogFont(&lf);
int nPosition = m_StatusCtrl.GetCurSel();
if (nPosition >= 0)
{
lf.lfWeight = 500;
pfont->CreateFontIndirect(&lf);
pwnd->SetFont(pfont);
pwnd->SetwindowTextW(_T("Status:"));
}
else
{
lf.lfWeight = 5000;
pfont->CreateFontIndirect(&lf);
pwnd->SetFont(pfont);
pwnd->SetwindowTextW(_T("Status*:"));
}
}
PatientDeatil 模块代码:
**PatientDetails.cpp : implementation file**
#include "stdafx.h"
#include "Patient_Module.h"
#include "PatientDetails.h"
#include "afxdialogex.h"
#include "odbcinst.h"
#include "afxdb.h"
#include "../Patient_Module/PatientRegistrationDlg.h"
#include "../Allergy_Module/AllergyDetails.h"
#include "../Allergy_Module/UIExportAllergy.h"
#include "../Patient_Module/PatientSearch.h"
#include "../Patient_Module/Singleton.h"
IMPLEMENT_DYNAMIC(CPatientDetails,CDialogEx)
CPatientDetails::CPatientDetails(CWnd* pParent /*=NULL*/)
: CDialogEx(IDD_PatientDetails,pParent)
{
}
CPatientDetails::~CPatientDetails()
{
}
//****OnInitDialog****
//purpose - this method will create the patient information window
//argument - void
//return - boolean
//preconditions - none
//postconditions - none
BOOL CPatientDetails::OnInitDialog()
{
CDialogEx::OnInitDialog();
m_brush.CreateSolidBrush(RGB(30,144,255));
return TRUE;
}
void CPatientDetails::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX,IDC_Name,m_NameCtrl);
DDX_Control(pDX,IDC_dob,m_dobCtrl);
DDX_Control(pDX,IDC_Gender,m_GenderCtrl);
DDX_Control(pDX,IDC_MRN,m_MrnCtrl);
DDX_Control(pDX,IDC_EncounterType,m_EncounterCtrl);
DDX_Control(pDX,IDC_ALLERGYLIST,m_AllergyListCtrl);
DDX_Control(pDX,IDC_ADD,m_AddButtonCtrl);
DDX_Control(pDX,IDC_CancelButton,m_btCancel);
}
BEGIN_MESSAGE_MAP(CPatientDetails,CDialogEx)
ON_COMMAND(ID_PatientDetails_ADD,&CPatientDetails::OnAddPatientDetail)
ON_COMMAND(ID_PatientDetails_Search,&CPatientDetails::OnSearchPatientDetail)
ON_BN_CLICKED(IDC_ADD,&CPatientDetails::OnBnClickedAdd)
ON_BN_CLICKED(IDC_CancelButton,&CPatientDetails::OnBnClickedCancelbutton)
END_MESSAGE_MAP()
// CPatientDetails message handlers
//****OnCtlColor****
//purpose - It will create a background color of the admin login dialog Box
//arguments - CDC,CWnd,UINT
//returns - HBrush
//preconditions - none
//postconditions - none
HBrush CPatientDetails::OnCtlColor(CDC* pDC,CWnd* pWnd,UINT nCtlColor)
{
CBrush m_brBack;
HBrush hbr = CDialog::OnCtlColor(pDC,pWnd,nCtlColor);
CDialogEx::OnCtlColor(pDC,nCtlColor);
pDC->SetBkMode(TRANSPARENT);
hbr = ::CreateSolidBrush(RGB(30,255));
return hbr;
}
//****OnAddPatientDetail****
//Purpose - This method will call to create the patient registration window
//argument - None
//returns - None
//preconditions - None
//postconditions - None
void CPatientDetails::OnAddPatientDetail()
{
// Todo: Add your command handler code here
CPatientRegistrationDlg patientReg;
patientReg.DoModal();
}
//****OnSearchPatientDetail****
//Purpose - This method will call to create the patient search window and set the details to the respecting fields and also activate the add button
//argument - None
//returns - None
//preconditions - None
//postconditions - None
void CPatientDetails::OnSearchPatientDetail()
{
// Todo: Add your command handler code here
CPatientSearch patientSearch;
patientSearch.DoModal();
SetPatientName(patientSearch.GetPatientName());
SetPatientEncounter(patientSearch.GetPatientEncounter());
SetPatientdob(patientSearch.GetPatientdob());
SetPatientGender(patientSearch.GetPatientGender());
SetPatinetMrn(patientSearch.GetPatientMrn());
m_sPersonId = patientSearch.GetPatientId();
setPatientId(m_sPersonId);
m_AddButtonCtrl.EnableWindow(TRUE);
m_AllergyListCtrl.GetSelectedColumn();
}
//****OnAllergyDetailsSearch****
//Purpose - This method will search the details of allergy of the selected person
//argument - None
//returns - boolean
//preconditions - None
//postconditions - None
BOOL CPatientDetails::OnAllergyDetailsSearch()
{
CString sMessage;
CString sCaption;
int nAllergyRowCount = 0;
int irec = 0;
CString sAllergyId,sAllergyName,sCategory,sSeverity,sInfo_Source,sstatus,sPersonId;
ResetListControl();
sAllergyName.LoadString(IDS_ALLERGYNAME);
sCategory.LoadString(IDS_ALLERGYCATEGORY);
sSeverity.LoadString(IDS_ALLERGYSEVERITY);
sInfo_Source.LoadString(IDS_ALLERGYSOURCE);
sstatus.LoadString(IDS_ALLERGYSTATUS);
ListView_SetExtendedListViewStyle(m_AllergyListCtrl,LVS_EX_GRIDLInes);
m_AllergyListCtrl.InsertColumn(0,LVCFMT_CENTER,200);
m_AllergyListCtrl.InsertColumn(1,200);
m_AllergyListCtrl.InsertColumn(2,200);
m_AllergyListCtrl.InsertColumn(3,200);
m_AllergyListCtrl.InsertColumn(4,200);
CSingLeton* st;
st = CSingLeton::getInstance();
if (!m_sPersonId.IsEmpty())
{
try
{
CRecordset recest(st);
CString ssqlString = L"Select * from allergies_table where Person_ID = '" + m_sPersonId + L"'";
recest.Open(CRecordset::forwardOnly,ssqlString,CRecordset::readOnly);
while (!recest.ISEOF())
{
nAllergyRowCount++;
if (nAllergyRowCount > 0)
{
recest.GetFieldValue(_T("Allergy_Id"),sAllergyId);
recest.GetFieldValue(_T("Allergy_Name"),sAllergyName);
recest.GetFieldValue(_T("Category"),sCategory);
recest.GetFieldValue(_T("Severity"),sSeverity);
recest.GetFieldValue(_T("Info_Source"),sInfo_Source);
recest.GetFieldValue(_T("Person_ID"),sPersonId);
recest.GetFieldValue(_T("Status"),sstatus);
irec = m_AllergyListCtrl.InsertItem(0,sAllergyName);
m_AllergyListCtrl.SetItemText(irec,1,sCategory);
m_AllergyListCtrl.SetItemText(irec,2,sSeverity);
m_AllergyListCtrl.SetItemText(irec,3,sInfo_Source);
m_AllergyListCtrl.SetItemText(irec,4,sstatus);
recest.MoveNext();
}
}
if (nAllergyRowCount == 0)
{
sMessage.LoadString(IDS_ALLERGYDATA);
sCaption.LoadString(IDS_WARNINGCAPTION);
::MessageBox(this->GetSafeHwnd(),sMessage,sCaption,MB_ICONWARNING);
}
}
catch (CDBException* e)
{
OutputDebugString(e->m_strError);
}
}
return 0;
}
//****ResetListControl****
//Purpose - This method will reset the list of the allergy
//argument - void
//returns - void
//preconditions - None
//postconditions - None
void CPatientDetails::ResetListControl()
{
m_AllergyListCtrl.DeleteallItems();
int iNbrofColumns;
CHeaderCtrl* pHeader = (CHeaderCtrl*)m_AllergyListCtrl.GetDlgitem(0);
if (pHeader)
{
iNbrofColumns = pHeader->GetItemCount();
}
for (int i = iNbrofColumns; i >= 0; i--)
{
m_AllergyListCtrl.DeleteColumn(i);
}
}
//****OnBnClickedAdd****
//Purpose - This method will send the person id first to the allergy detail class and then it will call UIExportAllergy class to create the allergy details window
//argument - void
//returns - void
//preconditions - None
//postconditions - None
void CPatientDetails::OnBnClickedAdd()
{
CAllergyDetails allergyDetails;
allergyDetails.OnGetPatientId(m_sPersonId);
CUIExportAllergy exportAllergy;
exportAllergy.CreateComponent();
OnAllergyDetailsSearch();
}
//****OnBnClickedCancelbutton****
//Purpose - This method will close the patient information window
//argument - void
//returns - void
//preconditions - None
//postconditions - None
void CPatientDetails::OnBnClickedCancelbutton()
{
/* Todo: Add your control notification handler code here*/
EndDialog(0);
}
//****SetPatientName****
//Purpose - This method will set the patient name in the patient information
//argument - CString
//returns - void
//preconditions - None
//postconditions - None
void CPatientDetails::SetPatientName(CString sPatient)
{
m_NameCtrl.SetwindowText(sPatient);
}
//****SetPatientEncounter****
//Purpose - this method will set the patient encounter type in the patient information
//argument - CString
//returns - void
//preconditions - None
//postconditions - None
void CPatientDetails::SetPatientEncounter(CString sEncounter)
{
m_EncounterCtrl.SetwindowText(sEncounter);
}
//****SetPatientMrn****
//Purpose - this method will set the patient mrn in the patient information
//argument - CString
//returns - void
//preconditions - None
//postconditions - None
void CPatientDetails::SetPatinetMrn(CString sMrn)
{
m_MrnCtrl.SetwindowText(sMrn);
}
//****SetPatientdob****
//Purpose - this method will set the patient date of birth in the patient information
//argument - CString
//returns - void
//preconditions - None
//postconditions - None
void CPatientDetails::SetPatientdob(CString sdob)
{
m_dobCtrl.SetwindowText(sdob);
}
//****SetPatientGender****
//Purpose - this method will set the patient gender in the patient information
//argument - CString
//returns - void
//preconditions - None
//postconditions - None
void CPatientDetails::SetPatientGender(CString sGender)
{
m_GenderCtrl.SetwindowText(sGender);
}
//****setPatientId****
//Purpose - this method will send the person id to search the details of allergy
//argument - CString
//returns - void
//preconditions - None
//postconditions - None
void CPatientDetails::setPatientId(CString sPersonId)
{
OnAllergyDetailsSearch();
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。