Re: Scrolling in CFormView
I'm a little confused on your setup.
CFormView is normally for your main application window. It should be visible
for the life of your application.
On the other hand, if you want to display a dialog box to get user data in
response to the user selecting a command, then you should create a new
dialog box--preferrably not one derived from CFormView.
What are you doing differently?
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
http://www.softcircuits.com/blog/
"Nee" <Smadhukar2000@gmail.com> wrote in message
news:030848aa-19a0-4e4c-a5f7-b1a9e995adff@35g2000pry.googlegroups.com...
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