Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
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   
>Also see Microsoft KB article 181934 ("How to create a timed message box").

Unfortunately that's the technique that's not working under Vista :(

Dave
date: Sun, 03 Aug 2008 17:09:58 +0100   author:   David Lowndes lid

Re: Behavior change with Vista   
>I have an application that up through XP works great, but I am having an 
>issue with the app under Vista.

Interestingly I find that this works as it does in XP provided that
the timedmessagebox doesn't have focus at the point where it times
out.

I wonder what's subtly different in Vista to have this effect?

Dave
date: Sun, 03 Aug 2008 17:23:35 +0100   author:   David Lowndes lid

Re: Behavior change with Vista   
>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

Raymond's code is based on the same fundamental technique of eating
the WM_QUIT message as shown in the MSDN sample, so although I've not
tried it, I don't think it'd work correctly under Vista either.

Dave
date: Sun, 03 Aug 2008 17:39:21 +0100   author:   David Lowndes lid

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   
>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.

I don't think it'll behave any differently either.

Can you try what I found - see if things work correctly if your timed
message box doesn't have the focus when the time expires.

Dave
date: Mon, 04 Aug 2008 16:15:26 +0100   author:   David Lowndes lid

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   
>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.)

You're right, it doesn't make 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.

Yep, that works under XP & Vista.

>I would have expected EndDialog() to work as well.

EndDialog is also fine under both OS's.

Thanks for the suggestion Norman.

Dave
date: Tue, 05 Aug 2008 18:56:10 +0100   author:   David Lowndes lid

Re: Behavior change with Vista   
Dave,

Thats a great suggestion! I wish I had thought of that. At one time the 
function I am using was a dialog procedure instead of a timer procedure 
and at this point I don't know why I changed it, but there had to be a 
reason for it. It may have been that I was creating a dialog dynamically 
myself, but then it got to be too much work to add all the buttons that 
could be on it depending on the specific criteria and sizing it 
appropriately for the amount of text which I also could not control. 
MessageBox() handles that all for me and until Vista, it was working 
beautifully and as documented.

I would still like to know why this doesn't work under Vista.

Thanks for your suggestion. I may implement that at some point when I 
have some spare time.

Regards,

Rich.

David Lowndes wrote:
>> 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.)
> 
> You're right, it doesn't make 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.
> 
> Yep, that works under XP & Vista.
> 
>> I would have expected EndDialog() to work as well.
> 
> EndDialog is also fine under both OS's.
> 
> Thanks for the suggestion Norman.
> 
> Dave
date: Tue, 05 Aug 2008 16:21:23 -0400   author:   Rich Douglass

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

Re: Behavior change with Vista   
>Dave,
>
>Thats a great suggestion!

It was Norman's suggestion.

>I wish I had thought of that.

Me too :)

>I would still like to know why this doesn't work under Vista.

Yes I would too - it might be an interesting item for Raymond Chen to
follow up on in his blog.

Dave
date: Tue, 05 Aug 2008 21:28:30 +0100   author:   David Lowndes lid

Re: Behavior change with Vista   
In article news:, Rich Douglass 
wrote:
> I would still like to know why this doesn't work under Vista.

Because Vista is broken?

Cheers,
 Daniel.
date: Thu, 07 Aug 2008 08:26:02 +0100   author:   Daniel James

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us