| further reading | more topics » |
| mjbWorld program | 3D theory |
3D physics |
3D maths |
3D programming | technology |
about site |
sitemap A-Z |
| index | language | dev tools | games | structure | platforms | OOAD | information |
| index | setup | 2d | 3d |
| index | dx9vb | dx9C# | OpenGL C++ |
| index | introduction | installation | basics | restoring | images | animation | transpancy |
| background | sound |
|
This toturial was written for me by Imran Khan (imranahmedkhan82@hotmail.com,
iak1982@yahoo.com). |
|||
|
Restoring Lost Surfaces: We have Learn about Surfaces but there is one problem with them , when your application got minimize all the surfaces and devices you initlialize will be lost and you will see nothing.In this Section We will show the solution of this problem. Its a continuation of the previous program. We will change the Constructor of form1 class, Showsurface( ) method and add a new method of ' GFocus ' . Let Start with Constructor.
As you see the method is same as previous we just add one line ' this.Load += new System.EventHandler(this.GFocus); ' . This adds handler to the GotFocus event (we will define GotFocus Handler later) When the application Lost focus the device and surfaces lost, so the next time the form comes up we have to reinitialize the device. This is where the GotFocus event must be added to the form. now GotFocus Handler.
Its a small and easy event, When the form lost and then got focus this event will be call. As first line will Destroy all the objects of devices, surfaces and then calling constructor of the form1 by making instance of form1. As the constructor call it initialize the surfaces and devices by calling Init( ). Now ShowSurface ( ) method.
We add just Try and Catch Block in this Method to Catch the Exception of Lost Surface. The Explanation of Exception is this, first time this function will work without try catch but when it lost focus , it will lost all the surfaces and again when it got focused by the user, it try to fill the surface (1st line) and then flip the surface (2nd line). This will throw Exception that the Surface is not present. To handle this problem Use try catch block and in Catch , reinitialize the surfaces and devices. Now when you run the program you will see a White screen, When you minimize it by pressing ' Alt + Tab ' and then again focus this window , YOU WILL STILL SEE THE SAME WHITE SCREEN. |
|
metadata block
|
|
| see also: | |
| Correspondence about this page | |
|
Book Shop - Further reading. Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them. |
|
|
Commercial Software Shop Where I can, I have put links to Amazon for commercial software, not directly related to this site, but related to the subject being discussed, click on the appropriate country flag to get more details of the software or to buy it from them. |
|
|
Can this page be improved? Please send me any improvements to here. I would appreciate ideas to make the pages more useful including error correction, ideas for new pages, improvements to wording. It helps if you quote the full URL of the page. |
|
|
progam I am working on a project which uses these principles, if you would like to help me with this you are welcome to join in, here: |
for kdgame programming: http://sourceforge.net/projects/kdgame/ |
This site may have errors. Don't use for critical systems.
Copyright (c) 1998-2008 Martin John Baker - All rights reserved - privacy policy.