Pre*_*ias 2 delphi winapi handle
我正在使用delphi 6处理应用程序,我试图将相机集成到现有应用程序中,相机代码将捕获的帧显示到Tpanel上,在我的应用程序中我需要在Tpaintbox上显示捕获的帧(我不是原始编码器)
这是来自的代码示例
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;
Run Code Online (Sandbox Code Playgroud)
这里是得到Tpanel手柄为87248682的这
hdc := GetDC( ViewForm.ViewPanel.Handle );
Run Code Online (Sandbox Code Playgroud)
所以当我尝试在这样的代码中使用Tpaintbox时
hdc := GetDC( ViewForm.PaintBox1.Canvas.Handle);
Run Code Online (Sandbox Code Playgroud)
结果是0,
所以相机框架不显示..
所以我试过这个
使用GetDC和GetWindowDC,但在这两种情况下,句柄的函数结果为0,

我的代码
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;
Run Code Online (Sandbox Code Playgroud)
对于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;
Run Code Online (Sandbox Code Playgroud)
那么请告诉我如何获得Tpaint手柄?
| 归档时间: |
|
| 查看次数: |
3173 次 |
| 最近记录: |