|
|
|
date: Tue, 29 Jul 2008 13:09:54 -0400,
group: microsoft.public.win32.programmer.ui
back
Behavior change with Vista
Hi,
I have an application that up through XP works great, but I am having an
issue with the app under Vista.
What I want to do is put up a message box with MessageBox() and wait
only so long for the user to respond to it. So what I did was create a
timer dlgproc and upon the completion of the timeout without any
response, I called PostQuitMessage() to close that dialog. This all
works as expected.
After the call to MessageBox() completes, I call PeekMessage() in a loop
to remove any further WM_QUIT messages in the queue.
Under XP and below, my application continues on as it should, but under
Vista, it seems like the application frame window is getting a WM_QUIT
message and then it shuts right down.
I would appreciate any suggestions of how to handle this so it works for
any version of Windows, but if that's not possible, I can detect Vista
and handle it differently.
Thanks in advance.
Rich.
date: Tue, 29 Jul 2008 13:09:54 -0400
author: Rich Douglass
Re: Behavior change with Vista
Rich Douglass wrote:
> Hi,
>
> I have an application that up through XP works great, but I am having an
> issue with the app under Vista.
>
> What I want to do is put up a message box with MessageBox() and wait
> only so long for the user to respond to it. So what I did was create a
> timer dlgproc and upon the completion of the timeout without any
> response, I called PostQuitMessage() to close that dialog. This all
> works as expected.
>
> After the call to MessageBox() completes, I call PeekMessage() in a loop
> to remove any further WM_QUIT messages in the queue.
>
> Under XP and below, my application continues on as it should, but under
> Vista, it seems like the application frame window is getting a WM_QUIT
> message and then it shuts right down.
>
> I would appreciate any suggestions of how to handle this so it works for
> any version of Windows, but if that's not possible, I can detect Vista
> and handle it differently.
>
> Thanks in advance.
>
> Rich.
Raymond Chen has an entry in his blog about creating a timed message box. I
can't comment on whether his code works on Vista or not, but if you have not
already looked at it you might want to do so.
http://blogs.msdn.com/oldnewthing/archive/2005/03/04/385100.aspx
--
Larry Futrell
date: Wed, 30 Jul 2008 16:21:03 -0400
author: Larry Futrell am
Re: Behavior change with Vista
>What I want to do is put up a message box with MessageBox() and wait
>only so long for the user to respond to it. So what I did was create a
>timer dlgproc and upon the completion of the timeout without any
>response, I called PostQuitMessage() to close that dialog. This all
>works as expected.
Rich,
Let me guess that your code looks something like this:
UINT TimedMessageBox( HWND hwndParent, LPCTSTR ptszMessage, LPCTSTR
ptszTitle, UINT flags, DWORD dwTimeout)
{
UINT_PTR idTimer;
UINT uiResult;
MSG msg;
idTimer = SetTimer(NULL, 0, dwTimeout,
(TIMERPROC)MessageBoxTimer);
uiResult = MessageBox(hwndParent, ptszMessage, ptszTitle, flags);
KillTimer(NULL, idTimer);
if (PeekMessage(&msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE))
{
uiResult = 0;
}
return uiResult;
}
... which I have in one of my applications.
>Under XP and below, my application continues on as it should, but under
>Vista, it seems like the application frame window is getting a WM_QUIT
>message and then it shuts right down.
I'd been unaware of this behaviour (I must never have tested waiting
for the timeout period on Vista), but I can confirm that my
application behaves the same and exists :(
Have you tried the versions of Raymond Chen's that Larry's linked to?
Dave
date: Thu, 31 Jul 2008 16:48:29 +0100
author: David Lowndes lid
Re: Behavior change with Vista
Rich Douglass wrote:
> Hi,
>
> I have an application that up through XP works great, but I am having an
> issue with the app under Vista.
>
> What I want to do is put up a message box with MessageBox() and wait
> only so long for the user to respond to it. So what I did was create a
> timer dlgproc and upon the completion of the timeout without any
> response, I called PostQuitMessage() to close that dialog. This all
> works as expected.
>
> After the call to MessageBox() completes, I call PeekMessage() in a loop
> to remove any further WM_QUIT messages in the queue.
>
> Under XP and below, my application continues on as it should, but under
> Vista, it seems like the application frame window is getting a WM_QUIT
> message and then it shuts right down.
>
> I would appreciate any suggestions of how to handle this so it works for
> any version of Windows, but if that's not possible, I can detect Vista
> and handle it differently.
Further to the other posts, I use EndDialog() which, while I haven't
explicitly tested it should not propagate to anything else.
--
Dean Earley (dean.earley@icode.co.uk)
i-Catcher Development Team
iCode Systems
date: Thu, 31 Jul 2008 17:01:00 +0100
author: Dean Earley
Re: Behavior change with Vista
Also see Microsoft KB article 181934 ("How to create a timed message box").
"Rich Douglass" wrote in message
news:uiVMv3Z8IHA.2336@TK2MSFTNGP03.phx.gbl...
> Hi,
>
> I have an application that up through XP works great, but I am having an
> issue with the app under Vista.
>
> What I want to do is put up a message box with MessageBox() and wait only
> so long for the user to respond to it. So what I did was create a timer
> dlgproc and upon the completion of the timeout without any response, I
> called PostQuitMessage() to close that dialog. This all works as expected.
>
> After the call to MessageBox() completes, I call PeekMessage() in a loop
> to remove any further WM_QUIT messages in the queue.
>
> Under XP and below, my application continues on as it should, but under
> Vista, it seems like the application frame window is getting a WM_QUIT
> message and then it shuts right down.
>
> I would appreciate any suggestions of how to handle this so it works for
> any version of Windows, but if that's not possible, I can detect Vista and
> handle it differently.
>
> Thanks in advance.
>
> Rich.
>
date: Fri, 1 Aug 2008 22:16:51 -0700
author: Sam Hobbs _change_social_to_socal
Re: Behavior change with Vista
Thank you all for your comments. I am going to take a look at Chen's
blog to see what he has there, but the guessed code example looks almost
identical to my code.
In my timer proc I have tried the following with no success in my
attempt to resolve this issue:
PostQuitMessage(1);
PostThreadMessage((DWORD)GetCurrentThread(), WM_QUIT, 1, 1);
PostMessage(hdlg, WM_DESTROY, 1, 1);
EndDialog(hdlg, FALSE);
This is very frustrating. I have also contemplated sending a custom
message and attaching my own dialog proc to MessageBox() and then
calling EndDialog() there, but that's the only thing I can see at this
point.
Any other suggestions would be greatly appreciated.
Thanks.
Rich.
Rich Douglass wrote:
> Hi,
>
> I have an application that up through XP works great, but I am having an
> issue with the app under Vista.
>
> What I want to do is put up a message box with MessageBox() and wait
> only so long for the user to respond to it. So what I did was create a
> timer dlgproc and upon the completion of the timeout without any
> response, I called PostQuitMessage() to close that dialog. This all
> works as expected.
>
> After the call to MessageBox() completes, I call PeekMessage() in a loop
> to remove any further WM_QUIT messages in the queue.
>
> Under XP and below, my application continues on as it should, but under
> Vista, it seems like the application frame window is getting a WM_QUIT
> message and then it shuts right down.
>
> I would appreciate any suggestions of how to handle this so it works for
> any version of Windows, but if that's not possible, I can detect Vista
> and handle it differently.
>
> Thanks in advance.
>
> Rich.
date: Mon, 04 Aug 2008 09:26:12 -0400
author: Rich Douglass
Re: Behavior change with Vista
Thanks again for all your suggestions. I didn't see much in Chen's blog
that looked interesting, so I went about trying to catch the WM_QUIT
message in my message loops. I found that by calling PostQuitMessage()
and passing in the window handle of my primary window, I could catch it
in my WinMain() function and know that it is the one I generated.
I don't like it, it's not pretty, it's a change in behavior that is not
documented and it's taken me way too much time already. But it seems to
work and that's what counts at this point.
I would still like a better solution if anyone has a better idea.
Thanks.
Rich.
Rich Douglass wrote:
> Hi,
>
> I have an application that up through XP works great, but I am having an
> issue with the app under Vista.
>
> What I want to do is put up a message box with MessageBox() and wait
> only so long for the user to respond to it. So what I did was create a
> timer dlgproc and upon the completion of the timeout without any
> response, I called PostQuitMessage() to close that dialog. This all
> works as expected.
>
> After the call to MessageBox() completes, I call PeekMessage() in a loop
> to remove any further WM_QUIT messages in the queue.
>
> Under XP and below, my application continues on as it should, but under
> Vista, it seems like the application frame window is getting a WM_QUIT
> message and then it shuts right down.
>
> I would appreciate any suggestions of how to handle this so it works for
> any version of Windows, but if that's not possible, I can detect Vista
> and handle it differently.
>
> Thanks in advance.
>
> Rich.
date: Mon, 04 Aug 2008 10:47:23 -0400
author: Rich Douglass
Re: Behavior change with Vista
Rich Douglass wrote:
> Thank you all for your comments. I am going to take a look at Chen's
> blog to see what he has there, but the guessed code example looks almost
> identical to my code.
>
> In my timer proc I have tried the following with no success in my
> attempt to resolve this issue:
>
> PostQuitMessage(1);
> PostThreadMessage((DWORD)GetCurrentThread(), WM_QUIT, 1, 1);
> PostMessage(hdlg, WM_DESTROY, 1, 1);
> EndDialog(hdlg, FALSE);
>
> This is very frustrating. I have also contemplated sending a custom
> message and attaching my own dialog proc to MessageBox() and then
> calling EndDialog() there, but that's the only thing I can see at this
> point.
>
> Any other suggestions would be greatly appreciated.
>
> Thanks.
>
> Rich.
>
I used a different technique which worked for me under Windows NT. I
can't see any reason why it should not work under Vista but, who knows?
I created a timer just as you have before calling MessageBox() but my
timer was set to send a WM_TIMER message instead of calling a procedure.
(I don't think that makes any difference.) When the WM_TIMER message
arrived I used FindWindow() to locate the message box window. (The class
name is always the same and you know what you put in the caption.) Then
use PostMessage() to send to that window a WM_COMMAND with wParam equal
to the button ID that you want the message box to return.
I would have expected EndDialog() to work as well. What did you pass as
the hdlg parameter when you called EndDialog() and how did you get it?
--
Norm
To reply, change domain to an adult feline.
date: Mon, 04 Aug 2008 18:22:39 -0700
author: Norman Bullen
Re: Behavior change with Vista
PostMessage(hdlg, WM_DESTROY, 1, 1);
is fundamentally wrong. You never send or post WM_DESTROY. You can only
receive it from the window manager.
"Rich Douglass" wrote in message
news:ujFgDXj9IHA.1468@TK2MSFTNGP05.phx.gbl...
> Thank you all for your comments. I am going to take a look at Chen's blog
> to see what he has there, but the guessed code example looks almost
> identical to my code.
>
> In my timer proc I have tried the following with no success in my attempt
> to resolve this issue:
>
> PostQuitMessage(1);
> PostThreadMessage((DWORD)GetCurrentThread(), WM_QUIT, 1, 1);
> PostMessage(hdlg, WM_DESTROY, 1, 1);
> EndDialog(hdlg, FALSE);
>
> This is very frustrating. I have also contemplated sending a custom
> message and attaching my own dialog proc to MessageBox() and then calling
> EndDialog() there, but that's the only thing I can see at this point.
>
> Any other suggestions would be greatly appreciated.
>
> Thanks.
>
> Rich.
>
> Rich Douglass wrote:
>> Hi,
>>
>> I have an application that up through XP works great, but I am having an
>> issue with the app under Vista.
>>
>> What I want to do is put up a message box with MessageBox() and wait only
>> so long for the user to respond to it. So what I did was create a timer
>> dlgproc and upon the completion of the timeout without any response, I
>> called PostQuitMessage() to close that dialog. This all works as
>> expected.
>>
>> After the call to MessageBox() completes, I call PeekMessage() in a loop
>> to remove any further WM_QUIT messages in the queue.
>>
>> Under XP and below, my application continues on as it should, but under
>> Vista, it seems like the application frame window is getting a WM_QUIT
>> message and then it shuts right down.
>>
>> I would appreciate any suggestions of how to handle this so it works for
>> any version of Windows, but if that's not possible, I can detect Vista
>> and handle it differently.
>>
>> Thanks in advance.
>>
>> Rich.
date: Mon, 4 Aug 2008 21:11:41 -0700
author: Alexander Grigoriev
Re: Behavior change with Vista
Alexander,
I agree with you that PostMessage() with WM_DESTROY is wrong, but I
think once there was an error in the MS docs, so out of desperation, I
tried it. And as expected, it didn't work.
Regards,
Rich.
Alexander Grigoriev wrote:
> PostMessage(hdlg, WM_DESTROY, 1, 1);
>
> is fundamentally wrong. You never send or post WM_DESTROY. You can only
> receive it from the window manager.
>
>
>
>
> "Rich Douglass" wrote in message
> news:ujFgDXj9IHA.1468@TK2MSFTNGP05.phx.gbl...
>> Thank you all for your comments. I am going to take a look at Chen's blog
>> to see what he has there, but the guessed code example looks almost
>> identical to my code.
>>
>> In my timer proc I have tried the following with no success in my attempt
>> to resolve this issue:
>>
>> PostQuitMessage(1);
>> PostThreadMessage((DWORD)GetCurrentThread(), WM_QUIT, 1, 1);
>> PostMessage(hdlg, WM_DESTROY, 1, 1);
>> EndDialog(hdlg, FALSE);
>>
>> This is very frustrating. I have also contemplated sending a custom
>> message and attaching my own dialog proc to MessageBox() and then calling
>> EndDialog() there, but that's the only thing I can see at this point.
>>
>> Any other suggestions would be greatly appreciated.
>>
>> Thanks.
>>
>> Rich.
>>
>> Rich Douglass wrote:
>>> Hi,
>>>
>>> I have an application that up through XP works great, but I am having an
>>> issue with the app under Vista.
>>>
>>> What I want to do is put up a message box with MessageBox() and wait only
>>> so long for the user to respond to it. So what I did was create a timer
>>> dlgproc and upon the completion of the timeout without any response, I
>>> called PostQuitMessage() to close that dialog. This all works as
>>> expected.
>>>
>>> After the call to MessageBox() completes, I call PeekMessage() in a loop
>>> to remove any further WM_QUIT messages in the queue.
>>>
>>> Under XP and below, my application continues on as it should, but under
>>> Vista, it seems like the application frame window is getting a WM_QUIT
>>> message and then it shuts right down.
>>>
>>> I would appreciate any suggestions of how to handle this so it works for
>>> any version of Windows, but if that's not possible, I can detect Vista
>>> and handle it differently.
>>>
>>> Thanks in advance.
>>>
>>> Rich.
>
>
date: Tue, 05 Aug 2008 16:23:10 -0400
author: Rich Douglass
|
|