Form.LostFocus and Form.GotFocus not working right

  • 7 years ago
    I'm making a DX8 game, running almost entirely in modules, and I want the game to pause automatically if it loses focus.
    I tried putting a GameHasFocus boolean in it, setting it to true or false in the Form.GotFocus and Form.LostFocus events on the form, but it's not working right.
    Can anyone help me out here? Is there an API call for checking on form focus?Embarrassed [:$]



  • 7 years ago

    hi momruoy,

    u don't need any API for form focus, u r right in ur way, but just declare ur boolean variable in ur main module then it'll be public for all form and u can use it to true/false in Form.GotFocus/Form.SetFocus events

    'like

    Public GameHasFocus as Boolean      'Declare it in main module

     

  • 7 years ago

    I guess the problem is that the GotFocus and LostFocus events only work within the application.  E.g. if you show another form within your app.  What you're looking for is responding to the whole application losing focus.  Check the following article on the Microsoft site about how to use a timer and an API call to achieve this:  http://support.microsoft.com/kb/69792

    Regards,

    Erwin

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“In theory, theory and practice are the same. In practice, they're not.”