获得窗体指针的办法FromHandle,WindowFromPoint

HWND hWnd = GetSafeHwnd();
CWnd* pWnd = FromHandle(hWnd);


CPoint point;
GetCursorPos(&point);
CWnd* pWnd = WindowFromPoint(point);


//设置窗口的层次使其置顶局中显示
SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);//static AFX_DATA const CWnd wndTopMost; // SetWindowPos pWndInsertAfter定义在afxwin.h
CenterWindow();




CRect rect;
GetWindowRect(rect);
rect.OffsetRect(0,0);
MoveWindow(rect);


FlashWindow(TRUE/FALSE)可以产生类似QQ的闪烁效果
SetWindowRgn()可以设置窗体区域,从而产生透明窗体的效果


//显示动画窗口
AnimateWindow(1000, AW_BLEND);//可以让窗体渐渐显示出来


//获得桌面窗口
CWnd* pWnd = CWnd::GetDesktopWindow();


//最小化所有桌面窗体
//获得任务栏窗口
CWnd* pWnd = CWnd::FindWindow(_T("Shell_TrayWnd"), NULL);




//发送ID为0x1F5(Win + M)的WM_HOTKEY消息
pWnd->SendMessage(WM_HOTKEY, 0x1F5);


你可能感兴趣的:(获得窗体指针的办法FromHandle,WindowFromPoint)