Home > Archive > Visual Studio > October 2004 > BitBlt operations overwrite existing bitmap controls in the dialog
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
BitBlt operations overwrite existing bitmap controls in the dialog
|
|
|
| I am using Visual C++ 6.0 to design a dialog-based GUI.
I first put a few CStatic bitmap controls in the dialog with ResourceView,
then I decide to draw a solid square and a few circles underneath as
background. To draw the background, I first created a compatible memory
device, then draw on the memory device, finally use Bitblt function to copy
the memory device context to the current device context. The centers of the
solid square and circles are not static, actually every second my software
redraw them. However, I found only for the first second the CStatic bitmap
controls are displayed in the dialog, then it disappeared, obviously was
overwritten by the "background".
It me since the same codes I wrote in eMbedded Visual C++ 4.0
worked perfect for PPC2003, and the bitmap controls were never overwritten
by the background.
I partly solved this problem by setting the visibility state of the bitmap
controls to off and then on for every second. However, I do not like the
flicker associated.
Could anybody please help me solve the problem? Thanks in advance.
John
//////////////////////////////////////////////////////////////
Iin Resource file, the control is defined as :
CONTROL 213,IDC_AZIMUTH_E,"Static",SS_BITMAP | NOT WS_VISIBLE |
WS_EX_TOPMOST,
123,121,15,13
Codes::
//Define the Memory Bitmap. Required!
CBitmap memBitmap;
memBitmap.CreateCompatibleBitmap (&clientDC,
SCREEN_WIDTH,
SCREEN_LENGTH); //Width, Height
dlgDC.SelectObject (&memBitmap);
// codes to draw on the memory device
..
..
..
//
clientDC.BitBlt(xStart, yStart,
SCREEN_WIDTH, SCREEN_LENGTH,
& dlgDC, xStart, yStart, SRCCOPY) ;
| |
| Gary Chanson 2004-10-01, 8:56 pm |
| The right way to do this would be to attach your redraw code to the
WM_ERASEBKGND message instead of to a timer. Then, your code will only be
executed when it's needed and in the correct sequence to avoid overwriting
your controls.
--
-GJC [MS Windows SDK MVP]
-Software Consultant (Embedded systems and Real Time Controls)
- http://www.mvps.org/ArcaneIncantations/consulting.htm
-gchanson@mvps.org
"JohnL" <hiliuzhe@hotmail.com> wrote in message
news:%232q5zBBqEHA.3300@TK2MSFTNGP12.phx.gbl...
> I am using Visual C++ 6.0 to design a dialog-based GUI.
>
> I first put a few CStatic bitmap controls in the dialog with ResourceView,
> then I decide to draw a solid square and a few circles underneath as
> background. To draw the background, I first created a compatible memory
> device, then draw on the memory device, finally use Bitblt function to
copy
> the memory device context to the current device context. The centers of
the
> solid square and circles are not static, actually every second my software
> redraw them. However, I found only for the first second the CStatic bitmap
> controls are displayed in the dialog, then it disappeared, obviously was
> overwritten by the "background".
>
> It me since the same codes I wrote in eMbedded Visual C++ 4.0
> worked perfect for PPC2003, and the bitmap controls were never overwritten
> by the background.
>
> I partly solved this problem by setting the visibility state of the bitmap
> controls to off and then on for every second. However, I do not like the
> flicker associated.
>
> Could anybody please help me solve the problem? Thanks in advance.
>
> John
>
> //////////////////////////////////////////////////////////////
>
> Iin Resource file, the control is defined as :
>
> CONTROL 213,IDC_AZIMUTH_E,"Static",SS_BITMAP | NOT WS_VISIBLE |
> WS_EX_TOPMOST,
> 123,121,15,13
>
> Codes::
>
> //Define the Memory Bitmap. Required!
> CBitmap memBitmap;
> memBitmap.CreateCompatibleBitmap (&clientDC,
> SCREEN_WIDTH,
> SCREEN_LENGTH); //Width, Height
> dlgDC.SelectObject (&memBitmap);
>
>
> // codes to draw on the memory device
> .
> .
> .
> //
>
> clientDC.BitBlt(xStart, yStart,
> SCREEN_WIDTH, SCREEN_LENGTH,
> & dlgDC, xStart, yStart, SRCCOPY) ;
>
>
>
>
>
>
| |
|
|
The problem is I want to control the update of the plots by my program, not
by windows. Since every time after I received some data from the serial
port, I wanted to update the plots accordingly. If I put the redraw code to
WM_ERASEBKGND message handler, and call InValidateRect or InValidate in the
timer or the serial data processing function, I will still see the flicker
since my plots are pretty big, almost the same size as the windows.
John
"Gary Chanson" <gchanson@No.Spam.TheWorld.net> wrote in message
news:%23pbJ5NBqEHA.708@tk2msftngp13.phx.gbl...
> The right way to do this would be to attach your redraw code to the
> WM_ERASEBKGND message instead of to a timer. Then, your code will only be
> executed when it's needed and in the correct sequence to avoid overwriting
> your controls.
>
> --
> -GJC [MS Windows SDK MVP]
> -Software Consultant (Embedded systems and Real Time Controls)
> - http://www.mvps.org/ArcaneIncantations/consulting.htm
> -gchanson@mvps.org
>
>
> "JohnL" <hiliuzhe@hotmail.com> wrote in message
> news:%232q5zBBqEHA.3300@TK2MSFTNGP12.phx.gbl...
ResourceView,[color=darkred]
> copy
> the
software[color=darkred]
bitmap[color=darkred]
overwritten[color=darkred]
bitmap[color=darkred]
>
| |
| Doug Forster 2004-10-06, 8:56 pm |
| Hi John,
You don't really show enough code so I'm guessing from the name that you
used a CClientDC to paint the bitmap in the background paint handler. You
should do it by drawing onto a CPaintDC in the dialog OnPaint() and you
should suppress any WM_ERASEBKGND painting.
Cheers
Doug Forster
"JohnL" <hiliuzhe@hotmail.com> wrote in message
news:%23qC0nejqEHA.556@tk2msftngp13.phx.gbl...
>
> The problem is I want to control the update of the plots by my program,
> not
> by windows. Since every time after I received some data from the serial
> port, I wanted to update the plots accordingly. If I put the redraw code
> to
> WM_ERASEBKGND message handler, and call InValidateRect or InValidate in
> the
> timer or the serial data processing function, I will still see the flicker
> since my plots are pretty big, almost the same size as the windows.
>
> John
>
>
>
>
> "Gary Chanson" <gchanson@No.Spam.TheWorld.net> wrote in message
> news:%23pbJ5NBqEHA.708@tk2msftngp13.phx.gbl...
> ResourceView,
> software
> bitmap
> overwritten
> bitmap
>
>
|
|
|
|
|