Archived

This topic is now archived and is closed to further replies.

CProgrammer

MFC CView window scrolling

Recommended Posts

Like the title says. How do I add two scrollbars to my MFC app, at the bottom and right of my CView field. I then want to retrieve position data from these scrollbars. Any ideas? Thanks in advance -CProgrammer

Share this post


Link to post
Share on other sites
Yeah, there's a couple of ways of doing it:

1. Use CScrollView in place of CView. CScrollView has built-in support for scrolling in a GDI-based application. However, I'm thinking this isn't what you want (I toyed with it for an OpenGL-enabled CView, it didn't work with OpenGL at all), so...

2. You could use the Win32 method, and specify WS_HSCROLL and WS_VSCROLL when the view is created. You'll need to override PreCreateWindow, and modify the style attribute of the CREATESTRUCT that's passed like this: cs.style |= WS_HSCROLL | WS_VSCROLL; Then, set up message handlers to catch WM_HSCROLL and WM_VSCROLL messages. You can set the parameters of the scroll bars by using the Win32 scrollbar functions supported by the CView, namely pView->SetScrollRange, pView->SetScrollPos and pView->SetScrollInfo. Hope this helps...


Windows 95 - 32 bit extensions and a graphical shell for a 16 bit patch
to an 8 bit operating system originally coded for a 4 bit microprocessor,
written by a 2 bit company that can't stand 1 bit of competition.


[edited by - iNsAn1tY on January 5, 2004 1:11:09 PM]

Share this post


Link to post
Share on other sites