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