Solved

Drag & Drop in a CScrollView

Posted on 1998-07-04
1
393 Views
Last Modified: 2013-11-20
I'm implementing my own drag and drop of bitmaps in a CScrollView window. Right now I redraw the entire view for each movement, but this is not a good solution since I'm going to have quite a lot of graphics in this window. What is the most efficient way to do this? Can I somehow read a section of the view into memory, draw my bitmap there, and the next time redraw only that section and so on.
0
Comment
Question by:zingo
[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
1 Comment
 
LVL 3

Accepted Solution

by:
eugenem earned 100 total points
ID: 1318732
First thing you need is clipping. This means you need to repaint only what you need, not the whole view. For example, when you drag a bitmap, you take previous rectangle of the bitmap and current rectangle of bitmap and compute the smallest rectangle that contains both of these. Then you set this rectangle as a clipping rectangle and draw your view. It will automatically prevent any output to any place of your DC outside this rectangle.
To set clipping rectangle you can use
void CWnd::InvalidateRect( LPCRECT lpRect, BOOL bErase = TRUE );
If you want to get this rectangle from OnPaint, use
CPaintDC dc( this );
CRect rectUpdate;
dc.GetClipBox(&rectUpdate);

If you want some more serious clipping you can use CDC::SelectClipRgn. You should also look for CRgn.

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

705 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