Resize items in CDialogBar

I have a SDI app with docked CDialogBar at the bottom.  I have a control on 
this dialog bar that I need to size according to the frame wnd size.    This 
needs to be done when initially created and whenever the main frame / view is 
resized.

I've overridden OnSize on the main frame and my dialog bar class.  I've 
tried using SetWindowPos for the control (which happens to be a scroll bar) 
on the dialog bar.  It doesn't work.

I've added a public method ResizeControls on my dialog bar class and called 
it from my CMainFrame::OnSize.  That doesn't work either.

Any suggestions?

Thanks
0
11/9/2006 2:40:02 AM
vc.mfc 33608 articles. 0 followers. Follow

7 Replies
1760 Views

Similar Articles

[PageSpeed] 5

SetWindowPos on the control will work. Are you sure your code that uses this
method is being called? You will need to do it in OnSize of the dialogbar.

-- 
Ajay Kalra [MVP - VC++]
ajaykalra@yahoo.com


"Ronnie Turrentine" <RonnieTurrentine@discussions.microsoft.com> wrote in
message news:0AA78562-B993-4A6B-A792-40D1D83DCCED@microsoft.com...
> I have a SDI app with docked CDialogBar at the bottom.  I have a control
on
> this dialog bar that I need to size according to the frame wnd size.
This
> needs to be done when initially created and whenever the main frame / view
is
> resized.
>
> I've overridden OnSize on the main frame and my dialog bar class.  I've
> tried using SetWindowPos for the control (which happens to be a scroll
bar)
> on the dialog bar.  It doesn't work.
>
> I've added a public method ResizeControls on my dialog bar class and
called
> it from my CMainFrame::OnSize.  That doesn't work either.
>
> Any suggestions?
>
> Thanks


0
ajaykalra (6842)
11/9/2006 2:51:23 AM
Yes I'm sure its being called from OnSize of my CMyDialogBar class.  Here is 
how:

m_ctrlViewScrollBar.SetWindowPos(NULL, 0, 0, newWidth, scrollRect.Height(), 
SWP_NOMOVE | SWP_NOZORDER); 

Now I have noticed that my CMyDialogBar::OnSize only gets call during 
creation.  It does not get called when the mainframe is being resized.  The 
dialog bar is docked.  In fact, I would like to keep it docked and not allow 
the user to undock it.


"Ajay Kalra" wrote:

> SetWindowPos on the control will work. Are you sure your code that uses this
> method is being called? You will need to do it in OnSize of the dialogbar.
> 
> -- 
> Ajay Kalra [MVP - VC++]
> ajaykalra@yahoo.com
> 
> 
> "Ronnie Turrentine" <RonnieTurrentine@discussions.microsoft.com> wrote in
> message news:0AA78562-B993-4A6B-A792-40D1D83DCCED@microsoft.com...
> > I have a SDI app with docked CDialogBar at the bottom.  I have a control
> on
> > this dialog bar that I need to size according to the frame wnd size.
> This
> > needs to be done when initially created and whenever the main frame / view
> is
> > resized.
> >
> > I've overridden OnSize on the main frame and my dialog bar class.  I've
> > tried using SetWindowPos for the control (which happens to be a scroll
> bar)
> > on the dialog bar.  It doesn't work.
> >
> > I've added a public method ResizeControls on my dialog bar class and
> called
> > it from my CMainFrame::OnSize.  That doesn't work either.
> >
> > Any suggestions?
> >
> > Thanks
> 
> 
> 
-2
11/9/2006 3:05:02 AM


"Ronnie Turrentine" <RonnieTurrentine@discussions.microsoft.com> wrote in
message news:E17EA086-C3FC-4DFA-8F5B-6A7F229BD930@microsoft.com...
> Yes I'm sure its being called from OnSize of my CMyDialogBar class.  Here
is
> how:
>
> m_ctrlViewScrollBar.SetWindowPos(NULL, 0, 0, newWidth,
scrollRect.Height(),
> SWP_NOMOVE | SWP_NOZORDER);
>
> Now I have noticed that my CMyDialogBar::OnSize only gets call during
> creation.  It does not get called when the mainframe is being resized.
The
> dialog bar is docked.  In fact, I would like to keep it docked and not
allow
> the user to undock it.

I am not sure why this is not getting called. I can see some instances where
this would not happen. For example, if you simply increase mainframe's
width. I would expect increasing the height of mainframe triggers a OnSize.
You can use Spy++ and see what messages are being passed on to dialogbar.

