Ignore:
Timestamp:
Jun 2, 2002, 9:34:36 PM (23 years ago)
Author:
sandervl
Message:

added ole drag and drop (wps -> odin app) support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/dragdrop.cpp

    r8542 r8553  
    1 /* $Id: dragdrop.cpp,v 1.1 2002-06-02 10:08:09 sandervl Exp $ */
     1/* $Id: dragdrop.cpp,v 1.2 2002-06-02 19:34:25 sandervl Exp $ */
    22
    33/*
     
    1111#include <windows.h>
    1212#include <dbglog.h>
     13#include <oledd.h>
    1314
    1415#define DBG_LOCALLOG    DBG_dragdrop
    1516#include "dbglocal.h"
    1617
     18static PFN_DRAGENTER       pfnDragEnter       = NULL;
     19static PFN_DRAGLEAVE       pfnDragLeave       = NULL;
     20static PFN_DROPFILES       pfnDropFiles       = NULL;
     21static PFN_DRAGOVER        pfnDragOver        = NULL;
     22static PFN_ACCEPTSDRAGDROP pfnAcceptsDragDrop = NULL;
     23static HANDLE              hOLE32             = 0;
     24
    1725//******************************************************************************
    1826//******************************************************************************
    19 ULONG DragDropFiles(HWND hwnd, UINT cFiles, POINT point, LPSTR pszFiles, UINT cbszFiles, BOOL fNonClient)
     27ULONG DragDropFiles(HWND hwnd, POINT point, UINT cFiles, LPSTR pszFiles, UINT cbszFiles, BOOL fNonClient)
    2028{
    2129    DROPFILES *pDropFile;
    2230    HGLOBAL    hDropFile;
    2331    DWORD      dwExStyle;
     32    HWND       orghwnd = hwnd;
    2433
    2534    dwExStyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
    2635   
    27     //Is it correct if the window or parent accepts files or must we check the topparent parent?
     36    //TODO: Is it correct if the window or parent accepts files or must we check the top parent?
    2837    hwnd = (dwExStyle & WS_EX_ACCEPTFILES) ? hwnd : GetParent(hwnd);
     38
     39    dwExStyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
     40    if(!(dwExStyle & WS_EX_ACCEPTFILES)) {
     41        if(pfnDropFiles) {
     42            return pfnDropFiles(hwnd);
     43        }
     44        return FALSE;
     45    }
    2946    cbszFiles++;    //extra terminating 0
    30 
    31     if(IsWindowUnicode(hwnd)) {
    32         dprintf(("unicode dropfiles"));
    33         cbszFiles *= 2;
    34     }
    35 
    3647    hDropFile = GlobalAlloc(0, sizeof(DROPFILES)+cbszFiles);
    3748    pDropFile = (DROPFILES *)GlobalLock(hDropFile);
     
    4253    pDropFile->pFiles = sizeof(DROPFILES);
    4354    pDropFile->fNC    = fNonClient;
    44     pDropFile->fWide  = ::IsWindowUnicode(hwnd);
     55    pDropFile->fWide  = FALSE;
    4556    pDropFile->pt     = point;
    46     if(IsWindowUnicode(hwnd)) {
    47         LPWSTR lpszFilesW = (LPWSTR)(pDropFile+1);
    48         while(*pszFiles) {
    49             int len = strlen(pszFiles);
    50             MultiByteToWideChar(CP_ACP, 0, pszFiles, -1, lpszFilesW, len);
    51             pszFiles   += len + 1;
    52             lpszFilesW += len + 1;
    53         }
    54         *lpszFilesW = 0;
    55     }
    56     else {
    57         //copy strings (excluding terminating 0)
    58         memcpy((pDropFile+1), pszFiles, cbszFiles-1);
    59     }
     57    //copy strings (excluding terminating 0)
     58    memcpy((pDropFile+1), pszFiles, cbszFiles-1);
    6059    GlobalUnlock(hDropFile);
    6160    SendMessageA(hwnd, WM_DROPFILES, hDropFile, 0);
    6261    return 0;
     62}
     63//******************************************************************************
     64//******************************************************************************
     65BOOL DragDropDragOver(HWND hwnd, DWORD dwEffect)
     66{
     67    if(pfnDragOver) {
     68        return pfnDragOver(hwnd, dwEffect);
     69    }
     70    return TRUE;    //ignore
     71}
     72//******************************************************************************
     73//******************************************************************************
     74BOOL DragDropDragEnter(HWND hwnd, POINT point, UINT cFiles, LPSTR pszFiles, UINT cbszFiles,
     75                       DWORD dwEffect, BOOL fNonClient)
     76{
     77    DROPFILES *pDropFile;
     78    HGLOBAL    hDropFile;
     79
     80    if(pfnDragEnter) {
     81        cbszFiles++;    //extra terminating 0
     82        hDropFile = GlobalAlloc(0, sizeof(DROPFILES)+cbszFiles);
     83        pDropFile = (DROPFILES *)GlobalLock(hDropFile);
     84        if(pDropFile == NULL) {
     85            DebugInt3();
     86            return FALSE;
     87        }
     88        pDropFile->pFiles = sizeof(DROPFILES);
     89        pDropFile->fNC    = fNonClient;
     90        pDropFile->fWide  = FALSE;
     91        pDropFile->pt     = point;
     92        //copy strings (excluding terminating 0)
     93        memcpy((pDropFile+1), pszFiles, cbszFiles-1);
     94        GlobalUnlock(hDropFile);
     95
     96        return pfnDragEnter(hwnd, hDropFile, dwEffect);
     97    }
     98    return TRUE;    //ignore
     99}
     100//******************************************************************************
     101//******************************************************************************
     102BOOL DragDropDragLeave(HWND hwnd)
     103{
     104    if(pfnDragLeave) {
     105        return pfnDragLeave(hwnd);
     106    }
     107    return TRUE;    //ignore
    63108}
    64109//******************************************************************************
     
    75120    DWORD dwStyle = GetWindowLongA(GetParent(hwnd), GWL_EXSTYLE);
    76121    if(!(dwStyle & WS_EX_ACCEPTFILES)) {
     122        if(pfnAcceptsDragDrop == NULL) {
     123            //check for OLE drag & drop
     124
     125            hOLE32 = GetModuleHandleA("OLE32.DLL");
     126            if(hOLE32 == 0) {
     127                //if ole32.dll isn't loaded, then ole drag and drop can't be active
     128                return FALSE;
     129            }
     130            //make sure the dll doesn't get unloaded
     131            hOLE32 = LoadLibraryA("OLE32.DLL");
     132
     133            pfnAcceptsDragDrop = (PFN_ACCEPTSDRAGDROP)GetProcAddress(hOLE32, "OLEDD_AcceptsDragDrop");
     134            pfnDragOver        = (PFN_DRAGOVER)GetProcAddress(hOLE32, "OLEDD_DragOver");
     135            pfnDragLeave       = (PFN_DRAGLEAVE)GetProcAddress(hOLE32, "OLEDD_DragLeave");
     136            pfnDragEnter       = (PFN_DRAGENTER)GetProcAddress(hOLE32, "OLEDD_DragEnter");
     137            pfnDropFiles       = (PFN_DROPFILES)GetProcAddress(hOLE32, "OLEDD_DropFiles");
     138            if(!pfnAcceptsDragDrop || !pfnDragOver || !pfnDragLeave || !pfnDragEnter || !pfnDropFiles) {
     139                dprintf(("OLE DD functions not found!!"));
     140                DebugInt3();
     141                return FALSE;
     142            }
     143        }
     144        if(pfnAcceptsDragDrop) {
     145            return pfnAcceptsDragDrop(hwnd);
     146        }
    77147        return FALSE;
    78148    }
Note: See TracChangeset for help on using the changeset viewer.