
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!