1 | /* $Id: dragdrop.cpp,v 1.1 2002-06-02 10:08:09 sandervl Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Win32 Drag 'n Drop functions for OS/2
|
---|
5 | *
|
---|
6 | * Copyright 2002 Sander van Leeuwen
|
---|
7 | *
|
---|
8 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
9 | *
|
---|
10 | */
|
---|
11 | #include <windows.h>
|
---|
12 | #include <dbglog.h>
|
---|
13 |
|
---|
14 | #define DBG_LOCALLOG DBG_dragdrop
|
---|
15 | #include "dbglocal.h"
|
---|
16 |
|
---|
17 | //******************************************************************************
|
---|
18 | //******************************************************************************
|
---|
19 | ULONG DragDropFiles(HWND hwnd, UINT cFiles, POINT point, LPSTR pszFiles, UINT cbszFiles, BOOL fNonClient)
|
---|
20 | {
|
---|
21 | DROPFILES *pDropFile;
|
---|
22 | HGLOBAL hDropFile;
|
---|
23 | DWORD dwExStyle;
|
---|
24 |
|
---|
25 | dwExStyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
|
---|
26 |
|
---|
27 | //Is it correct if the window or parent accepts files or must we check the topparent parent?
|
---|
28 | hwnd = (dwExStyle & WS_EX_ACCEPTFILES) ? hwnd : GetParent(hwnd);
|
---|
29 | cbszFiles++; //extra terminating 0
|
---|
30 |
|
---|
31 | if(IsWindowUnicode(hwnd)) {
|
---|
32 | dprintf(("unicode dropfiles"));
|
---|
33 | cbszFiles *= 2;
|
---|
34 | }
|
---|
35 |
|
---|
36 | hDropFile = GlobalAlloc(0, sizeof(DROPFILES)+cbszFiles);
|
---|
37 | pDropFile = (DROPFILES *)GlobalLock(hDropFile);
|
---|
38 | if(pDropFile == NULL) {
|
---|
39 | DebugInt3();
|
---|
40 | return 0;
|
---|
41 | }
|
---|
42 | pDropFile->pFiles = sizeof(DROPFILES);
|
---|
43 | pDropFile->fNC = fNonClient;
|
---|
44 | pDropFile->fWide = ::IsWindowUnicode(hwnd);
|
---|
45 | 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 | }
|
---|
60 | GlobalUnlock(hDropFile);
|
---|
61 | SendMessageA(hwnd, WM_DROPFILES, hDropFile, 0);
|
---|
62 | return 0;
|
---|
63 | }
|
---|
64 | //******************************************************************************
|
---|
65 | //******************************************************************************
|
---|
66 | BOOL DragDropAccept(HWND hwnd)
|
---|
67 | {
|
---|
68 | DWORD dwExStyle;
|
---|
69 |
|
---|
70 | dwExStyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
|
---|
71 | //Is it correct if the window or parent accepts files or must we check the topparent parent?
|
---|
72 | if(dwExStyle & WS_EX_ACCEPTFILES) {
|
---|
73 | return TRUE;
|
---|
74 | }
|
---|
75 | DWORD dwStyle = GetWindowLongA(GetParent(hwnd), GWL_EXSTYLE);
|
---|
76 | if(!(dwStyle & WS_EX_ACCEPTFILES)) {
|
---|
77 | return FALSE;
|
---|
78 | }
|
---|
79 | return TRUE;
|
---|
80 | }
|
---|
81 | //******************************************************************************
|
---|
82 | //******************************************************************************
|
---|
83 |
|
---|