Re: Graphics - need to draw to the screen and then erase it
From: Joćo Paulo Figueira [eMVP] (joao.figueira_at_primeworks.takethisout.pt)
Date: 04/25/04
- Next message: Nelson: "Re: Colors /16 bpp"
- Previous message: patrox: "Re: upload a whole folder at once ?"
- In reply to: A.B.: "Graphics - need to draw to the screen and then erase it"
- Next in thread: A.B.: "Re: Graphics - need to draw to the screen and then erase it"
- Reply: A.B.: "Re: Graphics - need to draw to the screen and then erase it"
- Reply: A.B.: "Re: Graphics - need to draw to the screen and then erase it"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 25 Apr 2004 12:20:37 +0100
There are anumber of interesting articles on Code Project on the subject of
Memory DCs. These support off-screen drawing and fast bit blitting to the
screen - just what you need. Here's a sampling:
http://www.codeproject.com/bitmap/bitmapdc.asp
http://www.codeproject.com/gdi/rotated_dc.asp
http://www.codeproject.com/gdi/bufferdc.asp
(I used the words "memory DC" to search for them).
To avoid the red dots, just make sure your dialog's OnLButtonDown handler
calls Default() instead of the base class handler:
void CMyDialog::OnLbuttonDown(...)
{
// You code here
Default(); // <-- This removes the tap-and-hold processing
}
-- Joćo Paulo Figueira Embedded MVP "A.B." <someone@somewhere.com> wrote in message news:gdKdnc-cIKeZ3BbdRVn-uQ@comcast.com... > I'm working on a Dialog-based MFC project using eVC++ 4.0 > > This is what I'm doing that's working pretty well... All my line/rectangle > drawing is taking place inside the OnPaint() event. I draw a black rectangle > and then use lines to create a grid. I then draw sine-waves ontop of the > grid. (and I say it's working "pretty well" because there's a slight flicker > visible when I draw the black rectangle). > > I now want to add a feature to allow the user to measure peaks, etc. of the > sine waves. So the user presses on the display with the stylus and a line is > drawn in parallel with the x-axis at the y point of where the user pressed > on the display (I make a call to Invalidate(FALSE) to keep the background > and just draw the line quickly). This part works too... HOWEVER, having to > redraw the grid and the wave takes a while and it looks silly to totally > refresh the screen when the user quickly presses on the screen with the > stylus. > > What I'd like to do is: > 1) detect the stylus pressing on the display and get the x,y coordinates (I > know how to) > 2) before drawing the line over the sine-wave & grid I'd like to copy the > small area to memory first (I don't know how) > 3) draw the line to measure the amplitude of the sine wave (I know how) > 4) when the user presses somewhere else on the screen, erase the line by > copying the previously stored small area of the display over the line (I > don't know how) > > Other things I've noticed... when I hold the stylus down on the display (to > initate the "right-mouse click") and the animated red-dots disappear when I > let go, the small area under that animation will get-rid of my line but keep > the background sine wave and grid unchanged. So maybe I don't even have to > BitBlt the background to memory after all - I just recreate whatever the > Operating System does when it clears the red-dot animation. > > thankyou for any help... > >
- Next message: Nelson: "Re: Colors /16 bpp"
- Previous message: patrox: "Re: upload a whole folder at once ?"
- In reply to: A.B.: "Graphics - need to draw to the screen and then erase it"
- Next in thread: A.B.: "Re: Graphics - need to draw to the screen and then erase it"
- Reply: A.B.: "Re: Graphics - need to draw to the screen and then erase it"
- Reply: A.B.: "Re: Graphics - need to draw to the screen and then erase it"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|