Using Win32 functions in Visual FoxPro Image Gallery
Window Class
..msdn
GetClassInfo
GetClassInfoEx
GetClassLong
GetClassName
GetWindowLong
RegisterClassEx
SetWindowLong
UnregisterClass
Code examples:
Adding user-defined items to the Control Menu of VFP form (requires VFP9)
Browsing Windows Known Folders (Special Folders)
Capturing keyboard activity of another application with the Raw Input API (VFP9)
Creating irregularly shaped FoxPro form using transparency color key
Customizing the frame of top-level form: removing the standard frame (VFP9, Vista)
Detecting changes in connections to removable drives (VFP9)
Displaying dimmed window behind VFP top-level form
Displaying hypertext links with the SysLink control (VFP9, Comctl32.dll)
Displaying icons in the system tray (VFP9)
Displaying the associated icons and descriptions for files and folders
Dragging files from Explorer window and dropping them on FoxPro control (requires VFP9)
Extended MessageBox Class
How to block the PrintScreen key
How to disable the Windows Clipboard (VFP9)
How to hot-track menu item selection in top-level form (requires VFP9)
How to make a VFP form fading out when released (GDI version)
How to make a VFP form fading out when released (GDI+ version)
How to view icons stored in executable files (Icon Viewer) - II
Locking the workstation
Placing a button on the VFP form as a new child window
Retrieving information about the main VFP window
Semi-transparent Form
Setting properties of the window: caption and user-defined value
Switching between keyboard layouts
System Image List Viewer
Transparent Menu Class (requires VFP9)
Using Common Controls: the Header Control
Using FoxTray ActiveX control: System Tray Icon and menu attached to VFP form
Using Month Calendar Control (VFP9, Comctl32.dll)
Using WM_COPYDATA for interprocess communication (VFP9)
Windows Shell Icons displayed and exported to ICO files (Vista)
Dragging files from Explorer window and dropping them on FoxPro control (requires VFP9)

