SetForegroundWindow API not working
Hey, i know there have been a lot of posts on this topic but i can't seem to find the answer to this question. I have an excel spreadsheet with cells full of visio shapes. When a double click is made on a cell, the shape is found and set to blink in visio. However, i am having trouble getting the visio window to pop up infront of the excel window
I am using SetForegroundWindow API by calling this:
VB Code:
'g_ovAppVisio is the Visio Application object
SetForegroundWindow g_ovAppVisio.WindowHandle32
this however, only causes the visio window to flash 3 times in the task bar, and not pop up. What else do I need to do to make it pop up in front of the excel window? Thanks!
Re: SetForegroundWindow API not working
Re: SetForegroundWindow API not working
Re: SetForegroundWindow API not working
Find the handle yourself with the FindWindow API? Just a thought...
Re: SetForegroundWindow API not working
It's the right handle, the window reacts, it just doesn't pop up. I think i need to use SetWindowPos but i'm not sure how to set the flags, or if there is a better procedure for doing that.
Re: SetForegroundWindow API not working
Re: SetForegroundWindow API not working
Quote:
Originally Posted by Vhati
It's the right handle, the window reacts, it just doesn't pop up. I think i need to use SetWindowPos but i'm not sure how to set the flags, or if there is a better procedure for doing that.
same case as mine. What I did is use the IsIconic function,setforeground and showwindow.
IsIconic use to check if the window is minimize or not if it's not minimize then use the setforeground then if it's minimize then use the showwindow.
Re: SetForegroundWindow API not working
Re: SetForegroundWindow API not working
Windows 98/Me, Windows 2000/XP: The system restricts which processes can set the foreground window. A process can set the foreground window only if one of the following conditions is true:
The process is the foreground process.
The process was started by the foreground process.
The process received the last input event.
There is no foreground process.
The foreground process is being debugged.
The foreground is not locked (see LockSetForegroundWindow).
The foreground lock time-out has expired (see SPI_GETFOREGROUNDLOCKTIMEOUT in SystemParametersInfo).
Windows 2000/XP: No menus are active.
Check MSDN for more
Re: SetForegroundWindow API not working
Quote:
Originally Posted by
mayurvb
Windows 98/Me, Windows 2000/XP: The system restricts which processes can set the foreground window. A process can set the foreground window only if one of the following conditions is true:
The process is the foreground process.
The process was started by the foreground process.
The process received the last input event.
There is no foreground process.
The foreground process is being debugged.
The foreground is not locked (see LockSetForegroundWindow).
The foreground lock time-out has expired (see SPI_GETFOREGROUNDLOCKTIMEOUT in SystemParametersInfo).
Windows 2000/XP: No menus are active.
Check MSDN for more
In 2019, the main difference in MSDN to above is:
Quote:
The foreground process is not a Modern Application or the Start Screen.
Makes sense. Necro reason being that given A is the start up form and unloaded, C is then number crunching_ hourglass_busy modally over another form B with a title bar. In multiple tests of the same operation, when borderless C (no ControlBox) is no longer busy, B sometimes pops up in front of C.
This behaviour has come about in Windows 10, and is possibly attributed to the OS handling of HUNGAPPTIMEOUT or WAITTOKILLTIMEOUT in our Modern Application.