Project source
Form source (Pascal)
Form source (DFM)
| Project source: DragJPEGTest.dpr |
program DragJPEGTest;
{Test application for UnitOOPS OLE Drag and Drop Components}
uses
Forms,
fmDragJPEGTest in 'fmDragJPEGTest.pas' {Form1};
{$R *.RES}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
Back to top
|
| Form source: fmDragJPEGTest.pas |
unit fmDragJPEGTest;
{ Form for example of dragging JPEG images to other applications by
converting them on-the-fly to bitmaps.
Last modified: 11/11/99
}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
uoole, jpeg, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
UOGraphicSource1: TUOGraphicSource;
Panel1: TPanel;
Image1: TImage;
Label1: TLabel;
procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses
uoUtil;
{$R *.DFM}
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
aBmp: TBitmap;
begin
// Detect a drag with any button
if uoDragDetect(Panel1.Handle, POINT(X,Y), Button) then
begin
// Tell the graphic source which button we got.
UOGraphicSource1.MouseButton := Button;
// Make a temporary bitmap
aBMP := TBitmap.create;
try
// Assign the (JPEG) graphic to the bitmap, which converts the
// JPEG to a bitmap.
aBmp.Assign(Image1.Picture.Graphic);
// Now, we have a bitmap, so assign it to the graphic source's picture
UOGraphicSource1.Picture.Graphic := aBmp;
// Now do the drag!
UOGraphicSource1.Execute;
// In case we made a big bitmap, let it go. Otherwise, it will live
// on unnecessarily in the Picture property of the TUOGraphicSource.
UOGraphicSource1.Picture := nil;
finally
// Clean up.
aBmp.Free;
end;
end;
end;
end.
Back to top
|
| Form source: fmDragJPEGTest.dfm |
object Form1: TForm1
Left = 390
Top = 273
Width = 203
Height = 239
Caption = 'Dragging a JPEG image'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 8
Top = 8
Width = 177
Height = 13
Caption = 'Drag the image to another application'
end
object Panel1: TPanel
Left = 19
Top = 32
Width = 152
Height = 165
AutoSize = True
Caption = 'Panel1'
TabOrder = 0
object Image1: TImage
Left = 1
Top = 1
Width = 150
Height = 163
AutoSize = True
Picture.Data = {
0A544A504547496D6167652C170000FFD8FFE000104A46494600010101012C01
2C0000FFDB004300080606070605080707070909080A0C140D0C0B0B0C191213
0F141D1A1F1E1D1A1C1C20242E2720222C231C1C2837292C30313434341F2739
3D38323C2E333432FFDB0043010909090C0B0C180D0D1832211C213232323232
3232323232323232323232323232323232323232323232323232323232323232
32323232323232323232323232FFC000110800A3009603012200021101031101
...omitted for brevity...
E48CE33D09C0EB50A6A1729A6472AC803B5C3213B4723D3A51455C92D0CDB65C
D5577832B33F980AE1B7904647D6B396572910273FBE039EA7E5F5A28A6BE145
37A8EB3BA9D64954484020023DA92E66961589E391958B6E383DF8A28A22B563
67476CC65B2844877ED2A06EE48CE3FC4D529AD20B8919E48C16566231C77F6A
28ACE9EE69D07DB4117DACAEC054A9054F23AFA54915D4C9A9496EAF88776CD9
818C1CF18FC28A294B707B15246CCC4100FB9009A28A2A908FFFD9}
OnMouseDown = Image1MouseDown
end
end
object UOGraphicSource1: TUOGraphicSource
DropEffects = [deCopy]
MouseButton = mbLeft
Left = 128
Top = 136
end
end
Back to top
|