|
-
Nov 2nd, 2001, 02:05 PM
#1
Thread Starter
Lively Member
Weird Structure
Hey Guys
I have a structure i defined myself which contains a string and a DWORD.
I have declared an instance of this in the header of a class and then i have functions in my class that write to this public variable. Well anyway when you try and read data out in another function the variable is empty.
Has anyone got any ideas
Peter
"Let's all join forces, rule with an iron hand...and prove to all the world, metal rules the land..."
-- Judas Priest
My email is [email protected]
-
Nov 2nd, 2001, 02:11 PM
#2
Monday Morning Lunatic
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Nov 2nd, 2001, 02:11 PM
#3
transcendental analytic
You got any code for the class and the functions?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 2nd, 2001, 02:12 PM
#4
Monday Morning Lunatic
Beat ya
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Nov 2nd, 2001, 02:15 PM
#5
transcendental analytic
Damnation parksie
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 2nd, 2001, 03:02 PM
#6
Thread Starter
Lively Member
//This is the header file
struct CountSign
{
TCHAR sCountSigners[STRING_LENGTH];
DWORD dwSignerSigned;
};
class CViewSigners : public CDialog
{
// Construction
public:
CViewSigners(CWnd* pParent = NULL); // standard constructor
void AddSignerToDisplay(TCHAR *psSignerName);
void AddCounterSignerToDisplay(TCHAR *psCountSignerName, DWORD dwIndexOfSigCountSigned);
// Dialog Data
//{{AFX_DATA(CViewSigners)
enum { IDD = IDD_SIGNER_DISPLAY };
CTreeCtrl m_tSignersView;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CViewSigners)
public:
virtual int DoModal();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
CImageList m_imageList;
// Generated message map functions
//{{AFX_MSG(CViewSigners)
virtual BOOL OnInitDialog();
virtual void OnCancel();
virtual void OnOK();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
TCHAR sSigners[STRING_LENGTH][MAX_SIGNERS];
//TCHAR sCountSigners[STRING_LENGTH][MAX_SIGNERS];
CountSign cCountSigners[MAX_SIGNERS];
UINT uiNumberOfSigners;
UINT uiNumberOfCountSigners;
};
//This is the bit that writes the data into the structure
void CViewSigners::AddCounterSignerToDisplay(TCHAR *psCountSignerName, DWORD dwIndexOfSigCountSigned)
{
if(uiNumberOfCountSigners == MAX_SIGNERS)
{
TCHAR *psErrorMessage;
TCHAR *psErrorTitle;
psErrorMessage = new TCHAR[STRING_LENGTH];
psErrorTitle = new TCHAR[STRING_LENGTH];
LoadString(_Module.GetModuleInstance(), IDS_MAX_CERTS, psErrorMessage, STRING_LENGTH);
LoadString(_Module.GetModuleInstance(), IDS_CERTERROR_TITLE, psErrorTitle, STRING_LENGTH);
MessageBox(psErrorMessage, psErrorTitle, MB_OK | MB_ICONWARNING);
delete[] psErrorMessage;
delete[] psErrorTitle;
}
else
{
strcpy(&cCountSigners[uiNumberOfCountSigners].sCountSigners[0], psCountSignerName);
cCountSigners[uiNumberOfCountSigners].dwSignerSigned = dwIndexOfSigCountSigned;
AfxMessageBox(cCountSigners[uiNumberOfCountSigners].sCountSigners);
char sTest[10];
_ultoa( cCountSigners[uiNumberOfCountSigners].dwSignerSigned ,sTest, 10);
AfxMessageBox(sTest);
uiNumberOfCountSigners++;
}
}
//This is the bit thats ment to read it out
BOOL CViewSigners::OnInitDialog()
{
CDialog::OnInitDialog();
HTREEITEM hItem[MAX_SIGNERS];
m_imageList.Create(IDB_SIGNER_TREE, 14, 1, RGB(255,0,0));
m_tSignersView.SetImageList(&m_imageList, TVSIL_NORMAL);
CViewSigners::SetWindowText("Signers");
//m_stSignersTitle = _T("File Signed By");
//UpdateData(FALSE);
TCHAR sTempCertName[STRING_LENGTH];
for(int i = 0; i < uiNumberOfSigners; i++)
{
hItem[i] = m_tSignersView.InsertItem(&sSigners[i][0], 0, 0);
}
for(int u = 0; u < uiNumberOfCountSigners; u++)
{
char sTest[10];
_ultoa( cCountSigners[u].dwSignerSigned ,sTest, 10);
AfxMessageBox(sTest);
AfxMessageBox(cCountSigners[i].sCountSigners);
strcpy(&sTempCertName[0], cCountSigners[i].sCountSigners);
AfxMessageBox(sTempCertName);
m_tSignersView.InsertItem(&sTempCertName[0], 1, 1, hItem[cCountSigners[i].dwSignerSigned]);
_strset(sTempCertName, NULL);
}
//hItem = m_tSignersView.InsertItem("Test", 0, 0);
//m_tSignersView.InsertItem("Test", 1, 1, hItem);
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
"Let's all join forces, rule with an iron hand...and prove to all the world, metal rules the land..."
-- Judas Priest
My email is [email protected]
-
Nov 2nd, 2001, 03:53 PM
#7
MFC-looking code is hard to read like this. At least for me.
Do you know about CODE & /CODE [code in brackets] around the C++ source you paste up?
Thanks.
-
Nov 2nd, 2001, 04:17 PM
#8
PowerPoster
PHP Code:
//This is the header file
struct CountSign
{
TCHAR sCountSigners[STRING_LENGTH];
DWORD dwSignerSigned;
};
class CViewSigners : public CDialog
{
// Construction
public:
CViewSigners(CWnd* pParent = NULL); // standard constructor
void AddSignerToDisplay(TCHAR *psSignerName);
void AddCounterSignerToDisplay(TCHAR *psCountSignerName, DWORD dwIndexOfSigCountSigned);
// Dialog Data
//{{AFX_DATA(CViewSigners)
enum { IDD = IDD_SIGNER_DISPLAY };
CTreeCtrl m_tSignersView;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CViewSigners)
public:
virtual int DoModal();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
CImageList m_imageList;
// Generated message map functions
//{{AFX_MSG(CViewSigners)
virtual BOOL OnInitDialog();
virtual void OnCancel();
virtual void OnOK();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
TCHAR sSigners[STRING_LENGTH][MAX_SIGNERS];
//TCHAR sCountSigners[STRING_LENGTH][MAX_SIGNERS];
CountSign cCountSigners[MAX_SIGNERS];
UINT uiNumberOfSigners;
UINT uiNumberOfCountSigners;
};
//This is the bit that writes the data into the structure
void CViewSigners::AddCounterSignerToDisplay(TCHAR *psCountSignerName, DWORD dwIndexOfSigCountSigned)
{
if(uiNumberOfCountSigners == MAX_SIGNERS)
{
TCHAR *psErrorMessage;
TCHAR *psErrorTitle;
psErrorMessage = new TCHAR[STRING_LENGTH];
psErrorTitle = new TCHAR[STRING_LENGTH];
LoadString(_Module.GetModuleInstance(), IDS_MAX_CERTS, psErrorMessage, STRING_LENGTH);
LoadString(_Module.GetModuleInstance(), IDS_CERTERROR_TITLE, psErrorTitle, STRING_LENGTH);
MessageBox(psErrorMessage, psErrorTitle, MB_OK | MB_ICONWARNING);
delete[] psErrorMessage;
delete[] psErrorTitle;
}
else
{
strcpy(&cCountSigners[uiNumberOfCountSigners].sCountSigners[0], psCountSignerName);
cCountSigners[uiNumberOfCountSigners].dwSignerSigned = dwIndexOfSigCountSigned;
AfxMessageBox(cCountSigners[uiNumberOfCountSigners].sCountSigners);
char sTest[10];
_ultoa( cCountSigners[uiNumberOfCountSigners].dwSignerSigned ,sTest, 10);
AfxMessageBox(sTest);
uiNumberOfCountSigners++;
}
}
//This is the bit thats ment to read it out
BOOL CViewSigners::OnInitDialog()
{
CDialog::OnInitDialog();
HTREEITEM hItem[MAX_SIGNERS];
m_imageList.Create(IDB_SIGNER_TREE, 14, 1, RGB(255,0,0));
m_tSignersView.SetImageList(&m_imageList, TVSIL_NORMAL);
CViewSigners::SetWindowText("Signers");
//m_stSignersTitle = _T("File Signed By");
//UpdateData(FALSE);
TCHAR sTempCertName[STRING_LENGTH];
for(int i = 0; i < uiNumberOfSigners; i++)
{
hItem[i] = m_tSignersView.InsertItem(&sSigners[i][0], 0, 0);
}
for(int u = 0; u < uiNumberOfCountSigners; u++)
{
char sTest[10];
_ultoa( cCountSigners[u].dwSignerSigned ,sTest, 10);
AfxMessageBox(sTest);
AfxMessageBox(cCountSigners[i].sCountSigners);
strcpy(&sTempCertName[0], cCountSigners[i].sCountSigners);
AfxMessageBox(sTempCertName);
m_tSignersView.InsertItem(&sTempCertName[0], 1, 1, hItem[cCountSigners[i].dwSignerSigned]);
_strset(sTempCertName, NULL);
}
//hItem = m_tSignersView.InsertItem("Test", 0, 0);
//m_tSignersView.InsertItem("Test", 1, 1, hItem);
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
-
Nov 2nd, 2001, 04:40 PM
#9
Monday Morning Lunatic
At least indent it first, I'm normally inclined not to bother even trying to read it if it's unindented.
And also it's MFC so...
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
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
|