user-0 提问: 请教下如何用VC编一个可以在全屏幕内画图的程序？

回复:
user: user-1
content: MFC有划线的功能，可以做成类似qq截图功能的绘画

user: user-2
content: GetWindowDC(NULL)  hWnd  [in] Handle to the window with a device context that is to be retrieved. If this value is NULL, GetWindowDC retrieves the device context for the entire screen.   使用这样获取到的DC就可以在整个屏幕上绘制你想绘制的东西了.

user: user-3
content: LineTo The LineTo function draws a line from the current position up to, but not including, the specified point.   BOOL LineTo(   HDC hdc,    // device context handle   int nXEnd,  // x-coordinate of line's ending point   int nYEnd   // y-coordinate of line's ending point );   Parameters hdc  Handle to a device context.  nXEnd  Specifies the x-coordinate of the line's ending point.  nYEnd  Specifies the y-coordinate of the line's ending point.  Return Values If the function succeeds, the return value is nonzero.  If the function fails, the return value is zero.   Windows NT: To get extended error information, callGetLastError.  Remarks The coordinates of the line's ending point are specified in logical units.   The line is drawn by using the current pen and, if the pen is a geometric pen, the current brush.   If LineTo succeeds, the current position is set to the specified ending point.   QuickInfo   Windows NT: Requires version 3.1 or later.   Windows: Requires Windows 95 or later.   Windows CE: Unsupported.   Header: Declared in wingdi.h.   Import Library: Use gdi32.lib.  See Also Lines and Curves Overview, Line and Curve Functions, MoveToEx, Polyline, PolylineTo

user: user-3
content: #include <windows.h> LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {     PAINTSTRUCT ps;     HDC hdc;     HFONT hfont,ohfont;     RECT r;     COLORREF oc;      switch(message) {     case WM_CLOSE://按Alt+F4退出         PostQuitMessage(0);         break;     case WM_PAINT:         BeginPaint(hWnd, &ps);         hdc = ps.hdc; // the device context to draw in         GetClientRect(hWnd, &r); // Obtain the window's client rectangle         hfont = CreateFont(240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "华文楷体");         ohfont=SelectObject(hdc,hfont);         oc=SetTextColor(hdc,0x00C080FF);         SetBkMode(hdc, TRANSPARENT);         TextOut(hdc,r.left+r.right/2-720, r.top+r.bottom/2-120,"最短画图程序",12);         SelectObject(hdc,ohfont);         SetTextColor(hdc,oc);         DeleteObject(hfont);         EndPaint(hWnd, &ps);         break;     default:         return DefWindowProc(hWnd, message, wParam, lParam);     }     return 0; } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {     MSG msg             = {0};     WNDCLASS wc         = {0};     HBRUSH hbrh;     hbrh=CreateSolidBrush(0x00000000);     wc.lpfnWndProc      = WndProc;     wc.hInstance        = hInstance;     wc.hbrBackground    = hbrh;     wc.lpszClassName    = "minwindowsapp";     wc.hCursor          = LoadCursor(NULL,IDC_ARROW);     if( FAILED(RegisterClass(&wc)) ) return 1;      if(FAILED(CreateWindow(wc.lpszClassName,                         "Minimal Windows Application",                         WS_POPUP|WS_VISIBLE,                         0,                         0,                         GetSystemMetrics(SM_CXSCREEN),                         GetSystemMetrics(SM_CYSCREEN),                         0,                         0,                         hInstance,                         NULL)))         return 2;      while( GetMessage( &msg, NULL, 0, 0 ) > 0 ) {         DispatchMessage( &msg );     }     DeleteObject(hbrh);     return 0; }