Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Minimizing other applications

Status
Not open for further replies.

RabidGoat

Programmer
Mar 2, 2005
2
0
0
ZA
I'm writing a program that controls the use of PC's at an Internet Cafe. It consists of a client ap on each pc and a server running at the desk. The client ap displays a large image on the screen until it receives a message from the server to open up for a set amount of time. This works perfectly for normal internet use and so on, but some of the pcs will allso be used for games, and I've been having trouble with them. When the pc's time expires and the image is supposed to kick in, the game continues to run in the foreground. I've been trying a variety of things to try and get the focus away from the game, but most it resulted in some weird stuff (for instance in one case the game would start flickering, but would still continue - for some reason your average child is not put off from playing by a mere flickering screen)
Help would be appreciated.
 
You should delve into DirectX programming, have a search at Microsoft' site, that should help (msdn.microsoft.com)

HTH
TonHu
 
How about this:

Make a list of all the programs names and run em through this function:

Code:
function MinimizeApp(AppName: PChar): Boolean;
var hAppWindow: HWND;
begin
Result := False;
hAppWindow := FindWindow(AppName, nil);
if PostMessage(hAppWindow,WS_MINIMIZE,0,0) <> 0 then
               Result := True;
end;

(This code probably will need some work)

[bobafett] BobbaFet [bobafett]

Everyone has a right to my opinion.
[/b]
Great Delphi Websites faq102-5352
 
Small update, just something I thought of while browsing through the forum:

Code:
function MinimizeApp(AppName: PChar): Boolean;
var hAppWindow: HWND;
begin
Result := False;
hAppWindow := FindWindow(AppName, nil);
if hAppWindow <> 0 then
    if PostMessage(hAppWindow,WS_MINIMIZE,0,0) <> 0 then
        Result := True;
end;
With the code like this, it'll return false both when the app cant be minimized or the app isnt running. You could simply find out whats going on like this:

Code:
if not MinimizeApp('someapp') then
    begin
    if FindWindow('someapp') = 0 then
         // app not running
         else
         // app didnt want to minimize
    end;


[bobafett] BobbaFet [bobafett]

Everyone has a right to my opinion.
[/b]
Great Delphi Websites faq102-5352
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top