如何获取桌面最上层的窗口?vc windows编程
想要获取在桌面最上层的窗口,然后在上面贴图,请问高手如何实现?补充问一下,贴上去的图,真么能删掉,想实现动画的效果!...
想要获取在桌面最上层的窗口,然后在上面贴图,请问高手如何实现?
补充问一下,贴上去的图,真么能删掉,想实现动画的效果! 展开
补充问一下,贴上去的图,真么能删掉,想实现动画的效果! 展开
1个回答
展开全部
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc,hd;
RECT rc;
TCHAR tx[]=L"Hello,VS2005.";
HWND hw;
switch (message)
{
case WM_COMMAND:
break;
case WM_CREATE:
SetTimer(hWnd,1,1000,NULL);
break;
case WM_TIMER:
hw=GetForegroundWindow();
if(hw)
{
hd=GetDC(hw);
TextOut(hd,10,10,tx,_tcslen(tx));
ReleaseDC(hw,hd);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
KillTimer(hWnd,1);
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
//GetForegroundWindow有时不灵光
//仅仅尝试了下TextOut,有了DC,画图其实一样。
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc,hd;
RECT rc;
TCHAR tx[]=L"Hello,VS2005.";
HWND hw;
switch (message)
{
case WM_COMMAND:
break;
case WM_CREATE:
SetTimer(hWnd,1,1000,NULL);
break;
case WM_TIMER:
hw=GetForegroundWindow();
if(hw)
{
hd=GetDC(hw);
TextOut(hd,10,10,tx,_tcslen(tx));
ReleaseDC(hw,hd);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
KillTimer(hWnd,1);
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
//GetForegroundWindow有时不灵光
//仅仅尝试了下TextOut,有了DC,画图其实一样。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询