Click here to Skip to main content
15,887,027 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
SuggestionRe: help me write a program Pin
David Crow30-Jan-17 2:19
David Crow30-Jan-17 2:19 
AnswerRe: help me write a program Pin
Patrice T28-Jan-17 13:10
mvePatrice T28-Jan-17 13:10 
Questionhow do i write this program? Pin
Member 1296870326-Jan-17 0:03
Member 1296870326-Jan-17 0:03 
AnswerRe: how do i write this program? Pin
Jochen Arndt26-Jan-17 0:29
professionalJochen Arndt26-Jan-17 0:29 
GeneralRe: how do i write this program? Pin
Stefan_Lang26-Jan-17 19:58
Stefan_Lang26-Jan-17 19:58 
AnswerRe: how do i write this program? Pin
Patrice T28-Jan-17 13:15
mvePatrice T28-Jan-17 13:15 
QuestionPerformance issue when drawing on MFC Pin
Member 162132325-Jan-17 10:59
Member 162132325-Jan-17 10:59 
AnswerRe: Performance issue when drawing on MFC Pin
leon de boer25-Jan-17 18:25
leon de boer25-Jan-17 18:25 
You are basically building a version of windows within windows Smile | :)

Buffering won't really help you that much, the problem is you are redrawing 50 shapes when you move one shape (look at your code you do 1..numberObjects) and most of the time you don't need to redraw them. What you need to do is calculate what shapes overlap where your shape to move is now, and what shapes overlap the move shape in it's new position. Then you only need to draw those limited shapes. Much of the time you only needed to redraw probably 1-3 shapes but you are drawing everything.

You can then get even smarter like windows and do only redraw partial areas. Do you see the next step from above in those cases you do have to redraw from above often you don't have to redraw the entire thing just a limited area. So you are minimizing the redrawing.

If you aren't going to have thousands I can give a quick hack which is to put each shape on it's own child window. That child window has frames off and have no background color and simply draws that shape just like your code does on the one parent window. Do you get what will happen the window is transparent except the area you draw on, in the old days we called them sprites. To move the shape just issue a window MoveWindow command to that child window handle and it will move and do minimum overlapping window redraws for you for free ..... because that is what windows does with a window move Smile | :)

I will give you the other thing about that trick the selection of the shapes is a lot easier probably than you current code because windows will sort all the overlapping for you.

That all said the often better way to do this is to simply XOR draw a rectangle representing the object and move just the XOR box with the mouse. When you get to where you want it you do the release and only then redraw everything. I assume you know the trick with XOR drawing if not
Combining GDI and GDI+ to Draw Rubber Band Rectangles[^]
In vino veritas


modified 26-Jan-17 0:42am.

GeneralRe: Performance issue when drawing on MFC Pin
Member 162132326-Jan-17 10:28
Member 162132326-Jan-17 10:28 
GeneralRe: Performance issue when drawing on MFC Pin
leon de boer26-Jan-17 17:50
leon de boer26-Jan-17 17:50 
Questionfree memory when constructor throw exception Pin
john563219-Jan-17 17:49
john563219-Jan-17 17:49 
AnswerRe: free memory when constructor throw exception Pin
rxantos19-Jan-17 19:05
rxantos19-Jan-17 19:05 
AnswerRe: free memory when constructor throw exception Pin
«_Superman_»19-Jan-17 19:32
professional«_Superman_»19-Jan-17 19:32 
AnswerRe: free memory when constructor throw exception Pin
Albert Holguin20-Jan-17 10:14
professionalAlbert Holguin20-Jan-17 10:14 
QuestionSend data to POS Printer by USB Pin
Member 1286002219-Jan-17 16:10
Member 1286002219-Jan-17 16:10 
AnswerRe: Send data to POS Printer by USB Pin
«_Superman_»19-Jan-17 19:48
professional«_Superman_»19-Jan-17 19:48 
SuggestionRe: Send data to POS Printer by USB Pin
David Crow20-Jan-17 3:15
David Crow20-Jan-17 3:15 
QuestionLight weight solution for distrubted memory map Pin
Member 380393118-Jan-17 16:12
Member 380393118-Jan-17 16:12 
QuestionGdiplus: DrawImage not working Pin
Member 162132314-Jan-17 3:28
Member 162132314-Jan-17 3:28 
AnswerRe: Gdiplus: DrawImage not working Pin
leon de boer14-Jan-17 23:45
leon de boer14-Jan-17 23:45 
GeneralRe: Gdiplus: DrawImage not working Pin
Member 162132325-Jan-17 10:57
Member 162132325-Jan-17 10:57 
Questionwhat?where? Pin
Member 1294982214-Jan-17 1:54
Member 1294982214-Jan-17 1:54 
AnswerRe: what?where? Pin
Afzaal Ahmad Zeeshan14-Jan-17 2:59
professionalAfzaal Ahmad Zeeshan14-Jan-17 2:59 
AnswerRe: what?where? Pin
Patrice T14-Jan-17 16:03
mvePatrice T14-Jan-17 16:03 
AnswerRe: what?where? Pin
jeron116-Jan-17 5:15
jeron116-Jan-17 5:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.