PDA

View Full Version : SdAskDestPath losing focus



tw0001
06-28-2006, 11:54 AM
Can someone explain why proper fixes to problems like these are continuously pushed to future versions?

http://community.installshield.com/showthread.php?t=159042

I mean it's something that everyone who is running a setup is going to run into, and the workaround must be applied, but why not fix it without the need for workarounds? Every user is going to end up searching for solutions and KB articles etc. May I suggesting putting in the release notes that this workaround must be applied to all setups.

I haven't used the product for a while and was disappointed to see this type of problem still existing.

tw0001
07-21-2006, 04:21 PM
Correction: neither of the workarounds work well.

The first one has a problem that you have to have the big background come up in your setup. Even if you disable that background immediately after enabling, you see it flashing on screen, which is ugly.

The second one makes the focus problem go away, but the finish dialog (SdFinish) does not come into focus when you reach the end of your setup.

Does anyone have a workaround that works properly in all cases? Or better yet does InstallShield have a fix to this problem coming in a future patch? It's been around since InstallShield 7.0.

To refresh your memory, I'm talking about the problem described here:

http://support.installshield.com/kb/view.asp?articleid=Q107938

tw0001
07-21-2006, 05:06 PM
EDIT: I found this (sort of) workaround using DS_SETFOREGROUND - see:

http://community.installshield.com/showthread.php?t=152540&page=1&pp=5

but come on, is that really the only way? It's really awful if a user actually does switch to another app while the setup is running, and then after the setup reaches Finish, it grabs focus from anything you happen to be doing (you could be working in some other app typing a letter for example and get interrupted by the setup)

DevinEllingson
07-24-2006, 05:40 AM
OK, first as far as a solution to this problem, I would recommend adding the following code to your OnBegin code:

hWnd = GetWindowHandle( HWND_INSTALL );
SetWindowLong( hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) | WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZE);

this is basically the same as calling Enable( DEFWINDOWMODE ) except that this does not display the background window, preventing the "flashing"

DO NOT add the additional line mentioned in the KB article:

SetWindowPos( hMain, 0, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE | SWP_NOREDRAW | SWP_NOSIZE | SWP_FRAMECHANGED | SWP_HIDEWINDOW );

This line will cause the problem with the finish dialog and should not be needed in any case.

The KB article I am talking about is:
http://support.installshield.com/kb/view.asp?articleid=Q107938

Please let me know (dellingson@macrovision.com) if you find a problem with this workaround, however since it basically the same as calling Enable( DEFWINDOWMODE ) the setup should work the same way as if:

Enable( DEFWINDOWMODE );
Disable( BACKGROUND );

was called.

I will post a second post with details of why this problem has not been resolved.

DevinEllingson
07-24-2006, 05:56 AM
OK, first some background:

When you create an InstallScript setup with a visible background, you will notice that the background window does not have a title bar, we accomplish this by setting the style to WS_POPUPWINDOW intially. We do this for compatibility with previous versions in which the background window was displayed by default, and did not have a title bar by default.

The background window runs in a different thread than the UI dialogs displayed by the script, this is so that any bitmaps/AVI's etc. displayed in the background window are updated and painted correctly.

The problem:

Unfortunately, starting with Windows XP and later, when you set the parent window of the dialog displayed by the Windows API SHBrowseForFolder to a window in a different thread that does not have a title bar (i.e.) a window set to WS_POPUPWINDOW, this problem occurs. (This problem can be reproduced in any app. that reproduces the above scenario)

Therefore to solve this problem (outside of the OS code that apparantly caused it in the first place) it would be necessary either to use a custom browse dialog instead of the SHBrowseForFolder dialog, or to try to fundamentally change the parent/child structure of the background and script windows to avoid the multithread issues. As of this time we have not taken either route.

Thus, currently the best solution is to change the background window to be an overlapped window as described in the previous post. Since most setups don't display a background this should not make any visible difference. For setups that display a background, use Enable( DEFWINDOWMODE ) to solve the problem. Thus, only setups that want to the use the "Default" background window w/o a title bar should be affected by this problem.

Devin Ellingson
Software Developer
InstallShield, A Macrovision Company

tw0001
07-24-2006, 11:51 AM
Thanks Devin, that works beautifully.

I see you have updated that KB article already - great! as there have been many posts of misinformation for yearly 4 years for all Installscript setups with no backgrounds.

