This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- How do I force a messageBox to the forground in BasicMSI
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jul 25, 2012
09:46 AM
How do I force a messageBox to the forground in BasicMSI
I have a BasicMSI installation I'm working with. In a couple places I display a AskYesNo question and some times that will pop up under the forground window. Is they a command I can use right before the AskYesNo to force it to the top?
Thanks
Brandon
Thanks
Brandon
(2) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jul 25, 2012
01:11 PM
Ahhh yes... that subject comes up every now and then! Here's what I recently did. Add the custom action below and then just add the line
SetWindowFocus();
to your desired Custom Actions where you have this issue. Of course this is not goof proof because someone could be navigating willy-nilly around the screen after you have SetWindowFocus... but it solves the problem for most practical cases.
-----------------------------------------------------------
function SetWindowFocus()
HWND hMain;
begin
hMain = GetWindowHandle( HWND_INSTALL );
//Attach foreground window thread to installation thread
AttachThreadInput( GetWindowThreadProcessId( GetForegroundWindow(), NULL ), GetCurrentThreadId(), TRUE );
//Bring to foreground
SetWindowPos( hMain, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
SetForegroundWindow( hMain );
//Detach the attached thread
AttachThreadInput( GetWindowThreadProcessId( GetForegroundWindow(), NULL ), GetCurrentThreadId(), FALSE );
SetFocus( hMain );
end;
-----------------------------------------------------------
SetWindowFocus();
to your desired Custom Actions where you have this issue. Of course this is not goof proof because someone could be navigating willy-nilly around the screen after you have SetWindowFocus... but it solves the problem for most practical cases.
-----------------------------------------------------------
function SetWindowFocus()
HWND hMain;
begin
hMain = GetWindowHandle( HWND_INSTALL );
//Attach foreground window thread to installation thread
AttachThreadInput( GetWindowThreadProcessId( GetForegroundWindow(), NULL ), GetCurrentThreadId(), TRUE );
//Bring to foreground
SetWindowPos( hMain, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
SetForegroundWindow( hMain );
//Detach the attached thread
AttachThreadInput( GetWindowThreadProcessId( GetForegroundWindow(), NULL ), GetCurrentThreadId(), FALSE );
SetFocus( hMain );
end;
-----------------------------------------------------------
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jul 27, 2012
09:21 AM
For a Basic MSI, you should probably use MsiProcessMessage instead. This will allow Windows Installer to properly parent the dialog, and suppress it in scenarios that should not show UI. However the API will not work if the custom action is invoked in response to a ControlEvent (such as a button press on a dialog).