![]() |
|
#1
|
|||
|
|||
|
Hi,
I have registered File Types for my program and once my program is executed I need the Main Form to become TopMost. It is working perfectly without issues on my development machine which is running Windows XP Pro. However I then tested it on another computer also running WinXP Pro but the window would just flash 3 times and remain under the window where I was launching the associated files from. I fixed the issue on the XP machine by setting ForegroundLockTimeout to (0) in the registry under the Key: HKEY_CURRENT_USER\Control Panel\Desktop It was set to 200000 by default. Now in Vista this registry key was also set the same value - (200000) and I have reset it to (0) however it has no effect and the window still does not become TopMost. I have tried everything I can think of in Vista to get the form TopMost even using a function to Force it but nothing seems to work! The Form will just stay under the Window and flash 3 times. Does anyone have any ideas or what I could do to solve this? Many thanks Nester261 "Where there's a will, there's always a way." -- The Hon Robert Nester Marley O.M. - aka Bob Marley! |
|
#2
|
|||
|
|||
|
Try:
[DELPHI]self.BringToFront; //Or Windows.SetForegroundWindow(self.Handle);[/DELPHI] Regards, Abdulaziz Jasser |
|
#3
|
|||
|
|||
|
Also see help for "SetWindowPos" API.
Regards, Abdulaziz Jasser |
|
#4
|
|||
|
|||
|
Hi,
Thanks for your reply. I have tried what you suggested but on Vista for some reason nothing is working to bring the Window to the front! I have tried:
The only thing I can get working is SetWindowPos like you suggested but I have to unset it twice once the Form is TopMost to prevent it becoming stuck. The only thing I can think is causing this in my program is that to make it Vista compatible I have had to override CreateParams and listen to messages from WMSyscommand, and, WMActivate. I am not sure if this would cause any problems though? Do you think? * My program crashes if I do not override CreateParams * I will mark as solved in a moment, I have just one more idea to try. Many thanks Nester261 "Where there's a will, there's always a way." -- The Hon Robert Nester Marley O.M. - aka Bob Marley! |
|
#5
|
|||
|
|||
|
ok after much testing and playing around I have nailed it down to being the ForegroundLockTimeout registry setting in Windows Vista.
When I changed it from (200000) to (0) there was no effect until I Rebooted and now the Form is becoming TopMost. The same happens in reverse, if I set it back to (200000) it will not take effect untill a Reboot has taken place. Note ** This does not happen on Windows XP ** I am going to test it on Windows 2k as soon as I have posted this. ...so now my question would be can this be avoided? Can I force Windows Vista to do this before a Reboot is needed? I did also try just restarting Explorer.exe to see if this would have any effect on things, but no it did not! (it was worth a try). Many thanks Nester261 "Where there's a will, there's always a way." -- The Hon Robert Nester Marley O.M. - aka Bob Marley! |
|
#6
|
|||
|
|||
|
I played with Vista but never liked it. I still use XP pro SP2. To tell you the truth, I can play with Windows APIs but not with (a buggy OS like Vista). They will clean it up for sure or perhaps replace it with a new one (for there lake in unable to convenience people to accept it as a good replacement for XP). But at this point I have no idea.
Regards, Abdulaziz Jasser |
|
#7
|
|||
|
|||
|
Not really I good idea (al least in your case), but why not reboot by code immediately after making the change?
This is only to avoid the users help until you figure out the problem (or MS comes with a service pack). Regards, Abdulaziz Jasser |
|
#8
|
|||
|
|||
|
Hi,
I will check the key the first time File Associations are made then display a message to inform the User and ask them what action they would like taken. When I tested it in Windows 2000 the ForegroundLockTimeout was also set to (200000) by default. It would seem this is the default in ALL versions of Windows. I cannot confirm this 100% just yet. Thanks for all your help Jasser Nester261 "Where there's a will, there's always a way." -- The Hon Robert Nester Marley O.M. - aka Bob Marley! |
![]() |
| Thread Tools | |
| Display Modes | |
|
|