diff --git a/if1632/shell.spec b/if1632/shell.spec index eaddc95c579..3a5ffb647cb 100644 --- a/if1632/shell.spec +++ b/if1632/shell.spec @@ -8,10 +8,10 @@ type win16 5 pascal RegSetValue(long str long str long) RegSetValue16 6 pascal RegQueryValue(long str ptr ptr) RegQueryValue16 7 pascal RegEnumKey(long long ptr long) RegEnumKey16 - 9 pascal16 DragAcceptFiles(word word) DragAcceptFiles - 11 pascal16 DragQueryFile(word s_word ptr s_word) DragQueryFile - 12 pascal16 DragFinish(word) DragFinish - 13 pascal16 DragQueryPoint(word ptr) DragQueryPoint + 9 pascal16 DragAcceptFiles(word word) DragAcceptFiles16 + 11 pascal16 DragQueryFile(word s_word ptr s_word) DragQueryFile16 + 12 pascal16 DragFinish(word) DragFinish16 + 13 pascal16 DragQueryPoint(word ptr) DragQueryPoint16 20 pascal16 ShellExecute(word str str str str s_word) ShellExecute16 21 pascal16 FindExecutable(str str ptr) FindExecutable16 22 pascal16 ShellAbout(word ptr ptr word) ShellAbout16 diff --git a/include/shell.h b/include/shell.h index c5d063e9660..31b199e0641 100644 --- a/include/shell.h +++ b/include/shell.h @@ -68,14 +68,40 @@ typedef WORD FILEOP_FLAGS; typedef WORD PRINTEROP_FLAGS; /****************************** -* DROPFILESTRUCT +* DRAG&DROP API */ typedef struct { /* structure for dropped files */ WORD wSize; POINT16 ptMousePos; BOOL16 fInNonClientArea; /* memory block with filenames follows */ -} DROPFILESTRUCT, *LPDROPFILESTRUCT; +} DROPFILESTRUCT16, *LPDROPFILESTRUCT16; + +typedef struct { /* structure for dropped files */ + DWORD lSize; + POINT32 ptMousePos; + BOOL32 fInNonClientArea; + BOOL32 fWideChar; + /* memory block with filenames follows */ +} DROPFILESTRUCT32, *LPDROPFILESTRUCT32; + +DECL_WINELIB_TYPE(DROPFILESTRUCT) +DECL_WINELIB_TYPE(LPDROPFILESTRUCT) + +void WINAPI DragAcceptFiles16(HWND16 hWnd, BOOL16 b); +void WINAPI DragAcceptFiles32(HWND32 hWnd, BOOL32 b); +#define DragAcceptFiles WINELIB_NAME(DragAcceptFiles) +UINT16 WINAPI DragQueryFile16(HDROP16 hDrop, WORD wFile, LPSTR lpszFile, WORD wLength); +UINT32 WINAPI DragQueryFile32A(HDROP32 hDrop, UINT32 lFile, LPSTR lpszFile, UINT32 lLength); +UINT32 WINAPI DragQueryFile32W(HDROP32 hDrop, UINT32 lFile, LPWSTR lpszFile, UINT32 lLength); +#define DragQueryFile WINELIB_NAME_AW(DragQueryFile) +void WINAPI DragFinish32(HDROP32 h); +void WINAPI DragFinish16(HDROP16 h); +#define DragFinish WINELIB_NAME(DragFinish) +BOOL32 WINAPI DragQueryPoint32(HDROP32 hDrop, POINT32 *p); +BOOL16 WINAPI DragQueryPoint16(HDROP16 hDrop, POINT16 *p); +#define DragQueryPoint WINELIB_NAME(DragQueryPoint) + /**************************************************************************** * NOTIFYICONDATA diff --git a/misc/shell.c b/misc/shell.c index 81cf3c77397..9659d69a82e 100644 --- a/misc/shell.c +++ b/misc/shell.c @@ -65,82 +65,191 @@ static UINT16 uMsgWndDestroyed = 0; static UINT16 uMsgShellActivate = 0; /************************************************************************* - * DragAcceptFiles [SHELL.9] + * DragAcceptFiles32 [SHELL32.54] */ -void WINAPI DragAcceptFiles(HWND16 hWnd, BOOL16 b) -{ WND* wnd = WIN_FindWndPtr(hWnd); - - if( wnd ) - wnd->dwExStyle = b? wnd->dwExStyle | WS_EX_ACCEPTFILES - : wnd->dwExStyle & ~WS_EX_ACCEPTFILES; +void WINAPI DragAcceptFiles32(HWND32 hWnd, BOOL32 b) +{ + WND* wnd = WIN_FindWndPtr(hWnd); + + if( wnd ) + wnd->dwExStyle = b? wnd->dwExStyle | WS_EX_ACCEPTFILES + : wnd->dwExStyle & ~WS_EX_ACCEPTFILES; } +/************************************************************************* + * DragAcceptFiles16 [SHELL.9] + */ +void WINAPI DragAcceptFiles16(HWND16 hWnd, BOOL16 b) +{ + DragAcceptFiles32(hWnd, b); +} /************************************************************************* - * DragQueryFile [SHELL.11] + * SHELL_DragQueryFile [internal] + * */ -UINT16 WINAPI DragQueryFile(HDROP16 hDrop, WORD wFile, LPSTR lpszFile, +static UINT32 SHELL_DragQueryFile(LPSTR lpDrop, LPWSTR lpwDrop, UINT32 lFile, + LPSTR lpszFile, LPWSTR lpszwFile, UINT32 lLength) +{ + UINT32 i; + + i = 0; + if (lpDrop) { + while (i++ < lFile) { + while (*lpDrop++); /* skip filename */ + if (!*lpDrop) + return (lFile == 0xFFFFFFFF) ? i : 0; + } + } + if (lpwDrop) { + while (i++ < lFile) { + while (*lpwDrop++); /* skip filename */ + if (!*lpwDrop) + return (lFile == 0xFFFFFFFF) ? i : 0; + } + } + + if (lpDrop) i = lstrlen32A(lpDrop); + if (lpwDrop) i = lstrlen32W(lpwDrop); + i++; + if (!lpszFile && !lpszwFile) { + return i; /* needed buffer size */ + } + i = (lLength > i) ? i : lLength; + if (lpszFile) { + if (lpDrop) lstrcpyn32A (lpszFile, lpDrop, i); + else lstrcpynWtoA(lpszFile, lpwDrop, i); + } else { + if (lpDrop) lstrcpynAtoW(lpszwFile, lpDrop, i); + else lstrcpyn32W (lpszwFile, lpwDrop, i); + } + return i; +} + +/************************************************************************* + * DragQueryFile32A [SHELL32.81] [shell32.82] + */ +UINT32 WINAPI DragQueryFile32A(HDROP32 hDrop, UINT32 lFile, LPSTR lpszFile, + UINT32 lLength) +{ /* hDrop is a global memory block allocated with GMEM_SHARE + * with DROPFILESTRUCT as a header and filenames following + * it, zero length filename is in the end */ + + LPDROPFILESTRUCT32 lpDropFileStruct; + LPSTR lpCurrent; + UINT32 i; + + TRACE(shell,"(%08x, %x, %p, %u)\n", hDrop,lFile,lpszFile,lLength); + + lpDropFileStruct = (LPDROPFILESTRUCT32) GlobalLock32(hDrop); + if(!lpDropFileStruct) + return 0; + + lpCurrent = (LPSTR) lpDropFileStruct + lpDropFileStruct->lSize; + i = SHELL_DragQueryFile(lpCurrent, NULL, lFile, lpszFile, NULL, lLength); + GlobalUnlock32(hDrop); + return i; +} + +/************************************************************************* + * DragQueryFile32W [shell32.133] + */ +UINT32 WINAPI DragQueryFile32W(HDROP32 hDrop, UINT32 lFile, LPWSTR lpszwFile, + UINT32 lLength) +{ + LPDROPFILESTRUCT32 lpDropFileStruct; + LPWSTR lpwCurrent; + UINT32 i; + + TRACE(shell,"(%08x, %x, %p, %u)\n", hDrop,lFile,lpszwFile,lLength); + + lpDropFileStruct = (LPDROPFILESTRUCT32) GlobalLock32(hDrop); + if(!lpDropFileStruct) + return 0; + + lpwCurrent = (LPWSTR) lpDropFileStruct + lpDropFileStruct->lSize; + i = SHELL_DragQueryFile(NULL, lpwCurrent, lFile, NULL, lpszwFile,lLength); + GlobalUnlock32(hDrop); + return i; +} +/************************************************************************* + * DragQueryFile16 [SHELL.11] + */ +UINT16 WINAPI DragQueryFile16(HDROP16 hDrop, WORD wFile, LPSTR lpszFile, WORD wLength) { /* hDrop is a global memory block allocated with GMEM_SHARE * with DROPFILESTRUCT as a header and filenames following * it, zero length filename is in the end */ - LPDROPFILESTRUCT lpDropFileStruct; + LPDROPFILESTRUCT16 lpDropFileStruct; LPSTR lpCurrent; WORD i; - TRACE(shell,"(%04x, %i, %p, %u)\n", - hDrop,wFile,lpszFile,wLength); + TRACE(shell,"(%04x, %x, %p, %u)\n", hDrop,wFile,lpszFile,wLength); + + lpDropFileStruct = (LPDROPFILESTRUCT16) GlobalLock16(hDrop); + if(!lpDropFileStruct) + return 0; - lpDropFileStruct = (LPDROPFILESTRUCT) GlobalLock16(hDrop); - if(!lpDropFileStruct) - return 0; - lpCurrent = (LPSTR) lpDropFileStruct + lpDropFileStruct->wSize; - - i = 0; - while (i++ < wFile) - { while (*lpCurrent++); /* skip filename */ - if (!*lpCurrent) - return (wFile == 0xFFFF) ? i : 0; - } - - i = strlen(lpCurrent); - if (!lpszFile) - return i+1; /* needed buffer size */ - - i = (wLength > i) ? i : wLength-1; - strncpy(lpszFile, lpCurrent, i); - lpszFile[i] = '\0'; + i = (WORD)SHELL_DragQueryFile(lpCurrent, NULL, wFile==0xffff?0xffffffff:wFile, + lpszFile, NULL, wLength); GlobalUnlock16(hDrop); return i; } + /************************************************************************* - * DragFinish [SHELL.12] + * DragFinish32 [SHELL32.80] */ -void WINAPI DragFinish(HDROP16 h) +void WINAPI DragFinish32(HDROP32 h) +{ TRACE(shell,"\n"); + GlobalFree32((HGLOBAL32)h); +} + +/************************************************************************* + * DragFinish16 [SHELL.12] + */ +void WINAPI DragFinish16(HDROP16 h) { TRACE(shell,"\n"); GlobalFree16((HGLOBAL16)h); } /************************************************************************* - * DragQueryPoint [SHELL.13] + * DragQueryPoint32 [SHELL32.135] */ -BOOL16 WINAPI DragQueryPoint(HDROP16 hDrop, POINT16 *p) -{ LPDROPFILESTRUCT lpDropFileStruct; - BOOL16 bRet; +BOOL32 WINAPI DragQueryPoint32(HDROP32 hDrop, POINT32 *p) +{ + LPDROPFILESTRUCT32 lpDropFileStruct; + BOOL32 bRet; TRACE(shell,"\n"); - lpDropFileStruct = (LPDROPFILESTRUCT) GlobalLock16(hDrop); + lpDropFileStruct = (LPDROPFILESTRUCT32) GlobalLock32(hDrop); + + memcpy(p,&lpDropFileStruct->ptMousePos,sizeof(POINT32)); + bRet = lpDropFileStruct->fInNonClientArea; + + GlobalUnlock32(hDrop); + return bRet; +} - memcpy(p,&lpDropFileStruct->ptMousePos,sizeof(POINT16)); - bRet = lpDropFileStruct->fInNonClientArea; - - GlobalUnlock16(hDrop); - return bRet; +/************************************************************************* + * DragQueryPoint16 [SHELL.13] + */ +BOOL16 WINAPI DragQueryPoint16(HDROP16 hDrop, POINT16 *p) +{ + LPDROPFILESTRUCT16 lpDropFileStruct; + BOOL16 bRet; + TRACE(shell,"\n"); + lpDropFileStruct = (LPDROPFILESTRUCT16) GlobalLock16(hDrop); + + memcpy(p,&lpDropFileStruct->ptMousePos,sizeof(POINT16)); + bRet = lpDropFileStruct->fInNonClientArea; + + GlobalUnlock16(hDrop); + return bRet; } /************************************************************************* diff --git a/programs/notepad/main.c b/programs/notepad/main.c index 791ca7357c5..735b4da7e3f 100644 --- a/programs/notepad/main.c +++ b/programs/notepad/main.c @@ -103,7 +103,7 @@ LRESULT NOTEPAD_WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) break; case WM_DROPFILES: - DragQueryFiles(wParam, 0, szFileName, sizeof(szFileName)); + DragQueryFile(wParam, 0, szFileName, sizeof(szFileName)); printf("file %s to be opened by drag and drop !\n", szFileName); DragFinish(wParam); break; diff --git a/relay32/shell32.spec b/relay32/shell32.spec index 89b4990152a..f490b895672 100644 --- a/relay32/shell32.spec +++ b/relay32/shell32.spec @@ -59,7 +59,7 @@ init Shell32LibMain 51 stdcall PathResolve(str long long) PathResolve 52 stdcall PathGetArgs(str) PathGetArgs 53 stub DoEnvironmentSubstW@8 # exported by name - 54 stdcall DragAcceptFiles(long long) DragAcceptFiles # exported by name + 54 stdcall DragAcceptFiles(long long) DragAcceptFiles32 55 stub PathQuoteSpaces 56 stdcall PathUnquoteSpaces(str) PathUnquoteSpaces 57 stdcall PathGetDriveNumber (str) PathGetDriveNumber32 @@ -85,9 +85,9 @@ init Shell32LibMain 77 stdcall SHMapPIDLToSystemImageListIndex(long long long) SHMapPIDLToSystemImageListIndex 78 stdcall OleStrToStrN(str long wstr long) OleStrToStrN 79 stdcall StrToOleStrN(wstr long str long) StrToOleStrN - 80 stub DragFinish # exported by name - 81 stub DragQueryFile # exported by name - 82 stub DragQueryFileA # exported by name + 80 stdcall DragFinish(long) DragFinish32 + 81 stdcall DragQueryFile(long long ptr long) DragQueryFile32A + 82 stdcall DragQueryFileA(long long ptr long) DragQueryFile32A 83 stub CIDLData_CreateFromIDArray 84 stub SHIsBadInterfacePtr 85 stdcall OpenRegStream(long long long long) OpenRegStream @@ -138,9 +138,9 @@ init Shell32LibMain 130 stub DAD_DragEnter 131 stub DAD_DragEnterEx 132 stub DAD_DragLeave - 133 stub DragQueryFileW # exported by name + 133 stdcall DragQueryFileW(long long ptr long) DragQueryFile32W 134 stub DAD_DragMove - 135 stub DragQueryPoint # exported by name + 135 stdcall DragQueryPoint(long ptr) DragQueryPoint32 136 stub DAD_SetDragImage 137 stdcall DAD_ShowDragImage (long) DAD_ShowDragImage 138 stub DuplicateIcon # exported by name