先用HDC hdc;
hdc=GetDC(hwnd);
MoveTo(hdc,x1,y1,NULL);
LineTo(hdc,x2,y2);
DeleteDC(hwnd,dc);

解决方案 »

  1.   

    先用HDC hdc;
    然后使用GetWindowDC()
    可以对窗体所有位置操作,包括非客户区
      

  2.   

    CWnd::UpdateWindow()//没有这个就会闪烁
    CClientDC::CClientDC(CWnd*)
    CDC::BltBit()
      

  3.   

    CWnd::UpdateWindow()//没有这个就会闪烁
    CDC::BltBit()
      

  4.   

    直接用picture控件就可以,不过要调整一下,使高度为0
    ok?
      

  5.   

    显示图片用picture控件也可以呀
      

  6.   

    CBitmap bmp; // define in your dialog classOnPaint()
    {
    CPaintDC dc(this);
    ...// add this code to your project
    bmp.LoadBitmap(IDB_TEST); // IDB_TEST is your import or created pic
    BITMAP bm;
    bmp.GetBitmap(&bm);
    CDC dcMem;
    dcMem.CreateCompatibleDC(&dc);
    dcMem.SelectObject(&bmp);
    // set x and y yourself
    dc.BitBlt(x, y, bm.bmWidth, bm.bmHeight, &dcMem, 0, 0, SRCCOPY);
    dcMem.DeleteDC();
    }