Click here to Skip to main content
15,887,273 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: All member variables contain same value Pin
BuckBrown22-Feb-06 11:06
BuckBrown22-Feb-06 11:06 
GeneralRe: All member variables contain same value Pin
Joe Woodbury22-Feb-06 11:14
professionalJoe Woodbury22-Feb-06 11:14 
GeneralRe: All member variables contain same value Pin
BuckBrown22-Feb-06 12:59
BuckBrown22-Feb-06 12:59 
GeneralRe: All member variables contain same value Pin
Blake Miller23-Feb-06 4:53
Blake Miller23-Feb-06 4:53 
AnswerRe: All member variables contain same value Pin
carks22-Feb-06 9:23
carks22-Feb-06 9:23 
GeneralRe: All member variables contain same value Pin
BuckBrown22-Feb-06 11:04
BuckBrown22-Feb-06 11:04 
QuestionRe: All member variables contain same value Pin
David Crow22-Feb-06 9:37
David Crow22-Feb-06 9:37 
AnswerRe: All member variables contain same value Pin
BuckBrown22-Feb-06 11:05
BuckBrown22-Feb-06 11:05 
Here are the two header and two cpp files. The code that is causing me problems is in the ListOfInstrumentsDlg::OnInitDialog() function.

// Instrument.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CInstrument dialog

class CInstrument : public CDialog
{
// Construction
public:
CInstrument(CWnd* pParent = NULL); // standard constructor

// Dialog Data
//{{AFX_DATA(CInstrument)
enum { IDD = IDD_DIALOG_INSTRUMENT };
CString m_GPIB;
CString m_Name;
CString m_Type;
CString m_Channels;
//}}AFX_DATA


// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CInstrument)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL

// Implementation
protected:

// Generated message map functions
//{{AFX_MSG(CInstrument)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_INSTRUMENT_H__E23BF332_8005_4295_B743_DDC7DC952923__INCLUDED_)

********************************************************
********************************************************

// Instrument.cpp : implementation file
//

#include "stdafx.h"
#include "ListOfInstruments.h"
#include "Instrument.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CInstrument dialog


CInstrument::CInstrument(CWnd* pParent /*=NULL*/)
: CDialog(CInstrument::IDD, pParent)
{
//{{AFX_DATA_INIT(CInstrument)
m_GPIB = _T("");
m_Name = _T("");
m_Type = _T("");
m_Channels = _T("");
//}}AFX_DATA_INIT
}


void CInstrument::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CInstrument)
DDX_Text(pDX, IDC_EDIT_GPIB, m_GPIB);
DDX_Text(pDX, IDC_EDIT_NAME, m_Name);
DDX_Text(pDX, IDC_EDIT_TYPE, m_Type);
DDX_Text(pDX, IDC_EDIT_CHANNELS, m_Channels);
//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CInstrument, CDialog)
//{{AFX_MSG_MAP(CInstrument)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

********************************************************
********************************************************

//
// ListOfInstrumentsDlg.h header file

#include "Instrument.h"

/////////////////////////////////////////////////////////////////////////////
// CListOfInstrumentsDlg dialog

class CListOfInstrumentsDlg : public CDialog
{
// Construction
public:
CListOfInstrumentsDlg(CWnd* pParent = NULL); // standard constructor

// Dialog Data
//{{AFX_DATA(CListOfInstrumentsDlg)
enum { IDD = IDD_LISTOFINSTRUMENTS_DIALOG };
CListBox m_ListInstruments;
CString m_Transfer;
CString m_Add;
//}}AFX_DATA

// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CListOfInstrumentsDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL

CInstrument Inst;

private:
// CArray<cinstrument, cinstrument&=""> InstArray;

// Implementation
protected:
HICON m_hIcon;

// Generated message map functions
//{{AFX_MSG(CListOfInstrumentsDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnDblclkListInstruments();
afx_msg void OnBtnTransfer();
afx_msg void OnBtnAdd();
afx_msg void OnBtnDelete();
afx_msg void OnBtnNew();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_LISTOFINSTRUMENTSDLG_H__11140619_DB17_44D5_BA7D_0A965B24C920__INCLUDED_)

********************************************************
********************************************************


// ListOfInstrumentsDlg.cpp : implementation file
//

#include "stdafx.h"
#include "ListOfInstruments.h"
#include "ListOfInstrumentsDlg.h"
#include "NewInstrument.h"
//#include "Instrument.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
CAboutDlg();

// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA

// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL

// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CListOfInstrumentsDlg dialog

