Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Limiting CScrollView scrolling area

Posted on 1998-06-19
5
Medium Priority
?
333 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A Bare Metal Image backup allows for the restore of an entire system to a similar or dissimilar hardware. They are highly useful for migrations and disaster recovery. Bare Metal Image backups support Full and Incremental backups. Differential backup…
VM backup deduplication is a method of reducing the amount of storage space needed to save VM backups. In most organizations, VMs contain many duplicate copies of data, such as VMs deployed from the same template, VMs with the same OS, or VMs that h…
This tutorial will walk an individual through the process of configuring basic necessities in order to use the 2010 version of Data Protection Manager. These include storage, agents, and protection jobs. Launch Data Protection Manager from the deskt…
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…
Suggested Courses

972 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