Subject RE: [IBO] IB_JPegImage - Dragging Image from Win explorer and dropping on IB_JPegImage
Author Adrian Wreyford
I decided to check for the dataset state, then force it to Insert, if it is
browse during the drag-drop, and to respect the edit or insert states if
allready in that.



I changed as follows:



procedure TIB_JPEGImage.WMDROPFILES(var Msg: TMessage);

function CompareFileExtension( FileName: PChar; Extension: string ):
boolean;

begin

Result := UpperCase(ExtractFileExt(StrPas(FileName))) = Extension;

end;

var

fileCount: integer;

fileName: pchar;

size: integer;

begin

fileName := '';

fileCount := DragQueryFile( Msg.WParam, $FFFFFFFF, fileName, 255 );

if fileCount = 1 then

begin

size := DragQueryFile( Msg.WParam, 0, nil, 0 ) + 1;

fileName := StrAlloc( size );

DragQueryFile(Msg.WParam, 0, fileName, size);

try

if CompareFileExtension( fileName, '.JPG' ) or

CompareFileExtension( fileName, '.JPEG' ) or

CompareFileExtension( fileName, '.WMF' ) or

CompareFileExtension( fileName, '.BMP' ) or

CompareFileExtension( fileName, '.ICO' ) then

Begin

{New code lines added here}

If DataLink.DataSet.State = dssBrowse then

DataLink.Dataset.Insert;

{End New Code Lines}

Picture.LoadFromFile( StrPas( fileName ))

end

else

raise Exception.Create( E_Graphic_Format_Not_Supported );

finally

StrDispose( fileName );

end;

DragFinish( Msg.WParam );

end

else

raise Exception.Create( E_Only_one_file_allowed );

end;



Any comments?



Regards



Adrian



[Non-text portions of this message have been removed]