关于SetWindowPlacement?(90分)

  • 主题发起人 主题发起人 penga
  • 开始时间 开始时间
P

penga

Unregistered / Unconfirmed
GUEST, unregistred user!
我在程序中用SetWindowPlacement(handle,@p)其中p:TWindowPlacement;<br>来控制窗口的状态(目的是点击最大化按钮后窗体变成只剩标题栏,位于屏<br>幕右上角,再次点击恢复原状。但我手头缺少参考书不知TWindowPlacement<br>类型应如何设置我试了几次都不很成功,请各位帮我一把。
 
在已答问题中我用过它:)<br>&lt;a href="http://www.gislab.ecnu.edu.cn/delphibbs/DispQ.asp?LID=145323"&gt;这里&lt;/a&gt;<br>
 
&nbsp; 不一定用SetWindowPlacement,这种情总只需对WM_SIZE进行自己的消息<br>处理就行了。
 
<br>其中WINDOWPLACEMENT的结构及参数的含意可见msdn中的说明:<br><br>The WINDOWPLACEMENT structure contains information about the <br>placement of a window on the screen. <br><br>typedef struct _WINDOWPLACEMENT { <br>&nbsp; &nbsp; UINT &nbsp;length; <br>&nbsp; &nbsp; UINT &nbsp;flags; <br>&nbsp; &nbsp; UINT &nbsp;showCmd; <br>&nbsp; &nbsp; POINT ptMinPosition; <br>&nbsp; &nbsp; POINT ptMaxPosition; <br>&nbsp; &nbsp; RECT &nbsp;rcNormalPosition; <br>} WINDOWPLACEMENT; <br>&nbsp;<br>Members<br>length <br>Specifies the length, in bytes, of the structure. Before calling the <br>GetWindowPlacement or SetWindowPlacement functions, set this member <br>to sizeof(WINDOWPLACEMENT). <br>GetWindowPlacement and SetWindowPlacement fail if this member is not <br>set correctly. <br><br>flags <br>Specifies flags that control the position of the minimized window and <br>the method by which the window is restored. This member can be one or <br>both of the following values:<br>&nbsp; Value Meaning WPF_RESTORETOMAXIMIZED <br>&nbsp;Specifies that the restored window will be maximized, regardless of <br>whether it was maximized before it was minimized. This setting is <br>only valid the next time the window is restored. It does not change <br>the default restoration behavior. This flag is only valid when the <br>SW_SHOWMINIMIZED value is specified for the showCmd member. <br>WPF_SETMINPOSITION <br>&nbsp;Specifies that the coordinates of the minimized window may be <br>specified. This flag must be specified if the coordinates are set in <br>the ptMinPosition member. <br><br><br>showCmd <br>Specifies the current show state of the window. This member can be <br>one of the following values: Value Meaning <br>SW_HIDE Hides the window and activates another window. <br>SW_MINIMIZE Minimizes the specified window and activates the top-<br>level window in the system's list. <br>SW_RESTORE Activates and displays a window. If the window is <br>minimized or maximized, the system restores it to its original size <br>and position (same as SW_SHOWNORMAL). <br>SW_SHOW Activates a window and displays it in its current size and <br>position. <br>SW_SHOWMAXIMIZED Activates a window and displays it as a maximized <br>window. <br>SW_SHOWMINIMIZED Activates a window and displays it as an icon. <br>SW_SHOWMINNOACTIVE Displays a window as an icon. The active window <br>remains active. <br>SW_SHOWNA Displays a window in its current state. The active window <br>remains active. <br>SW_SHOWNOACTIVATE Displays a window in its most recent size and <br>position. The active window remains active. <br>SW_SHOWNORMAL Activates and displays a window. If the window is <br>minimized or maximized, the system restores it to its original size <br>and position (same as SW_RESTORE). <br><br><br>ptMinPosition <br>Specifies the coordinates of the window's upper-left corner when the <br>window is minimized. <br>ptMaxPosition <br>Specifies the coordinates of the window's upper-left corner when the <br>window is maximized. <br>rcNormalPosition <br>Specifies the window's coordinates when the window is in the restored <br>position. <br>Remarks<br>If the window is a top-level window that does not have the <br>WS_EX_TOOLWINDOW window style, then the coordinates represented by <br>the following members are in workspace coordinates: ptMinPosition, <br>ptMaxPosition, and rcNormalPosition. Otherwise, these members are in <br>screen coordinates.<br><br>Workspace coordinates differ from screen coordinates in that they <br>take the locations and sizes of appbars (including the taskbar) into <br>account. Workspace coordinate (0,0) is the upper-left corner of <br>the "workspace area", the area of the screen not being used by <br>appbars.<br><br>The coordinates used in a WINDOWPLACEMENT structure should be used <br>only by the GetWindowPlacement and SetWindowPlacement functions. <br>Passing workspace coordinates to functions which expect screen <br>coordinates (such as SetWindowPos) will result in the window <br>appearing in the wrong location. For example, if the taskbar is at <br>the top of the screen, saving window coordinates using <br>GetWindowPlacement and restoring them using SetWindowPos causes the <br>window to appear to "creep" up the screen. <br>
 
接受答案了.
 
后退
顶部