CListOfInstrumentsDlg::CListOfInstrumentsDlg(CWnd* pParent /*=NULL*/)
: CDialog(CListOfInstrumentsDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CListOfInstrumentsDlg)
m_Transfer = _T("");
m_Add = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CListOfInstrumentsDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CListOfInstrumentsDlg)
DDX_Control(pDX, IDC_LIST_INSTRUMENTS, m_ListInstruments);
DDX_Text(pDX, IDC_EDIT_TRANSFER, m_Transfer);
DDX_Text(pDX, IDC_EDIT_ADD, m_Add);
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CListOfInstrumentsDlg, CDialog)
//{{AFX_MSG_MAP(CListOfInstrumentsDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_LBN_DBLCLK(IDC_LIST_INSTRUMENTS, OnDblclkListInstruments)
ON_BN_CLICKED(IDC_BTN_TRANSFER, OnBtnTransfer)
ON_BN_CLICKED(IDC_BTN_ADD, OnBtnAdd)
ON_BN_CLICKED(IDC_BTN_DELETE, OnBtnDelete)
ON_BN_CLICKED(IDC_BTN_NEW, OnBtnNew)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CListOfInstrumentsDlg message handlers

BOOL CListOfInstrumentsDlg::OnInitDialog()
{
CDialog::OnInitDialog();

// Add "About..." menu item to system menu.

// 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

// CString* m_InstrumentType;
// CString* m_InstrumentName;
// CString* m_GPIB;
// CString* m_Channels;
CString* m_Comma;
CString* m_Return;

FILE* infile;
char* config_file = "Config.txt";

infile = fopen(config_file, "r");

int end_of_file = 0;

CInstrument Inst;

// Here is where the input read from the Config.txt file and stored in the respective variables.
while (!end_of_file)
{
fscanf(infile, "%[^,]", Inst.m_Type);
// fscanf(infile, "%[^,]", &m_InstrumentType);
fscanf(infile, "%[,]", &m_Comma);
fscanf(infile, "%[^,]", Inst.m_Name);
// fscanf(infile, "%[^,]", &m_InstrumentName);
fscanf(infile, "%[,]", &m_Comma);
fscanf(infile, "%[^,]", Inst.m_GPIB);
// fscanf(infile, "%[^,]", &m_GPIB);
fscanf(infile, "%[,]", &m_Comma);
fscanf(infile, "%[^\n]", Inst.m_Channels);
// fscanf(infile, "%[^\n]", &m_Channels);
fscanf(infile, "%[\n]", &m_Return);
// InstArray.Add();
if (feof(infile))
end_of_file = 1;
}

return TRUE; // return TRUE unless you set the focus to a control
}


Buck
GeneralRe: All member variables contain same value Pin
David Crow23-Feb-06 2:29
David Crow23-Feb-06 2:29 
Questionlist view / how do i get a list of all selected items? Pin
Sebastian Pipping22-Feb-06 7:09
Sebastian Pipping22-Feb-06 7:09 
AnswerRe: list view / how do i get a list of all selected items? Pin
James R. Twine22-Feb-06 7:27
James R. Twine22-Feb-06 7:27 
GeneralRe: list view / how do i get a list of all selected items? Pin
Sebastian Pipping22-Feb-06 7:57
Sebastian Pipping22-Feb-06 7:57 
AnswerRe: list view / how do i get a list of all selected items? Pin
David Crow22-Feb-06 7:38
David Crow22-Feb-06 7:38 
GeneralRe: list view / how do i get a list of all selected items? Pin
Sebastian Pipping22-Feb-06 8:04
Sebastian Pipping22-Feb-06 8:04 
QuestionAccess to COM methods inside Windows Service ATL Pin
cmacgowan22-Feb-06 6:03
cmacgowan22-Feb-06 6:03 
QuestionLGPL query Pin
Chintoo72322-Feb-06 5:51
Chintoo72322-Feb-06 5:51 
AnswerRe: LGPL query Pin
Chris Losinger22-Feb-06 7:45
professionalChris Losinger22-Feb-06 7:45 
GeneralRe: LGPL query Pin
Chintoo72322-Feb-06 15:21
Chintoo72322-Feb-06 15:21 
GeneralRe: LGPL query Pin
Chris Losinger22-Feb-06 16:01
professionalChris Losinger22-Feb-06 16:01 
AnswerRe: LGPL query Pin
Joe Woodbury22-Feb-06 8:26
professionalJoe Woodbury22-Feb-06 8:26 
AnswerRe: LGPL query Pin
Sebastian Pipping22-Feb-06 15:40
Sebastian Pipping22-Feb-06 15:40 
QuestionPassing Arrays of structures from VB.NET to unmanaged C++ Pin
CPop22-Feb-06 5:45
CPop22-Feb-06 5:45 
QuestionListview controls Pin
Waldermort22-Feb-06 5:23
Waldermort22-Feb-06 5:23 
AnswerRe: Listview controls Pin
Joe Woodbury22-Feb-06 5:41
professionalJoe Woodbury22-Feb-06 5:41 
AnswerRe: Listview controls Pin
Gavin Taylor22-Feb-06 6:07
professionalGavin Taylor22-Feb-06 6:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.