• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 763
  • Last Modified:

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

0
MFCAnswer
Asked:
MFCAnswer
  • 5
  • 3
  • 2
  • +1
1 Solution
 
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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 5
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now