|
-
November 28th, 2011, 06:11 PM
#1
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.
-
November 29th, 2011, 01:43 AM
#2
Re: A question regarding SetWindowPos
 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
-
November 29th, 2011, 09:39 AM
#3
Re: A question regarding SetWindowPos
 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.
-
November 29th, 2011, 03:01 PM
#4
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?
Last edited by S_M_A; November 29th, 2011 at 03:31 PM.
-
November 29th, 2011, 03:05 PM
#5
Re: A question regarding SetWindowPos
 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.
Victor Nijegorodov
-
November 29th, 2011, 03:32 PM
#6
Re: A question regarding SetWindowPos
As I understand it he asks if he can use SWP_SHOWWINDOW with ShowWindow
-
November 29th, 2011, 03:39 PM
#7
-
November 29th, 2011, 03:51 PM
#8
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.
-
November 29th, 2011, 03:56 PM
#9
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?
-
November 29th, 2011, 04:19 PM
#10
Re: A question regarding SetWindowPos
 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?
-
November 29th, 2011, 04:20 PM
#11
Re: A question regarding SetWindowPos
 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.
-
November 29th, 2011, 04:23 PM
#12
Re: A question regarding SetWindowPos
 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.
-
November 30th, 2011, 03:15 AM
#13
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|