Re: Attaching a control to a CDialog
On May 29, 7:54 am, Nicholas Meyer <npme...@NOSPAM.gmail.com> wrote:
Hi jc,
Is there a good reason for you to create this control dynamically? If
not, then using DDX_Control is much simpler.
Create a private BitTimingList member in your class (not a pointer) then
in your dialog's DoDataExchange function, put the line:
DDX_Control(pDX, IDC_BITTIMING_LIST, m_bitTimingList);
This way, your BitTimingList class "takes over" (technically,
"subclasses") the list control that came on the dialog... no need to put
another on top of the existing one. This may well solve your problem.
You need to make sure that if you've implemented an OnCreate() function
in your list class that you duplicate the code in PreSubclassWindow(),
because OnCreate() is not called at the right time when using this
technique, only PreSubclassWindow.
i never heard of ddx_control before. that's why i never used it. i'm
going to do more research on that, and see how i can fit it to my
needs
i tried your advise. the result is same, i.e., the focus never stays
on the list, the selected row is always grayed (because i used the
style show row always)
but now i don't have to dynamically create the list instead
BitTimingList *editCtrl;
editCtrl = (BitTimingList *)GetDlgItem(IDC_BITTIMING_LIST);
editCtrl->SetParentPointer(this);
editCtrl->Init();
for(i = 0;i < m_nListCount;i++){
AddItemByIndex(editCtrl, i, m_pParamList[i]);
}
m_nCurrSelection = ReturnParamIndex(tempSt.nBTR0, tempSt.nBTR1,
m_pParamList, m_nListCount);
if(m_nCurrSelection != -1)
editCtrl->SelectItem(m_nCurrSelection);
else
editCtrl->SelectItem(0);
editCtrl->SetFocus();
and the data exchange is like this
void CBitTimingConfig::DoDataExchange(CDataExchange* pDX){
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_BITTIMING_LIST, m_BitTimingList);
}
i don't have an oncreate or presubclasswindow function in my list and
will see whether i need that or not
thanks again
jayachandran kamaraj