Drag and drop image resources

Drag and drop image resources

Postby Adolfo » Tue Aug 14, 2018 2:53 pm

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  Expand view
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
----------
Asus TUF F15, 32GB Ram, 1 TB NVME M.2, 1 TB SSD, GTX 1650
User avatar
Adolfo
 
Posts: 846
Joined: Tue Oct 11, 2005 11:57 am
Location: Chile

Re: Drag and drop image resources

Postby cdmmaui » Tue Aug 14, 2018 7:19 pm

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
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: Drag and drop image resources

Postby nageswaragunupudi » Wed Aug 15, 2018 1:28 pm

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  Expand view

#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
nageswaragunupudi
 
Posts: 10308
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Drag and drop image resources

Postby cdmmaui » Wed Aug 15, 2018 2:03 pm

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
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: Drag and drop image resources

Postby nageswaragunupudi » Wed Aug 15, 2018 2:10 pm

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
User avatar
nageswaragunupudi
 
Posts: 10308
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 25 guests