simple question, pls answer\ 
Author Message
 simple question, pls answer\

*** Sent via Developersdex http://www.*-*-*.com/ ***
Don't just participate in USENET...get rewarded for it!



Fri, 21 Jan 2005 06:36:30 GMT  
 simple question, pls answer\

sorry last time i press "ENTER" by misktake

any way i had a question

i am making an application
its openGL and i want my program to end when user press "ESC" but what i
have done its not working could you let me knwo where am i gong wrong
thank you
using System;
using System.Windows.Forms;
using System.Drawing;
using CsGL.OpenGL;
using CsGL.Util;
namespace OpenGl_CS_
{
        /// <summary>
        /// Summary description for myOpenGl.
        /// </summary>
        public class myOpenGl : OpenGLControl
        {
                public static Form f;
                public static ScreenForm sf;
                public static bool isRunning = true;            
                private bool fullScreen=true;

                public static void Main()
                {
                        creatFormWindow();
                        if(!fullScreen)
                        {
                                while(!f.Dispose)
                                {      
                                        Application.DoEvents();
                                }
                        }
                        else
                        {
                                while(OnKeyUp(?????) <=== dont know what to say here
                                {
                                }
                        }
                }

                public myOpenGl()

                {                      
                        createGlWindow();
                }

                public void Draw()....

                //initilazation
                public virtual void Init() ....

                public override void glDraw()...

                public virtual void createGlWindow()...

                protected override void OnSizeChanged(EventArgs e)...

                private static void creatFormWindow()..

                protected override void OnKeyUp(KeyEventArgs e)
                {
                        base.OnKeyUp(e);
                        if(e.KeyCode == Keys.Escape)
                        {
                                isRunning = false;
                                Application.Exit();
                        }
                }

        }

what i wanne do in my main is that
i said
if user didnot choose to run the application on fullscreen then end the
application when the press the (x) thingy
but i dont know how to end it when they choose the fullscreen mode
i override the protected override void OnKeyUp(KeyEventArgs e)
but when i run the application it dont work and plus i dont know how to
put in my while loop in main method
any help would greatly be appreciated  
i am student who is trying to learn C# on my own
computer science student =)
thx again

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Fri, 21 Jan 2005 06:44:19 GMT  
 simple question, pls answer\
amir, you need to trap the KeyDown event for your form.  In the OnKeyDown
method then you can check e.KeyCode to see if the user pressed the escape
key.  Then if they did you just signal the rest of your app to close.  Using
events like this makes it so you don't have to loop waiting for something
like you have sketched out in your code.

Hope that helps,

--
Greg
http://www.claritycon.com


Quote:

> sorry last time i press "ENTER" by misktake

> any way i had a question

> i am making an application
> its openGL and i want my program to end when user press "ESC" but what i
> have done its not working could you let me knwo where am i gong wrong
> thank you
> using System;
> using System.Windows.Forms;
> using System.Drawing;
> using CsGL.OpenGL;
> using CsGL.Util;
> namespace OpenGl_CS_
> {
> /// <summary>
> /// Summary description for myOpenGl.
> /// </summary>
> public class myOpenGl : OpenGLControl
> {
> public static Form f;
> public static ScreenForm sf;
> public static bool isRunning = true;
> private bool fullScreen=true;

> public static void Main()
> {
> creatFormWindow();
> if(!fullScreen)
> {
> while(!f.Dispose)
> {
> Application.DoEvents();
> }
> }
> else
> {
> while(OnKeyUp(?????) <=== dont know what to say here
> {
> }
> }
> }

> public myOpenGl()

> {
> createGlWindow();
> }

> public void Draw()....

> //initilazation
> public virtual void Init() ....

> public override void glDraw()...

> public virtual void createGlWindow()...

> protected override void OnSizeChanged(EventArgs e)...

> private static void creatFormWindow()..

> protected override void OnKeyUp(KeyEventArgs e)
> {
> base.OnKeyUp(e);
> if(e.KeyCode == Keys.Escape)
> {
> isRunning = false;
> Application.Exit();
> }
> }

> }

> what i wanne do in my main is that
> i said
> if user didnot choose to run the application on fullscreen then end the
> application when the press the (x) thingy
> but i dont know how to end it when they choose the fullscreen mode
> i override the protected override void OnKeyUp(KeyEventArgs e)
> but when i run the application it dont work and plus i dont know how to
> put in my while loop in main method
> any help would greatly be appreciated
> i am student who is trying to learn c# on my own
> computer science student =)
> thx again

> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



Fri, 21 Jan 2005 07:46:15 GMT  
 simple question, pls answer\

protected override void OnKeyUp(KeyEventArgs e)
        {
            base.OnKeyUp(e);
            if(e.KeyCode == Keys.Escape)
            {
                isRunning = false;
                Application.Exit();
            }
isnot this what you mean i did that
but no matter how many times i press escape it wont exit the program

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Fri, 21 Jan 2005 08:48:24 GMT  
 simple question, pls answer\

the problem is if i dont make a loop the screen will just appear and
gone in one sec
i need some kind of loop or something to keep i tgoing untill the user
press escape but i am having a hard time to code this idea
some one would please help =)

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Fri, 21 Jan 2005 09:04:22 GMT  
 simple question, pls answer\

Greg THANK YOU
THANKS AGAIN
=)
it worked you were really helpfull

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Fri, 21 Jan 2005 10:40:36 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. A simple question, but still no answer

2. Simple question ( for those how knows the answer )

3. This question must have a simple answer.

4. Help... V Simple Questions Need Answering

5. Simple Question - Please Answer -- Anyone??!!

6. simple 2 line answer socket question

7. Need answer for probably very simple question...

8. A question for a simple answer

9. expert advice needed pls, pls, pls

10. Simple problem across processes - need simplest answer

11. Pls answer me, I am online

12. PLS Email me answer

 

 
Powered by phpBB® Forum Software