473,386 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

page-flipping in managed C++

> The flicker is because you background is painted first to clear the
background and then your graphics shapes.
Flicker could be avoided by using a memory device context. where you draw
the complete image in a memory buffer and then swap it to the dialogbox
window, without painting the background first.


Sounds like page flipping. I like page flipping!

Ok. I currently draw to a Form (actually, my own class derived from a Form,
but therefore it is a Form) via a Graphics object I get from the Form's
Paint event (i.e., using DrawRectange, DrawEllipse, etc.). How do I easily
create and draw to an off-screen 'memory device context'
instead of the Form, and how do I then do the swap of the results to the
Form as you mentioned?

It sounds like a great idea, but I need details! : )

[==P==]

Nov 17 '05 #1
3 1177
Let me make this concrete. The following code snippet will draw a red
300x400 rectangle at position (100,200) on 'form' :

__gc class HandlerClass
{
public:
static void m_Paint_Event_Handler( Object*, PaintEventArgs* e )
{
Pen* pen = new Pen( Color::Red, 1 ) ;
e->Graphics->DrawRectangle( pen, 100, 200, 300, 400 ) ;
}
} ;

Form* form = new Form( ) ;
form->Paint += new PaintEventHandler( 0, HandlerClass::Paint_Event_Handler )
;

How would you modify this code so that it draws the red triangle on an
off-screen 'memory-device context' and then swaps (or copies) this
off-screen buffer to the on-screen form?

Thanks in advance! : )

[==P==]
"Peter Oliphant" <po*******@RoundTripInc.com> wrote in message
news:O%****************@TK2MSFTNGP12.phx.gbl...
The flicker is because you background is painted first to clear the
background and then your graphics shapes.
Flicker could be avoided by using a memory device context. where you draw
the complete image in a memory buffer and then swap it to the dialogbox
window, without painting the background first.


Sounds like page flipping. I like page flipping!

Ok. I currently draw to a Form (actually, my own class derived from a
Form,
but therefore it is a Form) via a Graphics object I get from the Form's
Paint event (i.e., using DrawRectange, DrawEllipse, etc.). How do I easily
create and draw to an off-screen 'memory device context'
instead of the Form, and how do I then do the swap of the results to the
Form as you mentioned?

It sounds like a great idea, but I need details! : )

[==P==]

Nov 17 '05 #2
Peter Oliphant wrote:
How would you modify this code so that it draws the red triangle on an
off-screen 'memory-device context' and then swaps (or copies) this
off-screen buffer to the on-screen form?


First you create a bitmap:

Bitmap* bmp = new Bitmap(ClientRectangle.Width, ClientRectangle.Height);

then you get a DC to the bitmap:

Graphics* gr = Graphics::FromImage(bmp);

Now you paint your image onto gr.

And finally paint the bitmap on the screen:
e->Graphics->DrawImageUnscaled(bmp, 0, 0);

Tom
Nov 17 '05 #3
Thanx, Tamas! That is exactly what I needed! : )

[==P==]

"Tamas Demjen" <td*****@yahoo.com> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
Peter Oliphant wrote:
How would you modify this code so that it draws the red triangle on an
off-screen 'memory-device context' and then swaps (or copies) this
off-screen buffer to the on-screen form?


First you create a bitmap:

Bitmap* bmp = new Bitmap(ClientRectangle.Width, ClientRectangle.Height);

then you get a DC to the bitmap:

Graphics* gr = Graphics::FromImage(bmp);

Now you paint your image onto gr.

And finally paint the bitmap on the screen:
e->Graphics->DrawImageUnscaled(bmp, 0, 0);

Tom

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Michael Brennan-White | last post by:
If I submit my for using a get action the resulting page loads . If I use a post action I get an error page saying "The page cannot be found". I am calling the originating page!!! This happens...
0
by: Nathan | last post by:
Hi, I seem to having a peculiar problem with the display of odd and even pages in XSL-FO. Here is a small background of the problem. My xsl stylesheet mentions my fo:layout-master-set as ...
2
by: James | last post by:
I've been to websites where if I navigate off a form, trying to get back to it by hitting the back button gives me a page which says "Warning, page has expired". It doesn't display the page. I've...
4
by: Kevin Phifer | last post by:
Ok, before anyone freaks out, I have a solution I need to create that gathers content from maybe different places. Each one can return a <form> in the html, so its the classic can't have more than...
2
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
6
by: MooreSmnith | last post by:
When I navigate to the next page using Response.Rediect("MyNextPage.aspx") current page Page_Load event is called. What I may wrongly understood is that post back will happen whenever there is any...
1
by: Lenard Gunda | last post by:
Hi! I have the following problem. From my main page, when someone clicks a button, it uses client side javascript to open another .aspx page. This page displays content, based on what the...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
8
by: Ed Jay | last post by:
I want to use history.go() to navigate between my previously loaded pages. I'm looking for a way to trigger a function call when a page is accessed using history.go(). Is there an event generated?...
3
by: Mesut | last post by:
I have written a form in with radio buttons the name is set to orderby and the value is set to KundeVorName and the next value is KundeNachName and it goes so on. I wanna modify my query according...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.