User rating: 7/10 (1 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Before you begin:
 
LOCAL oForm As TForm
oForm = CREATEOBJECT("TForm")
oForm.Visible=.T.
READ EVENTS
* end of main
 
DEFINE CLASS TForm As Form
#DEFINE WM_DROPFILES 0x0233
#DEFINE GWL_WNDPROC -4
#DEFINE MAX_PATH 260
 
PROTECTED hWindow, hOrigProc
    hWindow=0
    hOrigProc=0
    Width=350
    Height=200
    MinButton=.F.
    MaxButton=.F.
    Caption=" Dropping files on the form"
    ShowWindow=2
    Autocenter=.T.
 
    ADD OBJECT ch As CheckBox WITH;
    Left=10, Top=10, Autosize=.T., BackStyle=0,;
    Caption="Accept dropped files", Value=0
 
    ADD OBJECT lst As ListBox WITH;
    Left=5, Top=40, Width=340, Height=130
 
    ADD OBJECT lbl As Label WITH;
    Left=10, Top=176, Autosize=.T., BackStyle=0,;
    Caption="Drag files from an Explorer window and drop on the listbox"
 
PROCEDURE Init
    THIS.declare
 
PROCEDURE Destroy
    THIS.ReleaseAccept
    CLEAR EVENTS
 
PROCEDURE ch.InteractiveChange
    IF THIS.Value = 1
        ThisForm.SetAccept
    ELSE
        ThisForm.ReleaseAccept
    ENDIF
 
PROCEDURE SetAccept
    THIS.hWindow = GetFocus()
    THIS.hOrigProc = GetWindowLong(THIS.hWindow, GWL_WNDPROC)
 
    IF VERSION(5) >= 900
        = BINDEVENT(THIS.hWindow, WM_DROPFILES,;
            THIS, "OnFilesDropped")
    ENDIF
    = DragAcceptFiles(THIS.hWindow, 1)
 
PROCEDURE ReleaseAccept
    = UNBINDEVENTS(THIS)
 
    IF THIS.hWindow <> 0
        = DragAcceptFiles(THIS.hWindow, 0)
        THIS.hWindow=0
    ENDIF
 
PROCEDURE OnFilesDropped(hWindow as Integer,;
    nMsgID as Integer, wParam as Integer, lParam as Integer)
* requires VFP9, otherwise ignored
* note that input parameters are predefined and should not be changed
* see WindowProc function for details
 
    LOCAL nReturn
    nReturn=0
 
    DO CASE
    CASE nMsgID=WM_DROPFILES
        THIS.ProcessDroppedFiles(wParam)
 
    OTHERWISE
    * pass control to the original window procedure
        nReturn = CallWindowProc(THIS.hOrigProc, THIS.hWindow,;
            m.nMsgID, m.wParam, m.lParam)
    ENDCASE
RETURN nReturn
 
PROTECTED PROCEDURE ProcessDroppedFiles(hDrop)
    LOCAL cPoint, nX, nY
    cPoint = REPLICATE(CHR(0),8)  && POINT buffer
    = DragQueryPoint(hDrop, @cPoint)
    nX = buf2dword(SUBSTR(cPoint,1,4))
    nY = buf2dword(SUBSTR(cPoint,5,4))
 
    * only if clicked inside the listbox
    WITH THIS.lst
        IF NOT (BETWEEN(nX, .Left, .Left+.Width-1);
            AND BETWEEN(nY, .Top, .Top+.Height-1))
            RETURN
            = DragFinish(hDrop)
        ENDIF
    ENDWITH
 
    THIS.lst.Clear
 
    LOCAL nFilecount, nIndex, cBuffer, nLength
    nFilecount = DragQueryFile(hDrop, 0xFFFFFFFF, Null, 0)
 
    FOR nIndex=0 TO nFilecount-1
        cBuffer = REPLICATE(CHR(0), MAX_PATH)
        nLength = DragQueryFile(hDrop, nIndex, @cBuffer, MAX_PATH)
        cBuffer = SUBSTR(cBuffer, 1, nLength)
        THIS.lst.AddItem(cBuffer)
    NEXT
 
    = DragFinish(hDrop)
 
PROTECTED PROCEDURE declare
    DECLARE INTEGER GetFocus IN user32
    DECLARE DragFinish IN shell32 INTEGER hDrop
 
    DECLARE DragAcceptFiles IN Shell32;
        INTEGER hWindow, INTEGER fAccept
 
    DECLARE INTEGER DragQueryFile IN shell32;
        INTEGER hDrop, INTEGER iFile,;
        STRING @lpszFile, INTEGER cch
 
    DECLARE INTEGER DragQueryPoint IN shell32;
        INTEGER hDrop, STRING @lppt
 
    DECLARE INTEGER CallWindowProc IN user32;
        INTEGER lpPrevWndFunc, INTEGER hWindow, LONG Msg,;
        INTEGER wParam, INTEGER lParam
 
    DECLARE INTEGER GetWindowLong IN user32;
        INTEGER hWindow, INTEGER nIndex
 
ENDDEFINE
 
FUNCTION buf2dword(lcBuffer)
RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ;
    BitLShift(Asc(SUBSTR(lcBuffer, 2,1)),  8) +;
    BitLShift(Asc(SUBSTR(lcBuffer, 3,1)), 16) +;
    BitLShift(Asc(SUBSTR(lcBuffer, 4,1)), 24)
 
 
 

User rating: 7/10 (1 votes)
Rate this code sample:
  • ~
3507 bytes  
Created: 2002-08-10 09:52:33  
Modified: 2005-08-05 15:15:13  
Visits in 7 days: 201  
Listed functions:
CallWindowProc
DragAcceptFiles
DragFinish
DragQueryFile
DragQueryPoint
GetFocus
GetWindowLong
WindowProc
Printer friendly API declarations
My comment:
Read wonderful article of Andrew MacNeill Using Drag and Drop in your Applications. It explains how to use FoxPro native OLEDragOver and OLEDragDrop events for dragging and dropping files from Explorer and Outlook.
Word Index links for this example:
Translate this page:
  Spanish    Portuguese    German    French    Italian  
FreeTranslation.com offers instant, free translations of text or web pages.
User Contributed Notes:
mgreene@bdurham.com | 2005-05-22 22:02:07
Anatoliy,

Any ideas on how one can use OLEDragDrop to receive BMP or WAV content dropped on a VFP control? VFP's OLEDragDrop oDataObject.GetFormat() (2 for BMP, 12 for WAV) properly recognizes these data formats, but VFP's oDataObject.GetData() (2 for BMP, 12 for WAV) always returns .F. when one tries to retrieve this data.

I've tried both the array and non-array versions of GetData() with the same result. Note that I can receive strings and files (VFP 9) fine. Now I want to do the hard stuff.

Any suggestions appreciated,

Malcolm

Copyright © 2001-2013 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

Privacy policy
Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.1.55-log), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (54.235.20.17)
6.28 hrs.Example: 'Windows Shell Icons displayed and exported to ICO files (Vista)'
 Example: 'Setting the last-error code for the FoxPro'
7.32 hrs.Example: 'Class library providing access to the System Registry'
 Example: 'Scanning the hierarchy of child windows down from the main VFP window'
10.94 hrs.Function: 'GetWorldTransform'
 Example: 'Simple MAPI: how to pick an email recipient from Outlook Express address book'
17.06 hrs.Example: 'Accessing examples contained in this reference through Web Services'
 Function: 'GetWindowLong'
23.11 hrs.Function: 'JetCommitTransaction'
Function group: 'Extensible Storage Engine (ESE, Jet Blue)'
 Example: 'GDI+: printing image file'
Google
Advertise here!