Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
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) ;







Report this thread to moderator Post Follow-up to this message
Old Post
JohnL
10-02-04 01:56 AM


Re: BitBlt operations overwrite existing bitmap controls in the dialog
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) ;
>
>
>
>
>
>


Report this thread to moderator Post Follow-up to this message
Old Post
Gary Chanson
10-02-04 01:56 AM


Re: BitBlt operations overwrite existing bitmap controls in the dialog
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, 
> copy 
> the 
software 
bitmap 
overwritten 
bitmap 
>



Report this thread to moderator Post Follow-up to this message
Old Post
JohnL
10-04-04 09:06 PM


Re: BitBlt operations overwrite existing bitmap controls in the dialog
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 
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
Doug Forster
10-07-04 01:56 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Visual Studio archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:47 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.