创建canvas后,需要给canvas.handle赋值,下面代码演示了如何操作:
var
R: TRect;
DC: HDC;
Canvas: TCanvas;
begin
R:= ClientRect;
DC:= GetDC(Handle);
Canvas:= TCanvas.create;
Canvas.Handle:= DC;
Try
DrawEdge(Canvas.Handle, R, BDR_SUNKENOUTER, BF_LEFT or BF_TOP or BF_RIGHT or BF_BOTTOM or BF_ADJUST);
DrawEdge(Canvas.Handle, R, BDR_SUNKENINNER, BF_LEFT or BF_TOP or BF_RIGHT or BF_BOTTOM or BF_FLAT);
finally
ReleaseDC(Handle, DC);
Canvas.Free;
end;
end;