A question regarding SetWindowPos
The last argument for SetWindowPos nFlags could be SWP_SHOWWINDOW. But we can also call ShowWindow with SW_SHOW. Is there any difference between SW_SHOW and SWP_SHOWWINDOW in using them? Thanks.
Re: A question regarding SetWindowPos
Quote:
Originally Posted by
LarryChen
The last argument for SetWindowPos nFlags could be SWP_SHOWWINDOW. But we can also call ShowWindow with SW_SHOW. Is there any difference between SW_SHOW and SWP_SHOWWINDOW in using them? Thanks.
Regarding to Microsoft's MSDN you should use SWP_xxxxx constants as the last parameter of SetWindowPos. SW_xxx constants are for the ShowWindow function.
Regards
PA
Re: A question regarding SetWindowPos
Quote:
Originally Posted by
ProgramArtist
Regarding to Microsoft's MSDN you should use SWP_xxxxx constants as the last parameter of SetWindowPos. SW_xxx constants are for the ShowWindow function.
Regards
PA
Thanks for your reply. Basically my question is that since we might use SetWindowPos with SWP_SHOWWINDOW, why'd we need to call ShowWindow with SW_SHOW? Thanks.
Re: A question regarding SetWindowPos
It's two different functions why should you mix up the constants that are used in combination with them? Do you apply the same logic to return values as well? :confused:
Re: A question regarding SetWindowPos
Quote:
Originally Posted by
LarryChen
Thanks for your reply. Basically my question is that since we might use SetWindowPos with SWP_SHOWWINDOW, why'd we need to call ShowWindow with SW_SHOW? Thanks.
You do not need to call "ShowWindow with SW_SHOW" direct after "SetWindowPos with SWP_SHOWWINDOW" has been called.
Re: A question regarding SetWindowPos
As I understand it he asks if he can use SWP_SHOWWINDOW with ShowWindow
Re: A question regarding SetWindowPos
Quote:
Originally Posted by
S_M_A
As I understand it he asks if he can use SWP_SHOWWINDOW with ShowWindow
Well, it's very hard to understand what he means reading his OP... :eek:
but the second post sounds a bit more clear for me. Although i may be wrong. :rolleyes:
Re: A question regarding SetWindowPos
Sorry, I didn't state my question well. Basically when we want to display a window, we typically call SetWinowPos to set the size, position, etc for the window. Then I realize there is a parameter SWP_SHOWWINDOW with SetWindowPos. It seems like for me that it indicates to show the window. Okey, at this point, here comes my question. Since we can use SetWindowPos to show the window, why'd we need to call ShowWindow with SW_SHOW? Hopefully I explain my question well this time. Thanks.
Re: A question regarding SetWindowPos
It's not clear why you're implying a relationship between SetWindowPos and ShowWindow. They do different things. Are you saying you call SetWindowPos with SWP_SHOWWINDOW and you still need to call ShowWindow to see the window?
Re: A question regarding SetWindowPos
Quote:
Originally Posted by
GCDEF
It's not clear why you're implying a relationship between SetWindowPos and ShowWindow. They do different things. Are you saying you call SetWindowPos with SWP_SHOWWINDOW and you still need to call ShowWindow to see the window?
If SetWindowPos is called with SWP_SHOWWINDOW, does it show the window? If it does, is there any difference if I call ShowWindow with SW_SHOW to show the window?
Re: A question regarding SetWindowPos
Quote:
Originally Posted by
LarryChen
If SetWindowPos is called with SWP_SHOWWINDOW, does it show the window? If it does, is there any difference if I call ShowWindow with SW_SHOW to show the window?
Try it and see.
Re: A question regarding SetWindowPos
Quote:
Originally Posted by
GCDEF
Try it and see.
I tried it and couldn't really see any difference. I wonder if there is any difference in deep? Thanks.
Re: A question regarding SetWindowPos
SetWindwPos function can change size, position, z-order, can show/hide a window, and/or can activate a top-level window, all in a single call.
For some particular nFlags values it can behave like other functions.
In our case
Code:
UINT nFlags = SWP_SHOWWINDOW|SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE;
m_wnd.SetWindowPos(NULL, 0, 0, 0, 0, nFlags);
has the same effect like
Code:
m_wnd.ShowWindow(SW_SHOW);
If you simply want to make visible a hidden window, usually use ShowWindow which is simpler.
I would like to recommend paying attention to SetWindowPos and ShowWindow documentation, make some simple tests and see yourself which are the samenesses and differences.
Note: you can also discover other functions like MoveWindow, BringWindowToTop, etc which can be "simulated" with SetWindowPos.
Using one or another is up to your concrete needs, Windows programming knowledge and... taste ;)