vc中怎样移动窗口到(0,0)

来源:百度知道 编辑:UC知道 时间:2024/06/18 10:03:41
移动窗口我常用MoveWindow,比如this->MoveWindow(0,100,200,200)把窗口移动到(0,100),并指定其大小为(200,200).可是this->MoveWindow(0,0,200,200)时(0,0)被忽略,只指定大小为200,200.有人有办法解决这个问题吗.

用 SetWindowPos这个函数 (功能包括了MoveWindow这个函数)
你可以这样:

SetWindowPos(hWnd,HWND_TOPMOST,0,0,200,200,SWP_SHOWWINDOW);

窗口就移动到(0,0)的位置了

关于它的原型和说明:

The SetWindowPos function changes the size, position, and Z order of a child, pop-up, or top-level window. Child, pop-up, and top-level windows are ordered according to their appearance on the screen. The topmost window receives the highest rank and is the first window in the Z order.

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 flags
);

Parameters
hWnd
Handle to the window.
hWndInsertAfter
Handle to the window to precede the positioned win