Is there any downside to this workaround? If not then will it ever be incorporated into the main source code of InstallShield (rather than workaround?)

Thanks again,

Ted.

DevinEllingson
07-24-2006, 02:06 PM
The problem with incorporating it into the product is that either we would have to change the default background to have a title bar which could change the behavior of upgraded setups

Or change Enable( DEFWINDOWMODE) to not display the background automatically which would also change the behavior of upgraded setups.

Or add something to change to DEFWINDOWMODE w/o displaying the background window automatically, but this could be a confusing option.

Devin Ellingson
Software Developer
InstallShield, A Macrovision Company

Kevin Shanahan
10-05-2006, 11:56 AM
Background becomes VISIBLE in Windows XP with Q107938 workaround "B"

I've discovered a problem with the fix. When Setup is running with the "B" workaround, if you click on any other window (so that Setup loses focus), then click back on the Setup dialog, the background becomes visible.

How to reproduce:
- Create an empty InstallShield 12 InstallScript project.
- Add the workaround "B" code to the OnBegin function.
- Build and launch the Setup on Windows XP SP2 so it's sitting at the Welcome dialog.
- Activate another window like Notepad, or Explorer.
- Click back on the Welcome dialog.
The Background window will appear and be visible for the rest of the Setup process.

I can reproduce this behavior on any Windows XP SP2 computer. It does not occur on Windows Server 2003 SP1.



STATUSEX loses its alignment with other dialogs after applying Q107938 workaround

Applying workaround "A" causes the STATUSEX window to be shifted down and to the right, relative to the other dialogs. The amount of shift appears to correspond to the size of the border and title bar settings in Windows.

This problem also occurs when you use workaround "B" and you enable STATUSEX more than once. Try this sample code:

function OnBegin()
HWND hWnd;
STRING szMsg1,szMsg2,szOpt1,szOpt2,szTitle,szMsg,svDir;
NUMBER nReserved;
BOOL bvOpt1,bvOpt2;
begin
//Q107938 fix
hWnd=GetWindowHandle(HWND_INSTALL);
SetWindowLong(hWnd,GWL_STYLE,GetWindowLong(hWnd,GWL_STYLE) | WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZE);

//test window alignment - also try clicking another window and back
// to get the background to appear in XP
Enable(STATUSEX);
Delay(5);
SdWelcome('TEST','TEST');
Disable(STATUSEX);

//test the fix by clicking browse and entering an invalid path,
// then trying to type in another path
SdAskDestPath(szTitle,szMsg,svDir,nReserved);

//this status window will be shifted south
Enable(STATUSEX);
Delay(10);

//when skinned, even this dialog might be off-center
//from the original SdWelcome()'s position
SdFinish(szTitle,szMsg1,szMsg2,szOpt1,szOpt2,bvOpt1,bvOpt2);
abort;
end;


The windows will line up at first, but any subsequent Enable(STATUSEX) calls will show an off-kilter window. This is reproducible both on Windows XP and Server 2003.

Harald Schwegel
03-20-2007, 11:11 AM
Background becomes VISIBLE in Windows XP with Q107938 workaround "B"

I've discovered a problem with the fix. When Setup is running with the "B" workaround, if you click on any other window (so that Setup loses focus), then click back on the Setup dialog, the background becomes visible.

Kevin is right. Has anyone found a solution to this? BTW - in relation to the original question, its not just the finish dialog that does not come into focus, its any newly opened dialog. Once again IS disappoints.

koarl7018
04-17-2007, 07:22 AM
@Kevin, Harald


Background becomes VISIBLE in Windows XP with Q107938 workaround "B"

It seems this behavior can be reproduced on windows xp desktop style only.
Adding a "Disable(BACKGROUND)" after the workaround code worked for my setups.


/*
Workaround Installshield
BUG: Choose Folder Dialog Loses Focus on Windows 2000 and Windows XP
Document ID: Q107938
*/
hWnd = GetWindowHandle( HWND_INSTALL );
SetWindowLong( hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) | WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZE);
//SetWindowLong( hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) | WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZE);

Disable(BACKGROUND);


STATUSEX loses its alignment with other dialogs after applying Q107938 workaround

didn't find a workaround for the workaround yet ;)

@MACROVISION: This Bug (focus losing on SdAskDestPath) ist known since IS7. Why do you don't fix it???


@Harald: agree: Once again IS disappoints