|
-
January 20th, 2010, 09:16 PM
#1
Error 2065
Sorry... I am a newbie in MFC. I dun understand what error i am committing. I have defined my variables in the header file, yet the compiler is always sending the error msg, undeclared identifer. Please do help me.
// USBDlg.h : header file
//
#pragma once
#include "stdafx.h"
#include "afxwin.h"
#include "afxcmn.h"
struct HeaderLayer
{
BYTE FileID ;
BYTE FileVersion ;
BYTE reserved1;
BYTE reserved2;
long PILPos ;
long PILSize ;
long Image1Pos ;
long Image1Size ;
long Image2Pos ;
long Image2Size ;
};
struct PatientInfoLayer
{
char PatientID[64] ;
BYTE LangCode ;
char FirstName[160] ;
char LastName[160] ;
char MiddleName[160] ;
BYTE sex; //0-Male 1-Female 2-Unknown 3-Others
char reserved[3];
short dob_year;
__int8 dob_month;
__int8 dob_day ;
short ed_year;
__int8 ed_month;
__int8 ed_day ;
BYTE UnitCode ; //0-cm,kg 1-inch,pound
char reserved2[3];
short int_Height, fr_Height;
short int_Weight, fr_Weight;
short int_Waist, fr_Waist;
};
struct LCDInfoLayer
{
short LCDwidth;
short LCDheight;
};
// CUSBDlg dialog
class CUSBDlg : public CDialog
{
// Construction
public:
CUSBDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
enum { IDD = IDD_USB_DIALOG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnCbnSelchangeGroupcombo();
DECLARE_MESSAGE_MAP()
public:
HeaderLayer HL;
PatientInfoLayer PIL;
LCDInfoLayer LIL;
CButton ExecuteButton;
CString str_Group;
CString str_Command;
CComboBox GroupBox;
CComboBox CommandBox;
};
// USBDlg.cpp : implementation file
//
#include "stdafx.h"
#include "USB.h"
#include "USBDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
using namespace std;
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Implementation
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg: oDataExchange(CDataExchange* pDX)
{
CDialog: oDataExchange(pDX);
DDX_CBString(pDX, IDC_GROUPCOMBO, str_Group);
DDX_CBString(pDX, IDC_COMMANDCOMBO, str_Command);
DDX_Control(pDX, IDC_GROUPCOMBO, GroupBox);
DDX_Control(pDX, IDC_COMMANDCOMBO, CommandBox);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
// CUSBDlg dialog
CUSBDlg::CUSBDlg(CWnd* pParent /*=NULL*/)
: CDialog(CUSBDlg::IDD, pParent)
,str_Group(_T(""))
,str_Command(_T(""))
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CUSBDlg: oDataExchange(CDataExchange* pDX)
{
CDialog: oDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CUSBDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_CBN_SELCHANGE(IDC_GROUPCOMBO, &CUSBDlg::OnCbnSelchangeGroupcombo)
END_MESSAGE_MAP()
// CUSBDlg message handlers
BOOL CUSBDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CUSBDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CUSBDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this function to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CUSBDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void CUSBDlg::OnCbnSelchangeGroupcombo()
{
UpdateData(true);
// TODO: Add your control notification handler code here
CommandBox.ResetContent();
CString temp;
/*if(str_Group.Compare("Status")==0)
{
temp = "Get Operating Mode";
CommandBox.AddString(&temp);
}*/
UpdateData(false);
}
The error msg are below:::
>c:\documents and settings\sp04-038\my documents\visual studio 2005\projects\usb\usb\usbdlg.cpp(41) : error C2065: 'str_Group' : undeclared identifier
1>c:\documents and settings\sp04-038\my documents\visual studio 2005\projects\usb\usb\usbdlg.cpp(42) : error C2065: 'str_Command' : undeclared identifier
1>c:\documents and settings\sp04-038\my documents\visual studio 2005\projects\usb\usb\usbdlg.cpp(43) : error C2065: 'GroupBox' : undeclared identifier
1>c:\documents and settings\sp04-038\my documents\visual studio 2005\projects\usb\usb\usbdlg.cpp(44) : error C2065: 'CommandBox' : undeclared identifier
1>Generating Code...
1>Compiling...
1>USB.cpp
1>Generating Code...
1>Build log was saved at "file://c:\Documents and Settings\sp04-038\My Documents\Visual Studio 2005\Projects\USB\USB\Debug\BuildLog.htm"
1>USB - 4 error(s), 0 warning(s)
Can anyone please tell me what is wrong?
-
January 21st, 2010, 12:29 AM
#2
Re: Error 2065
You are using str_Group, str_Command, GroupBox and CommandBox variables in CAboutDlg class, which are declared in CUSBDlg class, so compiler doesn't recognize them.
-
January 25th, 2010, 09:23 PM
#3
Re: Error 2065
Thanks alot. Solved the problem. But now i have another 1. I installed the LibUSB-win32 project. However, i can't seemed to include <usb.h> The compiler keep on throw error fatal error C1083: Cannot open include file: 'usb.h': No such file or directory. error message, which pisses me off. How am i going to solve this problem.
-
January 26th, 2010, 08:08 AM
#4
Re: Error 2065
 Originally Posted by exodus2041
Thanks alot. Solved the problem. But now i have another 1. I installed the LibUSB-win32 project. However, i can't seemed to include <usb.h> The compiler keep on throw error fatal error C1083: Cannot open include file: 'usb.h': No such file or directory. error message, which pisses me off. How am i going to solve this problem.
There's a project property where you can specify the directories the compiler will search for header files. Alternately, you could specify the full path to the header file in the #include statement.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|