请问在SetWindowPos()的最后写的参数是:SWP_NOSIZE || SWP_SHOWWINDOW,什么意思?

ryrx 2007-07-27 09:48:37
rt
...全文
2218 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
sean1221 2009-10-28
  • 打赏
  • 举报
回复
说的真好,可量下不到MSDN
fatecui 2008-10-26
  • 打赏
  • 举报
回复
没过四级的看不懂噢哈哈哈哈
ccgxg 2007-07-28
  • 打赏
  • 举报
回复
同意 xiaoQ008

我来晚啦
xiaoQ008 2007-07-27
  • 打赏
  • 举报
回复
BOOL SetWindowPos(
HWND hWnd, // handle to window
HWND hWndInsertAfter, // placement-order handle
int X, // horizontal position
int Y, // vertical position
int cx, // width
int cy, // height
UINT uFlags // window-positioning options
);
如果你把uFlags设置成SWP_NOSIZE 则窗口的大小将保持不变,无论你把cx和cy设置成多少
窗口的大小始终保持不变
至于SWP_SHOWWINDOW 显然是把窗口显示出来啦 呵呵
和SWP_HIDEWINDOW隐藏窗口相反!
楼主 多看看MSDN噢!
这个函数的意思是:The SetWindowPos function changes the size, position, and Z order of a child, pop-up, or top-level window.
过了4级英语的应该可以看懂的噢!
jerry4711 2007-07-27
  • 打赏
  • 举报
回复
MSDN里的原话是这样的:

SWP_NOSIZE Retains the current size (ignores the cx and cy parameters).

SWP_SHOWWINDOW Displays the window.

建议楼主多看看MSDN哦!
WindAndSnow 2007-07-27
  • 打赏
  • 举报
回复
the SetWindowPos function assumes that SWP_NOMOVE and SWP_NOSIZE are set if SWP_HIDEWINDOW or SWP_SHOWWINDOW was set. Thus, hiding and showing a window and changing its size and position are not possible in an atomic operation.
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Diagnostics; using System.Runtime.InteropServices; namespace exe_test { public partial class Form1 : Form { public Form1() { InitializeComponent(); } Process process = null; IntPtr appWin; private string exeName = ""; [DllImport("user32.dll", EntryPoint = "GetWindowThreadProcessId", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] private static extern long GetWindowThreadProcessId(long hWnd, long lpdwProcessId); [DllImport("user32.dll", SetLastError = true)] private static extern IntPtr FindWindow(string lpClassName, string lpWindowName); [DllImport("user32.dll", SetLastError = true)] private static extern long SetParent(IntPtr hWndChild, IntPtr hWndNewParent); [DllImport("user32.dll", EntryPoint = "GetWindowLongA", SetLastError = true)] private static extern long GetWindowLong(IntPtr hwnd, int nIndex); [DllImport("user32.dll", EntryPoint = "SetWindowLongA", SetLastError = true)] private static extern long SetWindowLong(IntPtr hwnd, int nIndex, long dwNewLong); //private static extern int SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong); [DllImport("user32.dll", SetLastError = true)] private static extern long SetWindowPos(IntPtr hwnd, long hWndInsertAfter, long x, long y, long cx, long cy, long wFlags); [DllImport("user32.dll", SetLastError = true)] private static extern bool MoveWindow(IntPtr hwnd, int x, int y, int cx, int cy, bool repaint); [DllImport("user32.dll", EntryPoint = "PostMessageA", SetLastError = true)] private static extern bool PostMessage(IntPtr hwnd, uint Msg, long wParam, long lParam); private const int SWP_NOOWNERZORDER = 0x200; private const int SWP_NOREDRAW = 0x8; private const int SWP_NOZORDER = 0x4; private const int SWP_SHOWWINDOW = 0x0040; private const int WS_EX_MDICHILD = 0x40; private const int SWP_FRAMECHANGED = 0x20; private const int SWP_NOACTIVATE = 0x10; private const int SWP_ASYNCWINDOWPOS = 0x4000; private const int SWP_NOMOVE = 0x2; private const int SWP_NOSIZE = 0x1; private const int GWL_STYLE = (-16); private const int WS_VISIBLE = 0x10000000; private const int WM_CLOSE = 0x10; private const int WS_CHILD = 0x40000000; public string ExeName { get { return exeName; } set { exeName = value; } } private void button1_Click(object sender, EventArgs e) { this.exeName = @"calc.exe"; try { process = System.Diagnostics.Process.Start(this.exeName); process.WaitForInputIdle(); System.Threading.Thread.Sleep(150); appWin = process.MainWindowHandle; } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error"); } SetParent(appWin, this.splitContainer1.Panel2.Handle); MoveWindow(appWin, 0, 0, this.Width, this.Height, true); } } }

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