Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

WM_SHOWWINDOW and ShowWindow(hWnd, SW_SHOWNORMAL)

1,072 views
Skip to first unread message

JohnD

unread,
Nov 25, 2008, 10:36:35 AM11/25/08
to
Hello all,

I asked this on "microsoft.public.win32.programmer.ui" and got directed
here, hopefully you can help.

I need to to some processing whenever a window in my application is made
visible. I'd hoped to do this with the WM_SHOWWINDOW handler. Rather
annoyingly this message is not sent if ShowWindow() is called with
SW_SHOWNORMAL (anyone know why?). I can't really track down all the call
sites that make this window visible and I don't really want to cover
ShowWindow(). I don't think the message is sent if SetWindowPos is used to
show the window either.

What's a good way of running code when a window is made visible, regardless
of the mechanism?

Thanks,

john.

Fred

unread,
Nov 25, 2008, 11:06:53 AM11/25/08
to
JohnD wrote:
> Hello all,

> I need to to some processing whenever a window in my application is made
> visible.

What do you mean by "visible" ?
shown/hidden, partially visible, completely visible(topmost), .. ?

Christian ASTOR

unread,
Nov 25, 2008, 11:35:31 AM11/25/08
to
JohnD wrote:

> I need to to some processing whenever a window in my application is made
> visible. I'd hoped to do this with the WM_SHOWWINDOW handler. Rather
> annoyingly this message is not sent if ShowWindow() is called with
> SW_SHOWNORMAL (anyone know why?).

It's called only is the visible state of the window changes
Otherwise, WM_SIZE is sent (before WM_WINDOWPOSCHANGING, activating,... etc)

JohnD

unread,
Nov 26, 2008, 3:29:05 AM11/26/08
to
OK, I'll be a little more specific.

A window is either "hidden" (ShowWindow(hWnd,zero)), or "not hidden"
(ShowWindow(hWnd,non zero)).

I need to catch the case when a window becomes non-hidden for whatever
reason. So partialy exposed doesn't count, restored / maximized don't
count. Z-order changes don't count. I suppose it could also be described as
when the state of the WS_VISIBLE bit changes (Hmm, wonder if WM_STYLECHANGED
would help?).

I guess SW_SHOWNORMAL is special because it could be used to restore a
minimized or maxmized window, without changing the WS_VISIBLE bit, however
it is also frequently used to make a non-visible window visible.

Thanks,

/John.

(What I actually want to do is send the WM_UPDATEUISTATE message to the
window to get mnemonics on controls correct. My understanding of this
message is that is only automatically sent by the system in dialog boxes,
not on "regular" windows. So, I want to catch the initial "show" of the
window and send this message then)


"JohnD" <jo...@dyalog.com> wrote in message news:ggh622$gg0$1...@aioe.org...

antoine

unread,
Nov 26, 2008, 6:20:55 AM11/26/08
to
"JohnD" <jo...@dyalog.com> wrote in message news:ggj1cf$dik$1...@aioe.org...

> OK, I'll be a little more specific.
>
> A window is either "hidden" (ShowWindow(hWnd,zero)), or "not hidden"
> (ShowWindow(hWnd,non zero)).
> I need to catch the case when a window becomes non-hidden for whatever
> reason. So partialy exposed doesn't count, restored / maximized don't
> count. Z-order changes don't count. I suppose it could also be described
> as when the state of the WS_VISIBLE bit changes (Hmm, wonder if
> WM_STYLECHANGED would help?).
>
> I guess SW_SHOWNORMAL is special because it could be used to restore a
> minimized or maxmized window, without changing the WS_VISIBLE bit, however
> it is also frequently used to make a non-visible window visible.

Then WM_SHOWWINDOW is always sent when the window becomes visible.
With
ShowWindow(hWnd, SW_HIDE);
folowed by
ShowWindow(hWnd, SW_SHOWNORMAL);
I get WM_SHOWWINDOW


JohnD

unread,
Nov 27, 2008, 8:21:14 AM11/27/08
to
Hi Antoine,

Oh, ok, I'll check that. That's not what the documentation says, but I admit
I didn't check.

Thanks.

"antoine" <ant...@nospam.com> wrote in message
news:ggjbeg$3bh$1...@aioe.org...

0 new messages