I wish to avoid the application to switch when the user presses ALT-TAB or when Another programer (Like ICQ) whants to take control. I know that is possible because Quake does it.
Posted on 2001-09-24 11:20:33 by dxantos
hooks. Either via API or VXD
Check the hooks tutorial at iczelion's and check some vxd hooking here .

Two cents.

Posted on 2001-09-24 14:19:04 by latigo
there is another very easy way:

use DirectX in exclusive mode without Alow Ctrl+Alt+Del flag then
start your main game render and input loop in another thread then stop the message loop (no more GetMessage and stuff) use only DirectInput to read keyboard and mouse...

IF you want to get back ckeck for Alt+tab or what ever key you want to use and let the message loop run again ;)

we do like that in HE and it works pretty well
Posted on 2001-09-24 16:18:37 by BogdanOntanu
there is a better way (in my opinion ) .
when screen saver runs . you cant use ctrl+alt+del . as i recall you cant use alt+tab too . .

so just do

invoke SystemParametersInfo,SPI_SCREENSAVERRUNNING, true or false , '1', 0)

as you probably understood , when you send true you actully disable the alt+tab , when you send false you enable it ..

i hope it helps



Posted on 2001-09-24 17:35:05 by eko
in most situations, you should allow the user to select whether
alt+tab and ctrl+alt+del should be disallowed. In DX, you might need
a little more code to allow for lost surfaces etc, but you *should*
handle those anyways, otherwise you're a sloppy programmer.
Posted on 2001-09-24 18:19:42 by f0dder

One good programmer sure has to take care of lost surfaces and stuff, but all games that i have seen until now (that allow Alt+Tab ingame) have some problems (even *Craft) ...from our experience i susspect is the mutithread syncro that goes wrong somewhere.

We also had to take control of Alt+Tab (even if we allow it a milisecond later ingame) in HE because we have had to stop some threads first and only then we can let windows do its job and send us down to the "minimize" world ;)

and we still have problems with this matter....
Posted on 2001-09-24 18:46:43 by BogdanOntanu
Right now Im using openGL.

I know that D3D is very similar to openGL nowadays but since I have invested 2 years in the project changing API will be dificult (too much code).

When I switch focus, (or when another application steals the focus) most of the time openGL has no trouble but on some situations openGL loses the textures (and then you see white polygons). Altough I have code to release the textures and reload them, it takes about 5 to 10 seconds to restore all the textures. (depending on video memory). Of course I can opt to put all the textures on system memory as a backup, but I see this as a waste of memory. (If the user is switching the aplication then I should free as much memory as possible). Also I wish to minimize the posibility of creating a trainer. (As well as the see-trough cheat drivers). In single player mode this does not mather, but in multi-player, cheating is a concern. Thus I wish to disable ALT-TAB and when the user Presses CRTL-ALT-DELETE, leave the application (Ctrl-Alt-Delete means that something wrong happened). Also I wish that other aplication will not take control until the user chooses to quit the game.
Posted on 2001-09-24 19:48:38 by dxantos
dxantos, disabling alt+tab to avoid trainers is a wrong way to tackle
the situation. Obviously, in single-player, it will not matter. In multi-
player, your network protocol should be strong enough to make
cheats impossible (client/server makes it much harder to cheat,
and since there's not really a TCP or UDP equivalent to IPX broadcast,
C/S is the best way to go imho).

As for keeping textures in system memory as well as on the gfx
board... how large an amount of textures do you have? What are
your ideal system requirements? I can understand you don't want
to waste system resources. Instead of working directly with CreateFile
(and friends), you could create your own layer on top of this, to implement
a caching scheme (possible with a cache pool size that is user
tweakable). This way, users with much ram can keep a lot of stuff
in memory, while users with less ram will suffer the long load times.

If the user is switching the aplication then I should free as much memory as possible.

Why? Unless, of course, you're using ludicruous amounts :). A switch
from a game will usually be a short-term switch, probably because
boss/parents/children/minor kid brothers (or whoever whoever who
are not supposed to see what you're doing) have entered your room,
or because you have to check something quickly. In that case, it
will be a waste of your programming and the users time to delloac
a lot of stuff and realloc it when the users switches back into the game.

There probably isn't much you can do about the lame see-through
drivers, except for something akin to punk-buster (which is a great
annoyance imho).

Remember, you don't want to annoy the end user just to slow down
crackers/trainer makers. And if there is a way to cheat your game,
it will be found if people care enough about it (which is obviously
true for wellknown games, especially since some groupz consider a trainer a release...)
Posted on 2001-09-24 20:07:28 by f0dder