Т.е. процедура doDraw будет выглядеть так:
#pas
procedure THIImg_Line._work_doDraw;
var dc:HDC; c:integer; hp:HPEN;
begin
dc := imgGetDC(_Data);
ReadXY(_Data);
c := ReadInteger(_Data,_data_Color,_prop_Color);
hp := CreatePen(0,ReadInteger(_Data,_data_Size,_prop_Size),c);
SelectObject(DC,hp);
MoveToEx(DC,x1,y1,nil);
LineTo(DC,x2,y2);
DeleteObject(hp);
imgReleaseDC(dc);
_hi_CreateEvent(_Data,@_event_onDraw,dt);
end;
function THIImg.imgGetDC(var _Data:TData):HDC;
begin
case _prop_DrawSource of
Handle: begin
wnd := ReadInteger(_Data,_data_Bitmap,0);
Result := GetDC(wnd);
end;
Bitmap: begin
bmp := ReadBitmap(_Data,_data_Bitmap,nil);
Result := bmp.Canvas.Handle;
end;
Context:
Result := ReadInteger(_Data,_data_Bitmap,0);
end;
end;
procedure THIImg.imgReleaseDC(dc:HDC);
begin
case _prop_DrawSource of
Handle:
ReleaseDC(wnd, dc);
end;
end;