Scrolling in CFormView
Hi Friends,
Thanks in advance.
I have an SDI application in which view is derived from CFormView
i.e
<b>class CquestionnaireView : public CFormView</b>
Now i have a menu option "add question" ; on click the menu option a
dialog is created in the form view i.e.
<b>void CquestionnaireView::OnOptionAddquestion()
{
// Dailog class
CQuestionDlg* pQuestionDlg = new CQuestionDlg(GetItemCount);
pQuestionDlg->Create(IDD_DLG_QUESTION, this);
// vector of dialogs
m_vecQuestionsDlg.push_back(pQuestionDlg);
// get the height
int nWidth = 0, nHeight = 0;// set sroll view size
for( UINT x = 0; x < m_vecQuestionsDlg.size(); ++x )
{
CRect rtQuestionDlg;
m_vecQuestionsDlg[x]->GetClientRect(rtQuestionDlg);
nHeight += rtQuestionDlg.Height();
}
CRect rtClient;
GetClientRect(rtClient);
// set scroll sizes
SetScrollSizes(MM_TEXT, CSize(rtClient.Width(), nHeight));
// reposition the dialog
pQuestionDlg->RepositionWindow();
}</b>
its location is ok; till i dont do verticle scrolling as I do verticle
scrolling and Add new dialog; dialog is not visible but it holds the
position in View.
Please tell me do I need to handle verticle scroll bar; if yes then
how to do it.
////////////// Repostion window code
<b>void CQuestionDlg::RepositionWindow(UINT nFlags)
{
int x, y; // width, height;
CRect rtClient, rtParent;
GetWindowRect(rtClient);
int nWidth = rtClient.Width();
int nHeight = rtClient.Height();
GetParent()->GetClientRect(rtParent);
/////// m_nIndex -------- is the dialog insert location i.e. 0, 1,
2... so on
x = 0;
y = 0 + m_nIndex* nHeight;
CRect rect(x, y, x + nWidth, y + nHeight);
SetWindowPos(NULL, rect.left, rect.top, rect.Width(), rect.Height(),
nFlags);
}</b>
Thanks,
Subhash