Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CScrollView in a static CSplitterWnd pane

Posted on 1997-04-06
10
Medium Priority
?
1,009 Views
Last Modified: 2013-11-20
I am trying to put a CScrollView-derived view in
the lower right pane of a CSplitterWnd with 4 static
panes, using MSVC 4.0.  The other three panes are
derived from CView.

This worked fine in my last 16-bit app (MSVC 1.52)
but with MSVC 4.0, calling ResizeParentToFit() from
the OnSize() method of CScrollView only works properly
if both dimensions of the pane are smaller than the
logical view size (and both the horiz and vert
scrollbars appear).  If only one dimension is smaller,
then 1 scrollbar should appear, but it doesn't.

Stepping through the OnSize() code, the scrollbar actually
does appear, but disappears shortly thereafter (I believe
that it disappears when the View background is erased).  
The scrollbar disappears sometime after all OnSize()
methods have been processed by the four views, the
CSplitterWnd, and the enclosing CFrameWnd.  It is gone by
the time CScrollView::OnDraw() is called.  I don't know
what else to trap to narrow down the problem.
0
Comment
Question by:pschimpf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 

Author Comment

by:pschimpf
ID: 1300883
Adjusted points to 100
0
 
LVL 4

Expert Comment

by:mbhakta
ID: 1300884
If you read your Visual C++ docs carefully under the topic ResizeParentToFit() it says, this call should be used in the OnInitialUpdate() functions and guarantees no rational behaviour if misused. There might lie the answer for your problem.
0
 

Author Comment

by:pschimpf
ID: 1300885
The Visual C++ on-line references state that you should call
ResizeParentToFit() from OnInitialUpdate(), but NOT that this
is the ONLY place it should be called from.  In fact, if you
look at the help for SetScrollSizes() you will see an example
implementation of OnUpdate() that calls ResizeParentToFit().
This is the same place that I am calling it from, so there is
no reason to conclude that I am misusing it.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:pschimpf
ID: 1300886
Adjusted points to 200
0
 

Author Comment

by:pschimpf
ID: 1300887
Edited text of question
0
 

Author Comment

by:pschimpf
ID: 1300888
Sorry, I am actually calling ResizeParentToFit() from OnSize(),
not OnUpdate(), but I still see no reason that this is a
misuse of ResizeParentToFit().  It is actually the logical
place to call it from, because I wish the view window to be
no larger than the actual size of the document.  If the user
resizes the window to be larger (which results in a call to
OnSize()), then a call to ResizeParentToFit() should reduce
the view window back down to the proper size, and it does!
Its just that under the right circumstances, it also removes
a scroll bar, which it should not do.
0
 
LVL 1

Expert Comment

by:rhgaracci
ID: 1300889
Try the following in OnSize() instead of calling the CScrollView::OnSize()

CView::OnSize(nType, cx, cy);
ResizeParentToFit();
UpdateBars();
0
 

Author Comment

by:pschimpf
ID: 1300890
Interesting (because MSVC 4.0 has no help entry for
UpdateBars(), but it did compile).  Unfortunately,
it didn't help.  I do have a new clue, however:
I normally run with:
 
Control Panel/Display/Plus!/Show Window Contents while Dragging
turned off (not checked)

But if I turn it on, my Splitter window flickers as the Window
is being resized.  You can see it draw the scrollbar at the
stretched out size and then snap back to the ResizeWindowToFit()
size - without the ScrollBars being redrawn!  AND, a final
snap back to the ResizeParentToFit() size doesn't happen when
the mouse button is released - although it DOES when Show
Window Contents while Dragging is off!

It seems like the OnSize() method is being called while the
window is being resized, but the documentation says that it
should be called when the resizing is complete (i.e., when
you release the mouse button).  The documentation also discusses
another member function:  OnSizing() as opposed to OnSize().
But guess what?  The class wizard won't let you connect
OnSizing()!  Is the message map calling OnSize() when it should
be calling OnSizing()?  If so, is there a fix?  

If someone wants to play with this, I would be glad to email them
a small project that illustrates the problem.  Contact me at
Paul_Schimpf@atk.com.  If you find a fix, I will give you an
Excellent score, no matter how kludgy the fix is.  I'm convinced
that this is a hard one.  I'll increase the points as they become
available to me.

0
 

Author Comment

by:pschimpf
ID: 1300891
OK, I have an answer:

Do NOT call ResizeParentToFit() from inside OnSize().
Instead, use PostMessage() to post a user-defined message.
Create a handler for that user-defined message that calls
ResizeParentToFit().

This works, although I have no satisfactory explanation for
why calling ResizeParentToFit() from OnSize() directly doesn't,
and neither does Microsoft Tech support, although they have
aknowledged the problem and suggested this fix.

They also suggested creating my own ResizeToFit at the frame
window level.  At this level though, you have to account for
the width of scrollbars and splitter bars, etc.  Any easy way
to do that might be to start by maximizing everything by calling
ResizeParentToFit(FALSE) in the OnInitialUpdate() method of
the CScrollView-derived class, then recording the size of the
frame window client area, and then not allow the frame window
area to be stretched beyond that size in the OnSizing() method
of the frame window.  Of course, if you have zoom levels (like
I do), it gets a little more complicated...

0
 
LVL 2

Accepted Solution

by:
cathys earned 400 total points
ID: 1300892
(submitted for pschimpf)

OK, I have an answer:

Do NOT call ResizeParentToFit() from inside OnSize().
Instead, use PostMessage() to post a user-defined message.
Create a handler for that user-defined message that calls
ResizeParentToFit().

This works, although I have no satisfactory explanation for
why calling ResizeParentToFit() from OnSize() directly doesn't,
and neither does Microsoft Tech support, although they have
aknowledged the problem and suggested this fix.

They also suggested creating my own ResizeToFit at the frame
window level. At this level though, you have to account for
the width of scrollbars and splitter bars, etc. Any easy way
to do that might be to start by maximizing everything by calling
ResizeParentToFit(FALSE) in the OnInitialUpdate() method of
the CScrollView-derived class, then recording the size of the
frame window client area, and then not allow the frame window
area to be stretched beyond that size in the OnSizing() method
of the frame window. Of course, if you have zoom levels (like
I do), it gets a little more complicated...

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question