Resizing of CFormView

Hi:
I have a CMDIChildWindow to which I have attached CFormView.
My CFormView is derived from a Dialog Resource which has
a ListControl. I am using the following code to Resize the FormView

MyFormView:: OnSize(UINT nType, int cx, int cy)
{
      CFormView::OnSize(nType, cx, cy);
      if (::IsWindow (m_MyListCtrl.GetSafeHwnd ()))
      {                                
m_MyListCtrl.SetWindowPos(0,10,10,cx-25,cy-10,SWP_NOZORDE
R | SWP_NOMOVE);    
      };
as i resize, the space between the ListControl and the form border keeps varing. I want to keep this border space constant
and change the Control size only. And also the scrollbar
sometimes appears and sometimes does not.
Please suggest me the dehaviour of scroll bar
and also how to keep the border (space between list control and the edge of the formview)constant.
Thanks

LVL 1
MFCAnswerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MFCAnswerAuthor Commented:
Edited text of question.
0
Vinayak KumbarSr Program ManagerCommented:
Hi,

Try this code
CRect mrect;
CRect crect;
GetClientRect(&crect);
if(m_ScrollingList.m_hWnd)
{
      m_ScrollingList.GetWindowRect(&mrect);
      ScreenToClient(&mrect);
            m_ScrollingList.SetWindowPos(&m_ScrollingList.wndTop, mrect.left, mrect.top,
                  crect.right, cy+9, SWP_SHOWWINDOW | SWP_NOZORDER);
}

Only thing is u may have to reach some co-ordinate values after hit and trial method.

Try it out.

VinExpert
0
mikeblasCommented:
Do any of your windows have CS_BYTEALIGNCLIENT or CS_BYTEALIGNWINDOW?  I think that's your problem.

..B ekiM
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

MFCAnswerAuthor Commented:
VinExpert :
PLease tell me what is  m_ScrollingList ?

mikeblas:
none of my windows have CS_BYTEALIGNCLIENT or
CS_BYTEALIGNWINDOW.
0
MFCAnswerAuthor Commented:
Hello VinExpert and mikeblas,
please add further to ur comments
Thanks
0
MFCAnswerAuthor Commented:
Adjusted points to 100
0
mikeblasCommented:
> please add further to ur comments

Huh?  I can't understand that.

..B ekiM
0
Vinayak KumbarSr Program ManagerCommented:
Hi,

Sorry i forgot to mention it, it is same as ur m_MyListCtrl. U can replace that with Ur variable.

Cheers,
VinExpert

0
MFCAnswerAuthor Commented:
sorry, still does not work.
Thank you for all answers u gave.
0
Vinayak KumbarSr Program ManagerCommented:
Hi,

U have to find the proper co-ordinate values to use in the SetWindowPos(...) function. For my app  'mrect.left, mrect.top,                   crect.right, cy+9 ' gave the satisfactory results. But I got them by hit & trial method only. So I think u may also have to do the same to get proper values.

Best of luck.
VinExpert
0
wildyCommented:
Don't use OnSize. Instead use OnWindowPosChanging and OnWindowPosChanged.

something like this (pseudo-code):

OnWindowPosChanging(...)
{
   m_cliRect = GetClientRect;
   m_listRect = list.GetWindowRect;
   screentoclient(m_listrect);
}

OnWindowPosChanged(...)
{
   CRect newCliRect = GetClientRect;
   newSizeX = newCliRect.X - m_cliRect.X;
   newSizeY = newCliRect.Y - m_cliRect.Y;
   m_listRect.X = m_listRect.X + newSizeX;
   m_listRect.Y = m_listRect.Y + newSizeY;
   list.MoveWindow(m_listRect);
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.