Board index » cppbuilder » I need to draw onto all the controls of a form

I need to draw onto all the controls of a form

I'm tryng to draw on a form that contain some panels :
      Form->Canvas->MoveTo(strX, strY);
      Form->Canvas->LineTo(actX, actY);

In this way the lines drawed are below the panels.

How i can draw onto all the controls of my form ?
How i can save the region under the line to restore the screen ?

Thanks in advance.

 

Re:I need to draw onto all the controls of a form


Hi Paolo,

Quote
> I'm tryng to draw on a form that contain some panels :
> How i can draw onto all the controls of my form ?
> How i can save the region under the line to restore the screen ?

The only way to draw on top of other windowed controls is to either draw to a
transparent window that lies on top of the other windowed controls, or to draw
to the screen's device context.  Here's a simple example of the latter...

    HDC Hdc = GetDC(0);
    HPEN HPen = CreatePen(PS_SOLID, 5, RGB(0, 0, 255));
    HPEN HOldPen = SelectObject(Hdc, HPen);
    try
    {
        RECT RBounds = static_cast<RECT>(BoundsRect);
        HRGN HClipRgn = CreateRectRgnIndirect(&RBounds);
        SelectClipRgn(Hdc, HClipRgn);
        DeleteObject(HClipRgn);

        MoveToEx(Hdc, RBounds.left, RBounds.top, NULL);
        LineTo(Hdc, RBounds.right, RBounds.bottom);
    }
    catch (...)
    {
        DeleteObject(SelectObject(Hdc, HOldPen));
        ReleaseDC(0, Hdc);
    }
    DeleteObject(SelectObject(Hdc, HOldPen));    
    ReleaseDC(0, Hdc);  

HTH.

--
Damon Chandler
http://bcbcaq.freeservers.com

Other Threads