From: Sarah M. Weinberger on 3 Jul 2010 00:22 Hi All, Sorry it took so long to try out the code, but sadly "no go". I implemented the code fragment in an app and then ran the Windows 7 Windows Qualification test. Here is the code fragment and what I received as the result. :-( ---------------------------------------------------------------------------------------------------------------------------------------------------- Code Fragment ---------------------------------------------------------------------------------------------------------------------------------------------------- Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) 'Handle the request. Cancel = False 'Process the request conforming to Microsoft Windows 7 compatibilty requirements. If UnloadMode = 0 Then 'Ask about saving open files before closing and provide a cancel option. 'There is nothing to ask about, as there are no data files to save. Else 'Quit. Either the system or your own code is telling you to close. 'Fall through to end the program. Unload Me End If End Sub ---------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------- Windows 7 Qualification Report ---------------------------------------------------------------------------------------------------------------------------------------------------- 7. Adhere to Restart Manager messages Test case: Don't block reboot: PASS WITH WARNINGS WARNING: The following files did not respond to system restart requests: Executable c:\program files (x86)\butterflyvista\metricwiz\metricwiz.exe failed to shutdown. Some applications as part of their first launch display EULAs or auto update prompts, registration forms, etc. If your application performs in this way, it could be falsely reported as non-compliant with the restart requirement. If any of the above files are reported for this reason, you should restart testing from a clean state (clean OS). This time around, before running the /postinstall phase, execute any run-once functionality in the application PRIOR to running the /postinstall phase of the toolkit. IMPACT IF NOT FIXED: By failing to shutdown gracefully, customers could lose data when the OS finally forces a shutdown. It also slows the shutdown/reboot process, impacting performance perceptions. HOW TO FIX: In a critical shutdown, applications that return FALSE to WM_QUERYENDSESSION will be sent WM_ENDSESSION and closed, while those that time out in response to WM_QUERYENDSESSION, will be terminated. By following these guidelines, you can ensure that your application will handle critical shutdowns gracefully: WM_QUERYENDSESSION with LPARAM = ENDSESSION_CLOSEAPP(0x1): GUI 19 applications must respond (TRUE) immediately in preparation for a restart WM_ENDSESSION with LPARAM = ENDSESSION_CLOSEAPP(0x1): Applications must return a 0 value within 30 seconds and shut down. At a minimum, applications should prepare by saving any user data and state information that is needed after a restart Console applications that receive CTRL_C_EVENT notification should shut down immediately. Drivers must not veto a system shutdown event More information and guidance on requesting and responding to system shutdowns and the RestartManager is available HERE. ---------------------------------------------------------------------------------------------------------------------------------------------------- As you can see, the test reported a failure even though I am implementing the Form_QueryUnload. Thoughts? Thanks, Sarah
From: Nobody on 3 Jul 2010 00:57 "Sarah M. Weinberger" <nospam_mweinberger(a)hotmail.com> wrote in message news:29FCDEB9-C3FD-4062-886D-D2C355029BD7(a)microsoft.com... > Unload Me Remove the above line. Not sure if this fixes the problem, but this is not the proper place for it.
From: Mayayana on 3 Jul 2010 10:28 Look up the QueryUnload event. By calling Unload Me there you're running a loop. Something has called you to unload. The unloadmode parameter tells you where the message came from. So if the system is restarting you'll get an event with unloadmode of 2 or 3. You should always let those through and quit. When you call Unload Me there you cause another QueryUnload event where unloadmode is 1. If you don't need to check for files to save, etc., then you don't need to do anything. Just let the form get unloaded. If you do need to check you use something like the following (but don't put it in dialogue forms that might fire an unloadmode of 5) Private Sub Form_QueryUnload(cancel As Integer, unloadmode As Integer) Dim LRet as long ' quit unless the X close button was clicked. You ' might also check here for File ->Exit. That would ' result in unloadmode of 1 but to the person using ' the program it's the same as the Close button. If unloadmode <> 0 then Exit sub 'still going? Then Close button was clicked. LRet = MsgBox("Do you want to save the current file before quitting?", 35) Select Case LRet Case 7 Exit Sub '-- let it unload. The system will get the '-- return message it's waiting for. Case 6 '-- save work and then deal with quitting Case 2 cancel = 1 '-- They decided not to close, so block any further unload action. End Select | | Sorry it took so long to try out the code, but sadly "no go". I | implemented the code fragment in an app and then ran the Windows 7 Windows | Qualification test. Here is the code fragment and what I received as the | result. :-( | | ---------------------------------------------------------------------------------------------------------------------------------------------------- | Code Fragment | ---------------------------------------------------------------------------------------------------------------------------------------------------- | Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) | 'Handle the request. | Cancel = False | | 'Process the request conforming to Microsoft Windows 7 compatibilty | requirements. | If UnloadMode = 0 Then | 'Ask about saving open files before closing and provide a cancel | option. | | 'There is nothing to ask about, as there are no data files to save. | Else | 'Quit. Either the system or your own code is telling you to close. | | 'Fall through to end the program. | Unload Me | End If | End Sub | ---------------------------------------------------------------------------------------------------------------------------------------------------- | | | ---------------------------------------------------------------------------------------------------------------------------------------------------- | Windows 7 Qualification Report | ---------------------------------------------------------------------------------------------------------------------------------------------------- | 7. Adhere to Restart Manager messages | | | Test case: Don't block reboot: PASS WITH WARNINGS | | WARNING: The following files did not respond to system restart requests: | Executable c:\program files (x86)\butterflyvista\metricwiz\metricwiz.exe | failed to shutdown. | Some applications as part of their first launch display EULAs or auto update | prompts, registration forms, etc. If your application performs in this way, | it could be falsely reported as non-compliant with the restart requirement. | If any of the above files are reported for this reason, you should restart | testing from a clean state (clean OS). This time around, before running the | /postinstall phase, execute any run-once functionality in the application | PRIOR to running the /postinstall phase of the toolkit. | IMPACT IF NOT FIXED: By failing to shutdown gracefully, customers could lose | data when the OS finally forces a shutdown. It also slows the | shutdown/reboot process, impacting performance perceptions. | HOW TO FIX: In a critical shutdown, applications that return FALSE to | WM_QUERYENDSESSION will be sent WM_ENDSESSION and closed, while those that | time out in response to WM_QUERYENDSESSION, will be terminated. By following | these guidelines, you can ensure that your application will handle critical | shutdowns gracefully: | WM_QUERYENDSESSION with LPARAM = ENDSESSION_CLOSEAPP(0x1): GUI 19 | applications must respond (TRUE) immediately in preparation for a restart | WM_ENDSESSION with LPARAM = ENDSESSION_CLOSEAPP(0x1): Applications must | return a 0 value within 30 seconds and shut down. At a minimum, applications | should prepare by saving any user data and state information that is needed | after a restart | Console applications that receive CTRL_C_EVENT notification should shut down | immediately. Drivers must not veto a system shutdown event | More information and guidance on requesting and responding to system | shutdowns and the RestartManager is available HERE. | ---------------------------------------------------------------------------------------------------------------------------------------------------- | | As you can see, the test reported a failure even though I am implementing | the Form_QueryUnload. | | Thoughts? | | Thanks, | | Sarah |
From: Bob Butler on 3 Jul 2010 11:02 "Mayayana" <mayayana(a)invalid.nospam> wrote in message news:i0nha5$alb$1(a)news.eternal-september.org... > Look up the QueryUnload event. By calling > Unload Me there you're running a loop. Actually, it doesn't start a loop; "Unload Me" is not needed because the form is already unloading but it is apparently ignored > Private Sub Form_QueryUnload(cancel As Integer, unloadmode As Integer) > Dim LRet as long > ' quit unless the X close button was clicked. You > ' might also check here for File ->Exit. That would > ' result in unloadmode of 1 but to the person using > ' the program it's the same as the Close button. > > If unloadmode <> 0 then Exit sub I'd suggest using the constants for better readability if unloadmodeM<vbFormControlMenu Then Exit sub of course, that means it won't ask to save if the form is closing for any other reason so that may not be what is wanted. > 'still going? Then Close button was clicked. > > LRet = MsgBox("Do you want to save the current file before quitting?", > 35) > Select Case LRet > Case 7 > Exit Sub '-- let it unload. The system will get the > '-- return message it's waiting for. > Case 6 > '-- save work and then deal with quitting > Case 2 > cancel = 1 '-- They decided not to close, so block any further > unload action. > End Select and I'd definitely use the constants there rather than the numeric values LRet = MsgBox("Do you want to save the current file before quitting?", _ vbYesNoCancel,"Save changes?") Select Case LRet Case vbNo: ' no action needed Case vbYes: 'save and clear any 'dirty' flags Case vbCancel: cancel = True ' try to abort the unload End Select
From: Sarah M. Weinberger on 3 Jul 2010 11:56 Hi All, I had the code WITHOUT the added "Unload Me" until last night. I added that hoping that that would get rid of the warning, but sadly does not. The warning persists. Questions: 1. Is there an easier way to test the shutdown without having to go through the lengthly windows 7 qualification test? 2. Do all VB6 based applications suffer from this warning? 3. Thoughts on getting rid of the warning? Yes, I will take the Unload Me statement out again, but will not run the test, as that was already done. Sarah
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: SetKeyboardState to send Ctrl key combinations Next: Print on two sides |