Improve company productivity with a Business Account.Sign Up

x
?
Solved

Limiting CScrollView scrolling area

Posted on 1998-06-19
5
Medium Priority
?
335 Views
Last Modified: 2013-11-20
If you look at the display for a typical text file in Visual C++ you will see a grey area along the left hand border.  This prevents the characters from being placed too close to the left hand border, and gives a target area for mouse operations such as select line.  Scrolling does not effect the size of this area, it's always there.  Furthermore, the scroll bars go all the way to the left hand edge.

This is pretty slick, anyone know how it's done?  In particular I would like to do the same thing along the top of a vertically scrolling window.
0
Comment
Question by:jstolan
  • 3
5 Comments
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1318232
That window is not a CScrollView. That window is a special window written so that the scrolling does not scroll the gray area horizontally (but it does scroll vertically). This isn't too hard if you realize that the ScrollWindow() API contains a rectangle to scroll.

The scrollbars are not inside this window because it is a child of the MDI frame. The MDI frame sends messages to the window whenever it needs to be scrolled. So there's quite a bit of communciation between the MDI frame and the scrolling window. The scrollbars sends the scroll messages to the MDI frame, which in turns sends the scroll messages to the scrolling window.

Of course, when the MDI frame is resized, it resizes and repositions all of its children.
0
 
LVL 2

Author Comment

by:jstolan
ID: 1318233
thui

Thank you for your response.  However, I would really appreciate some sample code if you have it.  Or at least some direction as to where to find it.  I have quite a bit of code written based on a CScrollView class, and it's really not worth the effort to rewrite it just to get this added functionality.  Unless of course, I can get some sample code to lessen the effort.
0
 
LVL 1

Accepted Solution

by:
amby earned 300 total points
ID: 1318234
I think that in fact you have to create a Class derived from CView, in place of CScrollView...

the reasons are that if you derive it from CView, you are 100% handling scrolling code... And the implementation of that is very simple (I had once to translate a class from CSrollView-derived to CView derived, it is a little work but now it is working fine...)

what you have to do:

replace into the class declaration file:
class MyView : public CView
{
.

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMyView)

//}}AFX_VIRTUAL
.
//----- added to reposition the scrollers when have to
//{{AFX_MSG(CMyView)
afx_msg void OnSize(UINT nType, int cx, int cy);
//}}AFX_MSG
}

and in the definition file, do not forget:

IMPLEMENT_DYNCREATE(CMyView, CView)

BEGIN_MESSAGE_MAP(CMyView, CView)
      //{{AFX_MSG_MAP(CLangMgrTextView)
      ON_WM_SIZE()
      //}}AFX_MSG_MAP
END_MESSAGE_MAP()

To completely handle you scrolls, add 2 scrollers (=attributes of your class) to your application in the OnCreate member (handler of WM_CREATE):

int CMyView::OnCreate()
{
    m_hScroll.Create( SBS_HORZ | other_styles, rect, this, ID_HSCROLL );
    m_vScroll.Create( SBS_VERT | other_styles, rect, this, ID_HSCROLL );
}

to handle painting, I usually use an 'offset' attribute for eache sense:
int m_hOffset
int m_vOffset

do not forget to handle your WM_VSCROLL and WM_HSCROLL to handle scrolling (use the ScrollWindow function, which is fast)

I don't know if this is enough to help you, in fact if you do that in his way, I am really convinced that you will soon have good results

Good luck

0
 
LVL 1

Expert Comment

by:amby
ID: 1318235
you can try to handle the WM_WINDOWPOSCHANGING message,

the parameter of this massage is a structure containing the position of the window, try modifying them
0
 
LVL 1

Expert Comment

by:amby
ID: 1318236
hem... sorry... I suppose I tried to help someone else this time...

sorry about that last comment...
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
Microsoft Jet database engine errors can crop up out of nowhere to disrupt the working of the Exchange server. Decoding why a particular error occurs goes a long way in determining the right solution for it.
This tutorial will walk an individual through the process of installing of Data Protection Manager on a server running Windows Server 2012 R2, including the prerequisites. Microsoft .Net 3.5 is required. To install this feature, go to Server Manager…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

606 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