Google Answers Logo
View Question
 
Q: Visual C++ / MFC Scrollbars infuriating behavior. ( No Answer,   2 Comments )
Question  
Subject: Visual C++ / MFC Scrollbars infuriating behavior.
Category: Computers > Programming
Asked by: emtavano-ga
List Price: $10.00
Posted: 06 Jun 2002 13:06 PDT
Expires: 08 Jun 2002 00:37 PDT
Question ID: 23348
It's been a little while since I've done MFC, so there's probably an
obvious step I'm missing in this process, or else I am insane.  You be
the judge.

I am writing a form-based single document application, with a
CFormView as the base view class.  I have two rich edit controls which
I want to scroll using a single scrollbar.  In the dialog editor, I
dropped what I believe is called the common controls scrollbar
(vertical) into the dialog.  It's the scrollbar right on the dialog
editor toolbar, not an activex control.

If you try this and then test the dialog, you will see that when you
drag the scroll box, it always snaps back up to the top.

I can't seem to change this behavior.  I assigned it a member variable
and set the range with SetScrollRange.  I tried SetScrollPos.   I
tried SetScrollInfo.
The WM_VSCROLL message is being sent correctly, but the nPos parameter
in the overridden function is always zero.

How do you make this thing act like a scrollbar?  How do you make the
nPos parameter come back with a value?

I need that specific question answered.  I don't need any more
alternative approaches to the problem, such as splitter windows, using
the rich edit control scroll bars, etc.

Thank you.

Request for Question Clarification by davidmaymudes-ga on 06 Jun 2002 16:01 PDT
can you post the code you're using to call SetScrollRange?  It sounds
as though your scrollbar is still set to have a range of 0-0, so I'm
thinking perhaps either you're calling SetScrollRange on the wrong
window (need to call GetDlgItem to get the hwnd of the scrollbar
itself) or you're not calculating the proper maximum you want to
use....
 
the comment about the member variable below worries me; I can't
remember whether that works or not, but in any case that would only
apply at data exchange time when the dialog is going away, and
wouldn't be filled in while the dialog is up.... 
Answer  
There is no answer at this time.

Comments  
Subject: Re: Visual C++ / MFC Scrollbars infuriating behavior.
From: adamf-ga on 07 Jun 2002 10:20 PDT
 
Check out this sample sourcecode for handling a scrollbar. It explains
all the scrollbar behaviour and how to programatically handle the
scroll bar controls messages. Some additional info can be found at the
comments below the source code:

http://www.codeguru.com/controls/scrollbar_handling.shtml

If this is not what you needed, let me know what more information you
need and I would be happy to provide it for you.

AdamF - Researcher Applicant
Subject: Re: Visual C++ / MFC Scrollbars infuriating behavior.
From: emtavano-ga on 08 Jun 2002 00:37 PDT
 
I had actually seen that page on Codeguru already but couldn't get
that example to work either.  But as so often happens, when you leave
a problem alone for a few days, when you come back the solution is
obvious.

That IS the answer and good for you for finding it, adamf.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy