Re: How to split a window into two... and I DON'T mean CSplitterWnd!
The only to get rid of the CFormView scrollbar is to call SetScrollSizes.
Here is what I would do, in your CFormView's WM_SIZE handler:
void CFormViewResizeView::OnSize(UINT nType, int cx, int cy)
{
CFormView::OnSize(nType, cx, cy);
//make sure that the controls are created.
//WM_SIZE is sent at least once before the controls are created.
if (m_Label.GetSafeHwnd())
{
CRect Rect;
GetClientRect(&Rect);
CRect CtrlRect;
m_Label.GetWindowRect(&CtrlRect);
//if the lable is already at 0,0, you can comment out this line!
m_Label.SetWindowPos(NULL,0,0,Rect.Width(),CtrlRect.Height(),SWP_NOZORDER);
//the edit control should take up the rest of the window
m_Edit.SetWindowPos(NULL,0,CtrlRect.Height(),Rect.Width()-0,Rect.Height()-CtrlRect.Height()-0,SWP_NOZORDER);
//the -50s are there to keep the scrollbar from flashing
SetScrollSizes(MM_TEXT,CSize(Rect.Width()-50,Rect.Height()-50));
}
}
When setting the scrollsize if you don't subtract a substantial amount from
the size, then when the window is shrunk the scrollbar will flash.
I found that 50 is a good number for keeping the scrollbar from flashing.
Also don't forget to set the WS_CLIPCHILDREN flag of the CFormView.
AliR.
"FIihelahd" <looseonthestreet@gmail.com> wrote in message
news:10f647cc-8487-4112-8366-988b101e8086@n33g2000pri.googlegroups.com...
Hello,
I have a window that was originally a CEdit.
Now, I wanted to put a little caption on top of it, to describe what
it does.
As far as I'm aware, the options are:
1) Use a CFormView, and use static text, then put a CEdit control
underneath it.
2) Use a CSplitterWnd, and put the caption in the upper half, and the
CEdit in the lower half.
Now, I tried option 1)
it looks like this:
http://img14.imageshack.us/img14/2227/doingitwrong.png
"Song Notes" is the caption I was talking about.
I want to split the window into two so that Song Notes is in the upper
dialog, and the CEdit is the lower part, taking up the entire lower
part.
but option 1) has a major flaw. It's a CHEAT and it looks
unprofessional. I made the example small so you can see what happens
if there's a scrollbar... it's the scrollbar of the outer window, not
of the CEdit... There should not be two separate sets of scrollbars...
it should be as if the "Song Notes" part was just split with a
CSplitter, and the lower CEdit is really taking up the whole frame
there...
option 2) sucks, you get a dumb splitter bar there which I don't want.
How do you do this right?