Ignore:
Timestamp:
Jun 1, 2002, 7:26:32 PM (23 years ago)
Author:
sandervl
Message:

implemented simple drag & drop with WM_DROPFILES

File:
1 edited

Legend:

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

    r8377 r8541  
    1 /* $Id: win32wbase.cpp,v 1.324 2002-05-07 13:28:13 sandervl Exp $ */
     1/* $Id: win32wbase.cpp,v 1.325 2002-06-01 17:26:31 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    12681268//******************************************************************************
    12691269//******************************************************************************
     1270ULONG Win32BaseWindow::MsgDropFiles(UINT cFiles, POINT point, LPSTR pszFiles, UINT cbszFiles, BOOL fNonClient)
     1271{
     1272    DROPFILES *pDropFile;
     1273    HGLOBAL    hDropFile;
     1274    HWND       hwnd;
     1275
     1276    hwnd = (getExStyle() & WS_EX_ACCEPTFILES) ? getWindowHandle() : ::GetParent(getWindowHandle());
     1277    cbszFiles++;    //extra terminating 0
     1278
     1279    if(::IsWindowUnicode(hwnd)) {
     1280        dprintf(("unicode dropfiles"));
     1281        cbszFiles *= 2;
     1282    }
     1283
     1284    hDropFile = GlobalAlloc(0, sizeof(DROPFILES)+cbszFiles);
     1285    pDropFile = (DROPFILES *)GlobalLock(hDropFile);
     1286    if(pDropFile == NULL) {
     1287        DebugInt3();
     1288        return 0;
     1289    }
     1290    pDropFile->pFiles = sizeof(DROPFILES);
     1291    pDropFile->fNC    = fNonClient;
     1292    pDropFile->fWide  = ::IsWindowUnicode(hwnd);
     1293    pDropFile->pt     = point;
     1294    if(::IsWindowUnicode(hwnd)) {
     1295        LPWSTR lpszFilesW = (LPWSTR)(pDropFile+1);
     1296        while(*pszFiles) {
     1297            int len = strlen(pszFiles);
     1298            MultiByteToWideChar(CP_ACP, 0, pszFiles, -1, lpszFilesW, len);
     1299            pszFiles   += len + 1;
     1300            lpszFilesW += len + 1;
     1301        }
     1302        *lpszFilesW = 0;
     1303    }
     1304    else {
     1305        //copy strings (excluding terminating 0)
     1306        memcpy((pDropFile+1), pszFiles, cbszFiles-1);
     1307    }
     1308    GlobalUnlock(hDropFile);
     1309    ::SendMessageA(hwnd, WM_DROPFILES, hDropFile, 0);
     1310    return 0;
     1311}
     1312//******************************************************************************
     1313//******************************************************************************
     1314BOOL Win32BaseWindow::AcceptsDropFiles()
     1315{
     1316    //Is it correct if the window or parent accepts files or must we check the topparent parent?
     1317    if(getExStyle() & WS_EX_ACCEPTFILES) {
     1318        return TRUE;
     1319    }
     1320    DWORD dwStyle = GetWindowLongA(::GetParent(getWindowHandle()), GWL_EXSTYLE);
     1321    if(!(dwStyle & WS_EX_ACCEPTFILES)) {
     1322        return FALSE;
     1323    }
     1324    return TRUE;
     1325}
     1326//******************************************************************************
     1327//******************************************************************************
    12701328ULONG Win32BaseWindow::MsgChar(MSG *msg)
    12711329{
Note: See TracChangeset for help on using the changeset viewer.