我知道用CWindowDC类的话 可以用CWindowDC(GetDesktopWindow);直接初始化\ 如果用CDC的话~~怎么赋值 能在桌面绘图~ ------------------------------- HDC hDC = ::GetDC(NULL);// 可以直接操纵hDC CDC dc; // 在屏幕中绘制 dc.Attach(hDC); dc.SetBkMode(TRANSPARENT); dc.SetTextColor(RGB(255,0,0)); CRect rect; GetWindowRect(&rect); //ScreenToClient(&rect); ClientToScreen(&rect); dc.TextOut(rect.top,rect.left,"sdf"); //dc.Detach(); //ReleaseDC(&dc); --------------------- 客户端的 DC CClientDC dc(this);// CClientDC 是CDC 的子类,在CClientDC 在构造时调用了Windows函数GetDC,在析构时调用了ReleaseDC dc.SetBkMode(TRANSPARENT); dc.SetTextColor(RGB(255,0,0)); CRect rect; GetWindowRect(&rect); //ScreenToClient(&rect); // ClientToScreen(&rect); // dc.TextOut(rect.top,rect.left,"sdf"); dc.TextOut(0,0,"sdf"); |
|