Subject RE: [IBO] IB_JPegImage - Dragging Image from Win explorer and dropping on IB_JPegImage
Author Adrian Wreyford
OK .. I played with the code of the actual component, and they have a drop
handler for External controls:



I modified the code to place the dataset into insert mode, and this works
for me.

Wouldn't this be the preferred reaction?

Perhaps a property can be added to "improve" the component, ie DROPMODE -
dmInsert, dmEdit, that can be set to change the way the drop is handled by
the IB_JpegImage.



Here follows the code without the above property change:

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 line added here - this can be under the control of the
property suggested above?}

DataLink.Dataset.Insert;

{End New Code Line}

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;



Your comments will be welcomed



Regards



Adrian Wreyford

_____

From: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com] On Behalf
Of Adrian Wreyford
Sent: 17 December 2007 08:53 AM
To: IBObjects@yahoogroups.com
Subject: [IBO] IB_JPegImage - Dragging Image from Win explorer and dropping
on IB_JPegImage



Hallo those of you unfortunate not to be on annual leave.

I never realised this, but I you have an IB_JPegimage on a form, and
connected to a IB_Query, with a IB_NavigationBar and IB_UpdateBar.

The following can happen:

In image viewed in WinExplorer, can be dragged and dropped on the
IB_JpegImage, putting it in edit state, and the new image is displayed.

The DragDrop Icon is also displayed correctly.

Under this scenario, the OnDragOver, OnDragDrop, OnDragEnd events of the
IB_JpegImage are NOT fired, thus I have now way to disallow or manipulate
this action.

They are only fired, when dragging from one IB_JpegImage to another, and
then I can control nicely.

This wouldn't have been a problem in my situation, if the dataset was placed
in insert mode, but unfortunately it is placed in Edit mode, and if the user
then posts the change, the image overwrites a previously stored image, and
does not add a new one as the perception could come across.

I need to somehow detect that an Image is being dropped .. ie. check that it
is a suitable, JPeg image.

Then place the dataset in insert mode, and then based on the users reaction
with the IB_UpdateBar, post or cancel change.

Any pointers will be appreciated.

Regards

Adrian Wreyford



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