im working on an application using delphi 6, where im trying to integrate camera into the existing application, the camera code displays the captured frames onto a Tpanel, in my application i need to display the captured frame on Tpaintbox ( i am not the original coder),
this is a code sample from the
procedure TFrameThreadX.DrawFrame;
var
hdc:THandle;
begin
//do processing
.
.
hdc := GetDC( ViewForm.ViewPanel.Handle );
SetStretchBltMode(hdc,COLORONCOLOR);
StretchDIBits(hdc,0,0,nW,nH,0,0,ScW,ScH,DibPixels,TBitMapInfo((@FDib)^),DIB_RGB_COLORS,SRCCOPY);
ReleaseDC( ViewForm.ViewPanel.Handle, hdc );
//do processing
end;
here is get the Tpanel handle as 87248682 from this
hdc := GetDC( ViewForm.ViewPanel.Handle );
so when i try to use Tpaintbox in the code like this
hdc := GetDC( ViewForm.PaintBox1.Canvas.Handle);
The result is 0,
so the camera frames are not displayed..
so i tried this
using the GetDC and GetWindowDC but in both the cases the result of the functions is 0 for the handle,

my code
var
hdc : THandle;
begin
hdc := GetDC(Panel1.Handle);
Label1.Caption:=inttostr(hdc);
hdc := GetDC(Image1.Canvas.Handle);
Label2.Caption:=inttostr(hdc);
hdc := GetDC(PaintBox1.Canvas.Handle);
Label3.Caption:=inttostr(hdc);
end;
And for GetWindowDC
var
hdc : THandle;
begin
hdc := GetWindowDC(Panel1.Handle);
Label4.Caption:=inttostr(hdc);
hdc := GetWindowDC(Image1.Canvas.Handle);
Label5.Caption:=inttostr(hdc);
hdc := GetWindowDC(PaintBox1.Canvas.Handle);
Label6.Caption:=inttostr(hdc);
end;
So please tell me how to get the Tpaint handle?
Canvas.Handle is the DC handle you're looking for, so HDC := PaintBox1.Canvas.Handle
TPaintBox and TImage are TGraphicControl descendants and have no handle (they receive handle when they process WMPaint message). TPanel is TWinControl descendant and has a handle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With