BOOL CCSMessageRecon::OnInitDialog()
{
CDialog::OnInitDialog();
LVCOLUMN lvColumn;
int nColmn;
for(nColmn=0; nColmn<GetArrLength(m_columnWidth); nColmn++)
{
lvColumn.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
lvColumn.fmt = LVCFMT_LEFT;
lvColumn.cx = m_columnWidth[nColmn];
char txt[50];
strncpy(txt, m_columnHeading[nColmn].c_str(),m_columnHeading[nColmn].length()+1);
lvColumn.pszText =txt;
m_csmsg.InsertColumn(nColmn, &lvColumn);
}
return TRUE; // return TRUE unless you set the focus to a control
}
there is no problem in comilation. but got a link error. when I comment out the line, it will be fine. strncpy(txt, m_columnHeading[nColmn].c_str(),m_columnHeading[nColmn].length()+1);
I think you need to declare the variable as extern in the header file. Basically, in files that are using the variable other than the cpp where you define it, you need to specify extern, sort of like a prototype for a function.
but it doesn't work with extern. actually the m_columnHeading variable is a dialog class variable. the calling function and the varialbe are in the class context.