Do you have any good idea, show it to create other controls? Or, other controls will you draw?
Take over TPanel WndProc with the following code from the picture.
WndProc (Msg);
If (Msg, Msg==WM_PAINT)
{
TControlCanvas * PanelCanvas=new TControlCanvas ();
Try
{
PanelCanvas - & gt; The Control=this;
Int iSaveIndex;
TPoint Position;
ISaveIndex=SaveDC (PanelCanvas - & gt; Handle);
GetViewportOrgEx (PanelCanvas - & gt; Handle, & amp; The Position);
SetViewportOrgEx (PanelCanvas - & gt; The Handle, the Position x - this - & gt; Left, the Position. The y - this - & gt; Top, NULL);
IntersectClipRect (PanelCanvas - & gt; Handle, 0, 0, this - & gt; The Parent - & gt; ClientWidth,
This - & gt; The Parent - & gt; ClientHeight);
This - & gt; The Parent - & gt; Perform (WM_ERASEBKGND, (int) PanelCanvas - & gt; Handle, 0);
This - & gt; The Parent - & gt; Perform (WM_PAINT, (int) PanelCanvas - & gt; Handle, 0);
RestoreDC (PanelCanvas - & gt; Handle, iSaveIndex);
PanelCanvas - & gt; Brush - & gt; Color=clRed;
PanelCanvas - & gt; Pen - & gt; Width=1;
PanelCanvas - & gt; FrameRect (TRect (0, 0, this - & gt; Width - 1, this - & gt; Height - 1));
}
__finally
{
The delete PanelCanvas;
}
}