Re: Graphics - need to draw to the screen and then erase it

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Joćo Paulo Figueira [eMVP] (joao.figueira_at_primeworks.takethisout.pt)
Date: 04/25/04


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...
>
>


Relevant Pages

  • Graphics - need to draw to the screen and then erase it
    ... and then use lines to create a grid. ... I then draw sine-waves ontop of the ... So the user presses on the display with the stylus and a line is ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: Loading those huge CSVs.
    ... > a) use a TDrawgrid instead of a TStringgrid and use that as a virtual ... > grid would be able to display the first load of lines very fast, ... > you can use a number of tricks to cut down on memory use and load time. ...
    (borland.public.delphi.language.objectpascal)
  • Re: Q: Tip and advice on DataBase related question.
    ... don't try to display a million rows in a grid. ... could even use regex to identify the pattern to make for better ... don't try and hold it in memory all at once ...
    (microsoft.public.dotnet.languages.csharp)
  • MSFLEXGRID row selection error after
    ... I show some data in an MSHFlexGrid. ... when a user presses them I order my data differently and then I refresh ... my MSHFlexGrid to display the appropriate data. ... being displayed in the Grid. ...
    (microsoft.public.vb.general.discussion)
  • Re: No it doesnt
    ... result of the test to the calling routine, ... The second problem in the posted code concerns a possible memory leak. ... both cases (user press Print and user presses Cancel). ... For Each objPrinter In Printers ...
    (comp.lang.basic.visual.misc)