|
-
Feb 19th, 2004, 05:53 PM
#1
Thread Starter
Ex-Super Mod'rater
Losing Focus in a DirectX Project
I bet most people in this forum have came across this one before, when say you press Alt + Tab and your DirectX App loses focus it doesn't like it, yeah? Well I know you can Restore Surfaces then reload the images but does anyone know if theres a way just to stop it from losing the surfaces in the first place?
Thanx,
Paul
When your thread has been resolved please edit the original post in the thread (  )
and amend "-[RESOLVED]-" to the end of the title and change the icon to  , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

-
Feb 19th, 2004, 07:13 PM
#2
Supreme User
you mean like how DOS is made exclusively?
Not sure, but im sure theres some API for it, did you look at PSC?
-
Feb 19th, 2004, 07:19 PM
#3
Thread Starter
Ex-Super Mod'rater
When your thread has been resolved please edit the original post in the thread (  )
and amend "-[RESOLVED]-" to the end of the title and change the icon to  , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

-
Feb 19th, 2004, 07:21 PM
#4
Supreme User
Originally posted by Electroman
PSC??
Planet-Source-Code
link in signature
-
Feb 19th, 2004, 07:23 PM
#5
Thread Starter
Ex-Super Mod'rater
When your thread has been resolved please edit the original post in the thread (  )
and amend "-[RESOLVED]-" to the end of the title and change the icon to  , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

-
Feb 20th, 2004, 07:42 AM
#6
Yeah you can disable the Alt+Tab buttons, but it is not recomended at all. It is really anoying, and all real DX books are trying to make you understand how irritating it is. And an other thing is that some IMs and other stuff might pop up in the window on some machines too, and that will make you loos the focus too, so the best thing to do is to always check if you have the focus and if not, restore it...
-
Feb 20th, 2004, 09:08 AM
#7
Thread Starter
Ex-Super Mod'rater
As soon as you lose focus tho you need to retsore all the surfaces right, and how exactly do you check for focus and get focus back?
When your thread has been resolved please edit the original post in the thread (  )
and amend "-[RESOLVED]-" to the end of the title and change the icon to  , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

-
Feb 16th, 2008, 01:39 PM
#8
New Member
Re: Losing Focus in a DirectX Project
You can check for focus by using GetActiveWindow, a minor API call:
Code:
Public Declare Function GetActiveWindow Lib "user32" () As Long
If GetActiveWindow = Form1.hWnd Then
'You've got the focus
Else
'You've not
End If
Dunno about restoring surfaces though...? My program throws automation errors when it restores, but this method might work for you though, 'cos I'm not using many surfaces, mostly textures and sprites and stuff. (And because I'm hideously error-prone at times.) I presume your Form_Load sub holds all the surface-loading code, yeah? You can cheat: whenever the form reactivates, bomb it out and load it again.
The best way to go about that is just to use a little sub called Form_Activate and a variable saying when the program's tabbed out.
Code:
Private Sub Form_Load
'The lot
TabOut = False
End Sub
Private Sub Form_Activate
If TabOut = True Then
Unload Me 'Not sure if this is necessary
Form_Load
End If
End Sub
'Later on, in the main loop...
Private Sub RenderAll 'Called by the main loop
If GetActiveWindow = Me.hWnd Then
'Do the funky rendering gibbon
Else
TabOut = True
End If
End Sub
That any good for you?
Edit: You do know that [VBCode] thing [/VBCode] in your sig doesn't work, don't you?
Last edited by Son of Makuta; Feb 16th, 2008 at 01:42 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|