FWH 2304 : Dropping text/images from Web and External App

FWH 2304 : Dropping text/images from Web and External App

Postby nageswaragunupudi » Wed May 03, 2023 2:10 am

It is possible to drop images and text from Web pages
fwh\samples\imgdrop.prg
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oWnd, oBar, oBtn, cDrop := ""
   local lWeb  := .t.

   cDrop := "DROP HERE"

   DEFINE WINDOW oWnd TITLE "Drag&Drop me an Image"
   DEFINE BUTTONBAR oBar OF oWnd SIZE 120,48 //2007

   DEFINE BUTTON oBtn OF oBar PROMPT "Drop From ExternalApp" ;
      FILE "..\bitmaps\32x32\no.bmp","..\bitmaps\32x32\yes.bmp" LEFT ;
      ACTION If( lWeb, nil, ( oWnd:RegisterDragDrop(), lWeb := .t., oBar:Refresh() ) )
   oBtn:bBmpNo := { || If( lWeb, 2, 1 ) }

   DEFINE BUTTON oBtn OF oBar PROMPT "Drop From FileExplorer" ;
      FILE "..\bitmaps\32x32\no.bmp","..\bitmaps\32x32\yes.bmp" LEFT ;
      ACTION If( lWeb, ( oWnd:RevokeDragDrop(), lWeb := .f., oBar:Refresh() ), nil )
   oBtn:bBmpNo := { || If( lWeb, 1, 2 ) }

   oWnd:RegisterDragDrop()
   oWnd:bPainted := { |hDC,p,o| ShowDrop( hDC, o, cDrop ) }

   ACTIVATE WINDOW oWnd ;
      ON DROPFILES ( cDrop := aFiles[ 1 ], oWnd:Refresh() )

return nil

static function ShowDrop( hDC, oWnd, cDrop )

   local cExt
   local aRect    := oWnd:GetCliAreaRect():aRect

   if IsImageExt( cDrop )
      oWnd:DrawImage( cDrop, aRect )
   else
      oWnd:SayText( WrapToWidth( hDC, cDrop, aRect[ 4 ] - aRect[ 2 ], oWnd:oFont ), ;
                    aRect )
   endif

return nil


Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10643
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 87 guests