-- 
Ajay Kalra [MVP - VC++]
ajaykalra@yahoo.com


0
ajaykalra (6842)
11/9/2006 3:15:58 AM
"Ajay Kalra" wrote:
> 
> "Ronnie Turrentine" <RonnieTurrentine@discussions.microsoft.com> wrote in
> message news:E17EA086-C3FC-4DFA-8F5B-6A7F229BD930@microsoft.com...
> > Yes I'm sure its being called from OnSize of my CMyDialogBar class.  Here
> is
> > how:
> >
> > m_ctrlViewScrollBar.SetWindowPos(NULL, 0, 0, newWidth,
> scrollRect.Height(),
> > SWP_NOMOVE | SWP_NOZORDER);
> >
> > Now I have noticed that my CMyDialogBar::OnSize only gets call during
> > creation.  It does not get called when the mainframe is being resized.
> The
> > dialog bar is docked.  In fact, I would like to keep it docked and not
> allow
> > the user to undock it.
> 
> I am not sure why this is not getting called. I can see some instances where
> this would not happen. For example, if you simply increase mainframe's
> width. I would expect increasing the height of mainframe triggers a OnSize.
> You can use Spy++ and see what messages are being passed on to dialogbar.
> 
> -- 
> Ajay Kalra [MVP - VC++]
> ajaykalra@yahoo.com
> 

If I remove the SWP_NOMOVE flag from the call, I can move move the 
scrollbar.  I still haven't been able to resize it though.

-1
11/9/2006 4:57:02 AM
"Ronnie Turrentine" wrote:

> "Ajay Kalra" wrote:
> > 
> > "Ronnie Turrentine" <RonnieTurrentine@discussions.microsoft.com> wrote in
> > message news:E17EA086-C3FC-4DFA-8F5B-6A7F229BD930@microsoft.com...
> > > Yes I'm sure its being called from OnSize of my CMyDialogBar class.  Here
> > is
> > > how:
> > >
> > > m_ctrlViewScrollBar.SetWindowPos(NULL, 0, 0, newWidth,
> > scrollRect.Height(),
> > > SWP_NOMOVE | SWP_NOZORDER);
> > >
> > > Now I have noticed that my CMyDialogBar::OnSize only gets call during
> > > creation.  It does not get called when the mainframe is being resized.
> > The
> > > dialog bar is docked.  In fact, I would like to keep it docked and not
> > allow
> > > the user to undock it.
> > 
> > I am not sure why this is not getting called. I can see some instances where
> > this would not happen. For example, if you simply increase mainframe's
> > width. I would expect increasing the height of mainframe triggers a OnSize.
> > You can use Spy++ and see what messages are being passed on to dialogbar.
> > 
> > -- 
> > Ajay Kalra [MVP - VC++]
> > ajaykalra@yahoo.com
> > 
> 
> If I remove the SWP_NOMOVE flag from the call, I can move move the 
> scrollbar.  I still haven't been able to resize it though.
> 

New details...

I can get it resize initially.  The problem is my OnSize method doesn't get 
called when the user resizes the application window even though the 
CMainFrame::OnSize does get called.

For now, I call my CMyDialogBar::ResizeControls from CMainFrame::OnSize 
method.  What I noticed is that I call GetClientRect from the ResizeControls 
method but the width does not reflect the new width of the main frame.

0
11/9/2006 5:12:01 AM
Also CControlBar provides CalcDynamicLayout and CalcFixedLayout which
essentially provides a feedback for sizing the CControlBar. Perhaps that has
something to do with it. Regardless I would expect OnSize to be called.

-- 
Ajay Kalra [MVP - VC++]
ajaykalra@yahoo.com


