Solved

Drag & Drop in a CScrollView

Posted on 1998-07-04
1
388 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
1 Comment
 
LVL 3

Accepted Solution

by:
eugenem earned 100 total points
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Show shut-down message as Windows 8 shuts down. 9 74
Separate into files by filename 12 66
changeXy challenge 13 56
wordcount challenge 11 72
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now