Drag and drop image resources

Post Reply
User avatar
Adolfo
Posts: 815
Joined: Tue Oct 11, 2005 11:57 am
Location: Chile
Contact:

Drag and drop image resources

Post by Adolfo »

Hi everybody

I need to drag and drop and image on an IMAGE resource, then replace a mysql blob field with the "new" image.

Found something in the forum, but it does not work

Code: Select all

REDEFINE IMAGE oImage FILE "nula.jpg"      ID 101 OF oFldTra:aDialogs[ 4 ] UPDATE


      oImage:bDropFiles := { |r,c,aFiles| ;
      If( Lower( cFileExt( aFiles[ 1 ] ) ) $ "jpg,jpeg", ;
         ( oImage:LoadImage( nil, aFiles[ 1 ] ), oImage:Refresh() ), ;
         MsgInfo( "No es un archivo de imagen permitido", aFiles[ 1 ] ) ) }

   .......
  ACTIVATE DIALOG odlgTrabaja CENTERED ON INIT DragAcceptFiles( oImage:hWnd, .T. )
 
I can drop the file into the image, but it doesn't update

Any help will be appreciated.

Fom Chile
Adolfo
;-) Ji,ji,ji... buena la cosa... "all you need is code"

http://www.xdata.cl - Desarrollo Inteligente
----------
Lenovo Legion Y520, 16GB Ram, 1 TB NVME M.2, 1 TB SSD, GTX 1050
User avatar
cdmmaui
Posts: 653
Joined: Fri Oct 28, 2005 9:53 am
Location: The Woodlands - Dallas - Scottsdale - London
Contact:

Re: Drag and drop image resources

Post by cdmmaui »

Hello Adolfo,

We are looking for the same solution. Our customer would like to be able to Drag and Drop images, documents and/or e-mails to a specific record.

Dear Antonio and Rao, is this possible?
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Drag and drop image resources

Post by nageswaragunupudi »

This is a small sample program that demonstrates one way to import image data from external sources and save in a blob field of a table.

The table with images is displayed in XBrowse.

1) Drag and Drop: Any image file can be dragged and dropped on the required row of XBrowse. The image data read from the file is saved to the blob field.

2) Copy and Paste:
(a) Copy any image file in the file explorer and paste in the required cell of xbrowse.
(b) Copy any open image from an Internet browser or from any other source like word and paste in the cell.

Code: Select all

#include "fivewin.ch"

function Main()

   local oCn, oRs, oDlg, oBar, oFont, oBrw

   oCn   := FW_DemoDB()
   oRs   := oCn:wwonder2

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14

   DEFINE DIALOG oDlg SIZE 600,350 PIXEL TRUEPIXEL FONT oFont RESIZABLE

   @ 40,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oRs ;
         COLUMNS "NAME", "IMAGE" ;
         LINES NOBORDER

   WITH OBJECT oBrw
      :nEditTypes    := EDIT_GET
      :lCanPaste     := .t.
      :Image:nDataBmpAlign  := AL_CENTER
      :bDropFiles    := { |r,c,aFiles| oBrw:SetPos( r, , .t. ), ;
                          oBrw:Image:VarPut( MemoRead( aFiles[ 1 ] ) ) }
      //
      :CreateFromCode()
   END

   @ 02,20 BTNBMP PROMPT "PASTE" SIZE 76,36 PIXEL OF oDlg FLAT ;
     ACTION ( oBrw:GoToCol( "image" ), oBrw:Paste() )


   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT DragAcceptFiles( oBrw:hWnd, .t. )

   RELEASE FONT oFont

   oCn:Close()

return nil
 
FW MariaRowSet is used in the sample. But the same sample works the same way with DBF, Array, ADO RecordSet or Dolphin/MySql Query, by simply replacing "oRs" after DATASOURCE with Alias(), array, RecordSet or oQry, as the case may be. We used the fields "NAME" and "IMAGE" in the above example. You may replace with the field names in your table where necessary.

Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
cdmmaui
Posts: 653
Joined: Fri Oct 28, 2005 9:53 am
Location: The Woodlands - Dallas - Scottsdale - London
Contact:

Re: Drag and drop image resources

Post by cdmmaui »

Dear Rao,

Awesome! Thank you!

Would this work the same if I wanted to attach other document types such as PDF, Word, XLS, Email message, etc.?

Also, I would need to be able to add multiple documents to a single record and NOT overwrite the existing data.

Thanks again for your help!!!
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Drag and drop image resources

Post by nageswaragunupudi »

In principle, Yes.

Depending on how we want to store the dropped files or their contents in the target database, we need to provide suitable code for the bDropFiles codeblock or handle the paste object.
Regards

G. N. Rao.
Hyderabad, India
Post Reply