"Ronnie Turrentine" <RonnieTurrentine@discussions.microsoft.com> wrote in
message news:A39DE942-C86B-4B3E-B030-40662167D866@microsoft.com...
> "Ronnie Turrentine" wrote:
>
> > "Ajay Kalra" wrote:
> > >
> > > "Ronnie Turrentine" <RonnieTurrentine@discussions.microsoft.com> wrote
in
> > > message news:E17EA086-C3FC-4DFA-8F5B-6A7F229BD930@microsoft.com...
> > > > Yes I'm sure its being called from OnSize of my CMyDialogBar class.
Here
> > > is
> > > > how:
> > > >
> > > > m_ctrlViewScrollBar.SetWindowPos(NULL, 0, 0, newWidth,
> > > scrollRect.Height(),
> > > > SWP_NOMOVE | SWP_NOZORDER);
> > > >
> > > > Now I have noticed that my CMyDialogBar::OnSize only gets call
during
> > > > creation.  It does not get called when the mainframe is being
resized.
> > > The
> > > > dialog bar is docked.  In fact, I would like to keep it docked and
not
> > > allow
> > > > the user to undock it.
> > >
> > > I am not sure why this is not getting called. I can see some instances
where
> > > this would not happen. For example, if you simply increase mainframe's
> > > width. I would expect increasing the height of mainframe triggers a
OnSize.
> > > You can use Spy++ and see what messages are being passed on to
dialogbar.
> > >
> > > -- 
> > > Ajay Kalra [MVP - VC++]
> > > ajaykalra@yahoo.com
> > >
> >
> > If I remove the SWP_NOMOVE flag from the call, I can move move the
> > scrollbar.  I still haven't been able to resize it though.
> >
>
> New details...
>
> I can get it resize initially.  The problem is my OnSize method doesn't
get
> called when the user resizes the application window even though the
> CMainFrame::OnSize does get called.
>
> For now, I call my CMyDialogBar::ResizeControls from CMainFrame::OnSize
> method.  What I noticed is that I call GetClientRect from the
ResizeControls
> method but the width does not reflect the new width of the main frame.
>


0
ajaykalra (6842)
11/9/2006 5:56:10 AM
I plan to override those methods now.  I would expect OnSize to be called as 
well but it's not.

I am able to call my on resize method from the mainframe's OnSize and that 
works.  My problem there was that my scrollbar wouldn't go past a certain 
size unless I made the dialog template really big.  I guess my dialog bar 
size isn't really growing and it was limiting my scrollbar size.

Thanks for your patience and help.... it was a late night!

"Ajay Kalra" wrote:

> Also CControlBar provides CalcDynamicLayout and CalcFixedLayout which
> essentially provides a feedback for sizing the CControlBar. Perhaps that has
> something to do with it. Regardless I would expect OnSize to be called.
> 
> -- 
> Ajay Kalra [MVP - VC++]
> ajaykalra@yahoo.com
> 
> 
> "Ronnie Turrentine" <RonnieTurrentine@discussions.microsoft.com> wrote in
> message news:A39DE942-C86B-4B3E-B030-40662167D866@microsoft.com...
> > "Ronnie Turrentine" wrote:
> >
> > > "Ajay Kalra" wrote:
> > > >
> > > > "Ronnie Turrentine" <RonnieTurrentine@discussions.microsoft.com> wrote
> in
> > > > message news:E17EA086-C3FC-4DFA-8F5B-6A7F229BD930@microsoft.com...
> > > > > Yes I'm sure its being called from OnSize of my CMyDialogBar class.
> Here
> > > > is
> > > > > how:
> > > > >
> > > > > m_ctrlViewScrollBar.SetWindowPos(NULL, 0, 0, newWidth,
> > > > scrollRect.Height(),
> > > > > SWP_NOMOVE | SWP_NOZORDER);
> > > > >
> > > > > Now I have noticed that my CMyDialogBar::OnSize only gets call
> during
> > > > > creation.  It does not get called when the mainframe is being
> resized.
> > > > The
> > > > > dialog bar is docked.  In fact, I would like to keep it docked and
> not
> > > > allow
> > > > > the user to undock it.
> > > >
> > > > I am not sure why this is not getting called. I can see some instances
> where
> > > > this would not happen. For example, if you simply increase mainframe's
> > > > width. I would expect increasing the height of mainframe triggers a
> OnSize.
> > > > You can use Spy++ and see what messages are being passed on to
> dialogbar.
> > > >
> > > > -- 
> > > > Ajay Kalra [MVP - VC++]
> > > > ajaykalra@yahoo.com
> > > >
> > >
> > > If I remove the SWP_NOMOVE flag from the call, I can move move the
> > > scrollbar.  I still haven't been able to resize it though.
> > >
> >
> > New details...
> >
> > I can get it resize initially.  The problem is my OnSize method doesn't
> get
> > called when the user resizes the application window even though the
> > CMainFrame::OnSize does get called.
> >
> > For now, I call my CMyDialogBar::ResizeControls from CMainFrame::OnSize
> > method.  What I noticed is that I call GetClientRect from the
> ResizeControls
> > method but the width does not reflect the new width of the main frame.
> >
> 
> 
> 
0
11/9/2006 2:20:01 PM
Reply:

Similar Artilces: