I have a function in my MSI custom action DLL that launches the installed
executable using ShellExecuteEx(). It launched the application
successfully, but the application window is on the background of the
Installer window. Is there a way to make it foreground instead?
Thanks a bunch.
- Jiaquan Ma
To bring a window to the front of other windows, we could call the Win32
API function 'SetWindowPos'.
The syntax of the function 'SetWindowPos' is like below:
BOOL SetWindowPos(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx,
int cy, UINT uFlags);
To bring the window to the front of other windows, pass 'HWND_TOPMOST' to
the second parameter hWndInsertAfter.
For more information on the function 'SetWindowPos', you may visit the
following link.
'SetWindowPos Function'
http://msdn2.microsoft.com/en-us/library/ms633545.aspx
Hope this helps.
If my suggestion is not propriate to your scenario, please feel free to let
me know.
Sincerely,
Linda Liu
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
How about the problem now?
If you need our further assistance, please feel free to let me know.
Thank you for using our MSDN Managed Newsgroup Support Service!
SetWindowPos(ShExecInfo.hwnd, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW);
At least it works on my development box. I will let you if it doesn't.
Meanwhile, please let me know if I am not using the correct switch for
hWndInsertAfter or uFlags. Otherwise, this problem should be addressed.
Thanks.
- Jiaquan Ma
On 3/8/07 5:12 AM, in article XVC0bpW...@TK2MSFTNGHUB02.phx.gbl, "Linda
Thank you for your response.
I notice that you pass 4 zeros to the SetWindowPos function. If you don't
want to change the current position and size of the window, you may pass 4
zeros as the third to sixth paramaters and specify
SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW as the last parameter.
Hope this helps.
How about the problem now?
If you have any question, please feel free to let me know.