I'm no expert, but I have used Bitblt. I still get confused with the Picture stuff, but my
Image->Image copy used Image1.Picture.BitMap.Canvas.Handle.
Otherwise maybe you could use Form.Canvas.Handle.
Otherwise (!) maybe you must have a TImage on the Form
HTH
Ray Cramer
R...@Pol.ac.uk
I believe form.handle is a handle to a window; form.canvas.handle is a
handle to a device context, which is most likely what you want.
Tom
BitBlt( Form.Handle, 0,0, 100,100,Image1.Picture.BitMap.Handle, 0,0, scrCOPY)
But, there was not result in my FORM at Run-time.
Clanget.
If the form is an MDI Parent form, you will never see a result.
You need the handle for the MDI Client area to paint on it.
If the form is NOT an MDI parent form then use the Delphi
bitmap functions and use the canvas of the form (search under
Canvas in the help, look for copying bitmaps)
To solve the problem with your code fragment, you need to use
Form1.Canvas.Handle. Form1.Handle is the windows handle to the
form. Form1.Canvas.Handle is a Device Context handle.
You need to use a HDC not a THANDLE included is the help text for
GetDeviceContext and the WinAPI for BitBlt.
GetDeviceContext Method
Unit
Controls
Applies to TControl, TWinControl
Declaration
function GetDeviceContext(var WindowHandle: HWnd): HDC; virtual;
Description
The GetDeviceContext method returns a device context for the
control represented by the window handle passed in the
WindowHandle parameter. TControl implements GetDeviceContext
by returning the device context returned from its parent control's
GetDeviceContext. TWinControl overrides GetDeviceContext to call
the Windows API function GetDC, passing the windowed control's
Handle property and setting WindowHandle to Handle.
Windows API BitBlt
BitBlt (2.x) (WINPROCS unit)
function BitBlt(DestDC: HDC; X, Y, nWidth, Height: Integer; SrcDC: HDC;
XSrc, YSrc: Integer; Rop: LongInt): Bool;
The BitBlt function copies a bitmap from a specified device
context to a destination device context.
So off the top of my head (It may be wrong don't flame me) here is what
I would do to start coding this.
Var
MyDC:HDC;
BitIt:Boolean;
Devcaps:Integer;
Begin
MyDC:=GetDeviceContext(Form1.Handle);
DevCaps:=GetDeviceCaps(MyDC,RASTERCAPS); {Read WINAPI may need
more work?}
BitIt:=BitBlt(MyDC,10,10, 100, 10,DcToCopyFrom,10,10,MERGECOPY)
MyDC.Free;
End;
Not all devices support the BitBlt function. An application can
determine whether a device supports BitBlt by calling the
GetDeviceCaps function and specifying the RASTERCAPS
index.
Hope this helps I have not tested it but it is a start
Huet Bartels