Link to home
Start Free TrialLog in
Avatar of akajmf
akajmf

asked on

Delphi/Windows 2000 inactive window problem.

HI,

I currently have a program that has been built with Delphi 5, and when I run this program on Windows Me or 2000 it has a problem with inactive windows. Simply starting up the program will cause the vary first window to go inactive. This has not been a problem with 95, 98, or NT. It would be great if someone could tell me what causes it and how to fix it
ASKER CERTIFIED SOLUTION
Avatar of Epsylon
Epsylon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Madshi
Madshi

Normally the first window should be active. Do you have a default project (*.dpr) file or did you make some changes to it? Or do you show anything while the program shows up (= before and while the first window is shown)? There must be something, because my projects all work fine in all OSs...

Regards, Madshi.
Avatar of akajmf

ASKER

When the program is started a splash screen comes up as it connects to a server, when this is done a log in screen appears and that is what goes inactive. Various other forms go inactive throughout the whole program also, but it happens on the firs form the most.
Did you try

FormX.BringToFront;
You may try some of these
  SetForegroundWindow(Handle);
  BringWindowToTop(WindowHandle);
  SendMessage(Handle,WM_SETFOCUS,0,0);
But somewhere in the MSDN I red (about a year ago) that there is a new policy in windows 2000 about bringing windows to front.  E.g. if your program has no focus, it can't retreive it because the user may enter a password in that very moment expecting other app to catch it... I'd better search for that article again. It was about "What's new in Windows 2000"
It's right that you are not allowed to steal focus from the foreground window/application in ME&2000 in some situations, but this sounds like another situation. I go with Epsylon, I guess simply using InactiveForm.BringToFront after the splash screen should fix the problem.

Regards, Madshi.
Avatar of akajmf

ASKER

Thanks you all for your help. I am testing it and will soon let you know if any of your suggestions work.

if epsylons ForceForegroundWindow() doesn't work (it doesn't on my system - W2K SP1) take a look at this thread:

https://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20089680

the provided answer works for me. if you don't want to pay the 10 points I can repost the answer.

good luck
Avatar of Russell Libby
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept Epsylon's comment as answer

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Thank you,
Russell

EE Cleanup Volunteer