具体代码 #include "stdafx.h" #include<windows.h> #include<iostream> using namespace std; void main() { hwnd=FindWindowW(NULL,_T("Skype™ ")); int i=110; MoveWindow(hwnd,100+i,100,120,180,1); int x=350; int y=200; int cx=400; int cy=400; SetWindowPos(hwnd,HWND_TOPMOST,x,y,cx,cy,SWP_SHOWWINDOW); RECT rect,rect1; GetWindowRect(hwnd,&rect); GetClientRect(hwnd,&rect1); SetWindowPos(hwnd,HWND_TOPMOST,x,y,cx,cy,SWP_SHOWWINDOW); cout<<rect.top<<" "<<rect.left<<" "<<rect.bottom<<" "<<rect.right<<endl; } 前面MOVEWINDOW和SETWINDOW都起作用了,但是 1.SET WINdow的位置坐标是按照屏幕分辨率?感觉不像 2.最后4个输出结果是-38000 -38000 -37920 -37920,请指教,谢谢我有更好的答案
提问者采纳
2012-01-17 13:47
代码没问题,窗口最小化了之后就会那样 使最小化的窗口正常化:ShowWindow(hwnd, SW_NORMAL) 放在你的MoveWindow之前
-
提问者评价
-
嗯,我后来自己调试也发现了是因为最小化了,加入ShowWindow(hwnd, SW_NORMAL) 确实更安全,谢谢了