]> git.saurik.com Git - wxWidgets.git/blame - src/msw/ole/dataobj.cpp
Fix to excule OnPaint from WXPM
[wxWidgets.git] / src / msw / ole / dataobj.cpp
CommitLineData
269a5a34
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: msw/ole/dataobj.cpp
3// Purpose: implementation of wx[I]DataObject class
4// Author: Vadim Zeitlin
3f4a0c5b 5// Modified by:
269a5a34
VZ
6// Created: 10.05.98
7// RCS-ID: $Id$
8// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9// Licence: wxWindows license
10///////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
20#ifdef __GNUG__
0d0512bd 21 #pragma implementation "dataobj.h"
269a5a34
VZ
22#endif
23
24// For compilers that support precompilation, includes "wx.h".
25#include "wx/wxprec.h"
26
27#if defined(__BORLANDC__)
0d0512bd 28 #pragma hdrstop
269a5a34 29#endif
0d0512bd
VZ
30
31#if defined(__WIN32__) && !defined(__GNUWIN32_OLD__)
32
7dee726c 33#ifndef WX_PRECOMP
0d0512bd
VZ
34 #include "wx/intl.h"
35 #include "wx/log.h"
7dee726c 36#endif
5260b1c5 37
3f480da3 38#include "wx/dataobj.h"
17b74d79 39
0d0512bd
VZ
40#include "wx/msw/private.h" // includes <windows.h>
41
b64f0a5f 42#if wxUSE_NORLANDER_HEADERS
7dee726c
RS
43 #include <ole2.h>
44#endif
17b74d79 45#include <oleauto.h>
269a5a34 46
f6aa3903 47#ifndef __WIN32__
269a5a34
VZ
48 #include <ole2.h>
49 #include <olestd.h>
50#endif
51
8b85d24e
VZ
52#include <shlobj.h>
53
0d0512bd
VZ
54#include "wx/msw/ole/oleutils.h"
55
56#include "wx/msw/dib.h"
17b74d79 57
269a5a34
VZ
58// ----------------------------------------------------------------------------
59// functions
60// ----------------------------------------------------------------------------
61
8e193f38 62#ifdef __WXDEBUG__
d59ceba5 63 static const wxChar *GetTymedName(DWORD tymed);
1e8335b0
VZ
64#else // !Debug
65 #define GetTymedName(tymed) ""
66#endif // Debug/!Debug
269a5a34
VZ
67
68// ----------------------------------------------------------------------------
69// wxIEnumFORMATETC interface implementation
70// ----------------------------------------------------------------------------
8e193f38 71
269a5a34
VZ
72class wxIEnumFORMATETC : public IEnumFORMATETC
73{
74public:
8e193f38 75 wxIEnumFORMATETC(const wxDataFormat* formats, ULONG nCount);
c77ae1d9
VZ
76
77 // to suppress the gcc warning about "class has virtual functions but non
78 // virtual dtor"
79#ifdef __GNUG__
80 virtual
81#endif
8e193f38 82 ~wxIEnumFORMATETC() { delete [] m_formats; }
269a5a34 83
8e193f38 84 DECLARE_IUNKNOWN_METHODS;
269a5a34 85
8e193f38
VZ
86 // IEnumFORMATETC
87 STDMETHODIMP Next(ULONG celt, FORMATETC *rgelt, ULONG *pceltFetched);
88 STDMETHODIMP Skip(ULONG celt);
89 STDMETHODIMP Reset();
90 STDMETHODIMP Clone(IEnumFORMATETC **ppenum);
269a5a34
VZ
91
92private:
8e193f38
VZ
93 CLIPFORMAT *m_formats; // formats we can provide data in
94 ULONG m_nCount, // number of formats we support
95 m_nCurrent; // current enum position
269a5a34
VZ
96};
97
98// ----------------------------------------------------------------------------
99// wxIDataObject implementation of IDataObject interface
100// ----------------------------------------------------------------------------
8e193f38 101
269a5a34
VZ
102class wxIDataObject : public IDataObject
103{
104public:
8e193f38 105 wxIDataObject(wxDataObject *pDataObject);
c77ae1d9
VZ
106
107 // to suppress the gcc warning about "class has virtual functions but non
108 // virtual dtor"
109#ifdef __GNUG__
110 virtual
111#endif
d59ceba5
VZ
112 ~wxIDataObject();
113
114 // normally, wxDataObject controls our lifetime (i.e. we're deleted when it
115 // is), but in some cases, the situation is inversed, that is we delete it
116 // when this object is deleted - setting this flag enables such logic
117 void SetDeleteFlag() { m_mustDelete = TRUE; }
269a5a34 118
8e193f38 119 DECLARE_IUNKNOWN_METHODS;
269a5a34 120
8e193f38
VZ
121 // IDataObject
122 STDMETHODIMP GetData(FORMATETC *pformatetcIn, STGMEDIUM *pmedium);
123 STDMETHODIMP GetDataHere(FORMATETC *pformatetc, STGMEDIUM *pmedium);
124 STDMETHODIMP QueryGetData(FORMATETC *pformatetc);
125 STDMETHODIMP GetCanonicalFormatEtc(FORMATETC *In, FORMATETC *pOut);
126 STDMETHODIMP SetData(FORMATETC *pfetc, STGMEDIUM *pmedium, BOOL fRelease);
127 STDMETHODIMP EnumFormatEtc(DWORD dwDirection, IEnumFORMATETC **ppenumFEtc);
128 STDMETHODIMP DAdvise(FORMATETC *pfetc, DWORD ad, IAdviseSink *p, DWORD *pdw);
129 STDMETHODIMP DUnadvise(DWORD dwConnection);
130 STDMETHODIMP EnumDAdvise(IEnumSTATDATA **ppenumAdvise);
269a5a34
VZ
131
132private:
8e193f38 133 wxDataObject *m_pDataObject; // pointer to C++ class we belong to
d59ceba5
VZ
134
135 bool m_mustDelete;
136};
137
269a5a34
VZ
138// ============================================================================
139// implementation
140// ============================================================================
141
3f480da3
VZ
142// ----------------------------------------------------------------------------
143// wxDataFormat
144// ----------------------------------------------------------------------------
145
146void wxDataFormat::SetId(const wxChar *format)
147{
148 m_format = ::RegisterClipboardFormat(format);
149 if ( !m_format )
150 {
151 wxLogError(_("Couldn't register clipboard format '%s'."), format);
152 }
153}
154
155wxString wxDataFormat::GetId() const
156{
157 static const int max = 256;
158
159 wxString s;
160
161 wxCHECK_MSG( !IsStandard(), s,
223d09f6 162 wxT("name of predefined format cannot be retrieved") );
3f480da3
VZ
163
164 int len = ::GetClipboardFormatName(m_format, s.GetWriteBuf(max), max);
165 s.UngetWriteBuf();
166
167 if ( !len )
168 {
169 wxLogError(_("The clipboard format '%d' doesn't exist."), m_format);
170 }
171
172 return s;
173}
174
269a5a34
VZ
175// ----------------------------------------------------------------------------
176// wxIEnumFORMATETC
177// ----------------------------------------------------------------------------
178
179BEGIN_IID_TABLE(wxIEnumFORMATETC)
8e193f38
VZ
180 ADD_IID(Unknown)
181 ADD_IID(EnumFORMATETC)
269a5a34
VZ
182END_IID_TABLE;
183
184IMPLEMENT_IUNKNOWN_METHODS(wxIEnumFORMATETC)
185
8e193f38 186wxIEnumFORMATETC::wxIEnumFORMATETC(const wxDataFormat *formats, ULONG nCount)
269a5a34 187{
8e193f38
VZ
188 m_cRef = 0;
189 m_nCurrent = 0;
190 m_nCount = nCount;
191 m_formats = new CLIPFORMAT[nCount];
192 for ( ULONG n = 0; n < nCount; n++ ) {
193 m_formats[n] = formats[n].GetFormatId();
194 }
269a5a34
VZ
195}
196
197STDMETHODIMP wxIEnumFORMATETC::Next(ULONG celt,
198 FORMATETC *rgelt,
199 ULONG *pceltFetched)
200{
8e193f38 201 wxLogTrace(wxTRACE_OleCalls, wxT("wxIEnumFORMATETC::Next"));
269a5a34 202
8e193f38
VZ
203 if ( celt > 1 ) {
204 // we only return 1 element at a time - mainly because I'm too lazy to
205 // implement something which you're never asked for anyhow
206 return S_FALSE;
207 }
269a5a34 208
8e193f38
VZ
209 if ( m_nCurrent < m_nCount ) {
210 FORMATETC format;
211 format.cfFormat = m_formats[m_nCurrent++];
212 format.ptd = NULL;
213 format.dwAspect = DVASPECT_CONTENT;
214 format.lindex = -1;
215 format.tymed = TYMED_HGLOBAL;
216 *rgelt = format;
269a5a34 217
8e193f38
VZ
218 return S_OK;
219 }
220 else {
221 // bad index
222 return S_FALSE;
223 }
269a5a34
VZ
224}
225
226STDMETHODIMP wxIEnumFORMATETC::Skip(ULONG celt)
227{
8e193f38
VZ
228 wxLogTrace(wxTRACE_OleCalls, wxT("wxIEnumFORMATETC::Skip"));
229
230 m_nCurrent += celt;
231 if ( m_nCurrent < m_nCount )
232 return S_OK;
269a5a34 233
8e193f38
VZ
234 // no, can't skip this many elements
235 m_nCurrent -= celt;
269a5a34 236
8e193f38 237 return S_FALSE;
269a5a34
VZ
238}
239
240STDMETHODIMP wxIEnumFORMATETC::Reset()
241{
8e193f38 242 wxLogTrace(wxTRACE_OleCalls, wxT("wxIEnumFORMATETC::Reset"));
269a5a34 243
8e193f38 244 m_nCurrent = 0;
269a5a34 245
8e193f38 246 return S_OK;
269a5a34
VZ
247}
248
249STDMETHODIMP wxIEnumFORMATETC::Clone(IEnumFORMATETC **ppenum)
250{
8e193f38
VZ
251 wxLogTrace(wxTRACE_OleCalls, wxT("wxIEnumFORMATETC::Clone"));
252
253 // unfortunately, we can't reuse the code in ctor - types are different
254 wxIEnumFORMATETC *pNew = new wxIEnumFORMATETC(NULL, 0);
255 pNew->m_nCount = m_nCount;
256 pNew->m_formats = new CLIPFORMAT[m_nCount];
257 for ( ULONG n = 0; n < m_nCount; n++ ) {
258 pNew->m_formats[n] = m_formats[n];
259 }
260 pNew->AddRef();
261 *ppenum = pNew;
269a5a34 262
8e193f38 263 return S_OK;
269a5a34
VZ
264}
265
266// ----------------------------------------------------------------------------
267// wxIDataObject
268// ----------------------------------------------------------------------------
269
270BEGIN_IID_TABLE(wxIDataObject)
8e193f38
VZ
271 ADD_IID(Unknown)
272 ADD_IID(DataObject)
269a5a34
VZ
273END_IID_TABLE;
274
275IMPLEMENT_IUNKNOWN_METHODS(wxIDataObject)
276
277wxIDataObject::wxIDataObject(wxDataObject *pDataObject)
278{
8e193f38
VZ
279 m_cRef = 0;
280 m_pDataObject = pDataObject;
d59ceba5
VZ
281 m_mustDelete = FALSE;
282}
283
284wxIDataObject::~wxIDataObject()
285{
286 if ( m_mustDelete )
287 {
288 delete m_pDataObject;
289 }
269a5a34
VZ
290}
291
292// get data functions
293STDMETHODIMP wxIDataObject::GetData(FORMATETC *pformatetcIn, STGMEDIUM *pmedium)
294{
8e193f38 295 wxLogTrace(wxTRACE_OleCalls, wxT("wxIDataObject::GetData"));
269a5a34 296
8e193f38
VZ
297 // is data is in our format?
298 HRESULT hr = QueryGetData(pformatetcIn);
299 if ( FAILED(hr) )
300 return hr;
269a5a34 301
8e193f38
VZ
302 // for the bitmaps and metafiles we use the handles instead of global memory
303 // to pass the data
304 wxDataFormat format = (wxDataFormatId)pformatetcIn->cfFormat;
269a5a34 305
8e193f38
VZ
306 switch ( format )
307 {
308 case wxDF_BITMAP:
309 pmedium->tymed = TYMED_GDI;
310 break;
311
d9317fd4
VZ
312 case wxDF_ENHMETAFILE:
313 pmedium->tymed = TYMED_ENHMF;
314 break;
315
8e193f38 316 case wxDF_METAFILE:
265b0c07
VZ
317 pmedium->hGlobal = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE,
318 sizeof(METAFILEPICT));
319 if ( !pmedium->hGlobal ) {
f6bcfd97 320 wxLogLastError(wxT("GlobalAlloc"));
265b0c07
VZ
321 return E_OUTOFMEMORY;
322 }
8e193f38
VZ
323 pmedium->tymed = TYMED_MFPICT;
324 break;
325
326 default:
327 // alloc memory
328 size_t size = m_pDataObject->GetDataSize(format);
329 if ( !size ) {
330 // it probably means that the method is just not implemented
331 wxLogDebug(wxT("Invalid data size - can't be 0"));
332
333 return DV_E_FORMATETC;
334 }
335
9e2896e5
VZ
336 if ( !format.IsStandard() ) {
337 // for custom formats, put the size with the data - alloc the
338 // space for it
339 size += sizeof(size_t);
340 }
341
8e193f38
VZ
342 HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, size);
343 if ( hGlobal == NULL ) {
f6bcfd97 344 wxLogLastError(wxT("GlobalAlloc"));
8e193f38
VZ
345 return E_OUTOFMEMORY;
346 }
347
348 // copy data
349 pmedium->tymed = TYMED_HGLOBAL;
350 pmedium->hGlobal = hGlobal;
351 }
269a5a34 352
8e193f38
VZ
353 pmedium->pUnkForRelease = NULL;
354
355 // do copy the data
356 hr = GetDataHere(pformatetcIn, pmedium);
357 if ( FAILED(hr) ) {
358 // free resources we allocated
265b0c07 359 if ( pmedium->tymed & (TYMED_HGLOBAL | TYMED_MFPICT) ) {
8e193f38
VZ
360 GlobalFree(pmedium->hGlobal);
361 }
362
363 return hr;
364 }
269a5a34 365
8e193f38 366 return S_OK;
269a5a34
VZ
367}
368
369STDMETHODIMP wxIDataObject::GetDataHere(FORMATETC *pformatetc,
370 STGMEDIUM *pmedium)
371{
8e193f38 372 wxLogTrace(wxTRACE_OleCalls, wxT("wxIDataObject::GetDataHere"));
269a5a34 373
8e193f38
VZ
374 // put data in caller provided medium
375 switch ( pmedium->tymed )
376 {
377 case TYMED_GDI:
d59ceba5
VZ
378 if ( !m_pDataObject->GetDataHere(wxDF_BITMAP, &pmedium->hBitmap) )
379 return E_UNEXPECTED;
8e193f38
VZ
380 break;
381
d9317fd4
VZ
382 case TYMED_ENHMF:
383 if ( !m_pDataObject->GetDataHere(wxDF_ENHMETAFILE,
384 &pmedium->hEnhMetaFile) )
385 return E_UNEXPECTED;
386 break;
387
8e193f38 388 case TYMED_MFPICT:
d9317fd4
VZ
389 // fall through - we pass METAFILEPICT through HGLOBAL
390
8e193f38
VZ
391 case TYMED_HGLOBAL:
392 {
393 // copy data
9e2896e5
VZ
394 HGLOBAL hGlobal = pmedium->hGlobal;
395 void *pBuf = GlobalLock(hGlobal);
8e193f38
VZ
396 if ( pBuf == NULL ) {
397 wxLogLastError(wxT("GlobalLock"));
398 return E_OUTOFMEMORY;
399 }
400
9e2896e5
VZ
401 if ( !wxDataFormat(pformatetc->cfFormat).IsStandard() ) {
402 // for custom formats, put the size with the data
403 size_t *p = (size_t *)pBuf;
404 *p++ = GlobalSize(hGlobal);
405 pBuf = p;
406 }
407
408 wxDataFormat format = pformatetc->cfFormat;
d59ceba5
VZ
409 if ( !m_pDataObject->GetDataHere(format, pBuf) )
410 return E_UNEXPECTED;
8e193f38 411
9e2896e5 412 GlobalUnlock(hGlobal);
8e193f38
VZ
413 }
414 break;
415
416 default:
417 return DV_E_TYMED;
418 }
269a5a34 419
8e193f38 420 return S_OK;
269a5a34
VZ
421}
422
9e2896e5 423// set data functions
269a5a34
VZ
424STDMETHODIMP wxIDataObject::SetData(FORMATETC *pformatetc,
425 STGMEDIUM *pmedium,
426 BOOL fRelease)
427{
d59ceba5 428 wxLogTrace(wxTRACE_OleCalls, wxT("wxIDataObject::SetData"));
8e193f38 429
d59ceba5
VZ
430 switch ( pmedium->tymed )
431 {
432 case TYMED_GDI:
9e2896e5 433 m_pDataObject->SetData(wxDF_BITMAP, 0, &pmedium->hBitmap);
d59ceba5
VZ
434 break;
435
d9317fd4
VZ
436 case TYMED_ENHMF:
437 m_pDataObject->SetData(wxDF_ENHMETAFILE, 0, &pmedium->hEnhMetaFile);
438 break;
439
d59ceba5 440 case TYMED_MFPICT:
d9317fd4 441 // fall through - we pass METAFILEPICT through HGLOBAL
d59ceba5
VZ
442 case TYMED_HGLOBAL:
443 {
51edda6a
VZ
444 wxDataFormat format = pformatetc->cfFormat;
445
446 // this is quite weird, but for file drag and drop, explorer
447 // calls our SetData() with the formats we do *not* support!
448 //
449 // as we can't fix this bug in explorer (it's a bug because it
450 // should only use formats returned by EnumFormatEtc), do the
451 // check here
452 if ( !m_pDataObject->IsSupportedFormat(format) ) {
453 // go away!
454 return DV_E_FORMATETC;
455 }
456
d59ceba5
VZ
457 // copy data
458 void *pBuf = GlobalLock(pmedium->hGlobal);
459 if ( pBuf == NULL ) {
f6bcfd97 460 wxLogLastError(wxT("GlobalLock"));
d59ceba5
VZ
461
462 return E_OUTOFMEMORY;
463 }
464
9e2896e5
VZ
465 // we've got a problem with SetData() here because the base
466 // class version requires the size parameter which we don't
467 // have anywhere in OLE data transfer - so we need to
468 // synthetise it for known formats and we suppose that all data
469 // in custom formats starts with a DWORD containing the size
470 size_t size;
51edda6a 471 switch ( format )
9e2896e5
VZ
472 {
473 case CF_TEXT:
474 case CF_OEMTEXT:
475 size = strlen((const char *)pBuf);
476 break;
790ad94f 477#if !defined(__WATCOMC__) && ! (defined(__BORLANDC__) && (__BORLANDC__ < 0x500))
9e2896e5 478 case CF_UNICODETEXT:
d834f22c
JS
479#if (defined(__BORLANDC__) && (__BORLANDC__ > 0x530))
480 size = std::wcslen((const wchar_t *)pBuf);
481#else
c3b177ae 482 size = ::wcslen((const wchar_t *)pBuf);
d834f22c 483#endif
9e2896e5 484 break;
4d85bcd1 485#endif
9e2896e5
VZ
486 case CF_BITMAP:
487 case CF_HDROP:
488 // these formats don't use size at all, anyhow (but
489 // pass data by handle, which is always a single DWORD)
490 size = 0;
491 break;
492
8ee9d618
VZ
493 case CF_DIB:
494 // the handler will calculate size itself (it's too
495 // complicated to do it here)
496 size = 0;
497 break;
498
265b0c07
VZ
499 case CF_METAFILEPICT:
500 size = sizeof(METAFILEPICT);
501 break;
502
9e2896e5
VZ
503 default:
504 {
505 // we suppose that the size precedes the data
506 size_t *p = (size_t *)pBuf;
507 size = *p++;
508 pBuf = p;
f0c5ebdc
RD
509 if (! format.IsStandard() ) {
510 // see GetData for coresponding increment
511 size -= sizeof(size_t);
512 }
9e2896e5
VZ
513 }
514 }
515
9e2896e5 516 bool ok = m_pDataObject->SetData(format, size, pBuf);
d59ceba5
VZ
517
518 GlobalUnlock(pmedium->hGlobal);
9e2896e5
VZ
519
520 if ( !ok ) {
521 return E_UNEXPECTED;
522 }
d59ceba5
VZ
523 }
524 break;
525
526 default:
527 return DV_E_TYMED;
528 }
529
530 if ( fRelease ) {
265b0c07
VZ
531 // we own the medium, so we must release it - but do *not* free any
532 // data we pass by handle because we have copied it elsewhere
533 switch ( pmedium->tymed )
d59ceba5 534 {
265b0c07
VZ
535 case TYMED_GDI:
536 pmedium->hBitmap = 0;
537 break;
538
539 case TYMED_MFPICT:
540 pmedium->hMetaFilePict = 0;
541 break;
d9317fd4
VZ
542
543 case TYMED_ENHMF:
544 pmedium->hEnhMetaFile = 0;
545 break;
d59ceba5
VZ
546 }
547
548 ReleaseStgMedium(pmedium);
549 }
550
551 return S_OK;
269a5a34
VZ
552}
553
554// information functions
555STDMETHODIMP wxIDataObject::QueryGetData(FORMATETC *pformatetc)
556{
d59ceba5
VZ
557 // do we accept data in this format?
558 if ( pformatetc == NULL ) {
559 wxLogTrace(wxTRACE_OleCalls,
560 wxT("wxIDataObject::QueryGetData: invalid ptr."));
8e193f38 561
d59ceba5
VZ
562 return E_INVALIDARG;
563 }
269a5a34 564
d59ceba5
VZ
565 // the only one allowed by current COM implementation
566 if ( pformatetc->lindex != -1 ) {
567 wxLogTrace(wxTRACE_OleCalls,
568 wxT("wxIDataObject::QueryGetData: bad lindex %d"),
569 pformatetc->lindex);
269a5a34 570
d59ceba5
VZ
571 return DV_E_LINDEX;
572 }
269a5a34 573
d59ceba5
VZ
574 // we don't support anything other (THUMBNAIL, ICON, DOCPRINT...)
575 if ( pformatetc->dwAspect != DVASPECT_CONTENT ) {
576 wxLogTrace(wxTRACE_OleCalls,
577 wxT("wxIDataObject::QueryGetData: bad dwAspect %d"),
578 pformatetc->dwAspect);
579
580 return DV_E_DVASPECT;
581 }
582
583 // and now check the type of data requested
9e2896e5 584 wxDataFormat format = pformatetc->cfFormat;
d59ceba5 585 if ( m_pDataObject->IsSupportedFormat(format) ) {
d59ceba5 586 wxLogTrace(wxTRACE_OleCalls, wxT("wxIDataObject::QueryGetData: %s ok"),
1e8335b0 587 wxGetFormatName(format));
d59ceba5
VZ
588 }
589 else {
590 wxLogTrace(wxTRACE_OleCalls,
591 wxT("wxIDataObject::QueryGetData: %s unsupported"),
1e8335b0 592 wxGetFormatName(format));
9e2896e5 593
d59ceba5
VZ
594 return DV_E_FORMATETC;
595 }
596
597 // we only transfer data by global memory, except for some particular cases
598 DWORD tymed = pformatetc->tymed;
599 if ( (format == wxDF_BITMAP && !(tymed & TYMED_GDI)) &&
600 !(tymed & TYMED_HGLOBAL) ) {
601 // it's not what we're waiting for
d59ceba5
VZ
602 wxLogTrace(wxTRACE_OleCalls,
603 wxT("wxIDataObject::QueryGetData: %s != %s"),
604 GetTymedName(tymed),
605 GetTymedName(format == wxDF_BITMAP ? TYMED_GDI
606 : TYMED_HGLOBAL));
d59ceba5
VZ
607
608 return DV_E_TYMED;
609 }
610
269a5a34 611 return S_OK;
269a5a34
VZ
612}
613
614STDMETHODIMP wxIDataObject::GetCanonicalFormatEtc(FORMATETC *pFormatetcIn,
615 FORMATETC *pFormatetcOut)
616{
8e193f38
VZ
617 wxLogTrace(wxTRACE_OleCalls, wxT("wxIDataObject::GetCanonicalFormatEtc"));
618
619 // TODO we might want something better than this trivial implementation here
620 if ( pFormatetcOut != NULL )
621 pFormatetcOut->ptd = NULL;
269a5a34 622
8e193f38 623 return DATA_S_SAMEFORMATETC;
269a5a34
VZ
624}
625
9e2896e5 626STDMETHODIMP wxIDataObject::EnumFormatEtc(DWORD dwDir,
269a5a34
VZ
627 IEnumFORMATETC **ppenumFormatEtc)
628{
8e193f38 629 wxLogTrace(wxTRACE_OleCalls, wxT("wxIDataObject::EnumFormatEtc"));
269a5a34 630
9e2896e5
VZ
631 wxDataObject::Direction dir = dwDir == DATADIR_GET ? wxDataObject::Get
632 : wxDataObject::Set;
269a5a34 633
9e2896e5 634 size_t nFormatCount = m_pDataObject->GetFormatCount(dir);
8e193f38 635 wxDataFormat format, *formats;
9e2896e5
VZ
636 formats = nFormatCount == 1 ? &format : new wxDataFormat[nFormatCount];
637 m_pDataObject->GetAllFormats(formats, dir);
8e193f38
VZ
638
639 wxIEnumFORMATETC *pEnum = new wxIEnumFORMATETC(formats, nFormatCount);
640 pEnum->AddRef();
641 *ppenumFormatEtc = pEnum;
642
643 if ( formats != &format ) {
644 delete [] formats;
645 }
269a5a34 646
8e193f38 647 return S_OK;
269a5a34
VZ
648}
649
9e2896e5 650// ----------------------------------------------------------------------------
269a5a34 651// advise sink functions (not implemented)
9e2896e5
VZ
652// ----------------------------------------------------------------------------
653
269a5a34
VZ
654STDMETHODIMP wxIDataObject::DAdvise(FORMATETC *pformatetc,
655 DWORD advf,
656 IAdviseSink *pAdvSink,
657 DWORD *pdwConnection)
658{
659 return OLE_E_ADVISENOTSUPPORTED;
660}
661
662STDMETHODIMP wxIDataObject::DUnadvise(DWORD dwConnection)
663{
664 return OLE_E_ADVISENOTSUPPORTED;
665}
666
667STDMETHODIMP wxIDataObject::EnumDAdvise(IEnumSTATDATA **ppenumAdvise)
668{
669 return OLE_E_ADVISENOTSUPPORTED;
670}
671
672// ----------------------------------------------------------------------------
673// wxDataObject
674// ----------------------------------------------------------------------------
675
676wxDataObject::wxDataObject()
677{
d59ceba5
VZ
678 m_pIDataObject = new wxIDataObject(this);
679 m_pIDataObject->AddRef();
269a5a34
VZ
680}
681
682wxDataObject::~wxDataObject()
683{
d59ceba5
VZ
684 ReleaseInterface(m_pIDataObject);
685}
686
687void wxDataObject::SetAutoDelete()
688{
689 ((wxIDataObject *)m_pIDataObject)->SetDeleteFlag();
690 m_pIDataObject->Release();
691
692 // so that the dtor doesnt' crash
693 m_pIDataObject = NULL;
269a5a34
VZ
694}
695
d9317fd4 696#ifdef __WXDEBUG__
8e193f38 697
f6bcfd97 698const wxChar *wxDataObject::GetFormatName(wxDataFormat format)
d9317fd4
VZ
699{
700 // case 'xxx' is not a valid value for switch of enum 'wxDataFormat'
701 #ifdef __VISUALC__
702 #pragma warning(disable:4063)
703 #endif // VC++
704
f6bcfd97 705 static wxChar s_szBuf[256];
d9317fd4 706 switch ( format ) {
f6bcfd97
BP
707 case CF_TEXT: return wxT("CF_TEXT");
708 case CF_BITMAP: return wxT("CF_BITMAP");
709 case CF_METAFILEPICT: return wxT("CF_METAFILEPICT");
710 case CF_SYLK: return wxT("CF_SYLK");
711 case CF_DIF: return wxT("CF_DIF");
712 case CF_TIFF: return wxT("CF_TIFF");
713 case CF_OEMTEXT: return wxT("CF_OEMTEXT");
714 case CF_DIB: return wxT("CF_DIB");
715 case CF_PALETTE: return wxT("CF_PALETTE");
716 case CF_PENDATA: return wxT("CF_PENDATA");
717 case CF_RIFF: return wxT("CF_RIFF");
718 case CF_WAVE: return wxT("CF_WAVE");
719 case CF_UNICODETEXT: return wxT("CF_UNICODETEXT");
720 case CF_ENHMETAFILE: return wxT("CF_ENHMETAFILE");
721 case CF_HDROP: return wxT("CF_HDROP");
722 case CF_LOCALE: return wxT("CF_LOCALE");
8e193f38 723
d9317fd4 724 default:
c77ae1d9 725 if ( !::GetClipboardFormatName(format, s_szBuf, WXSIZEOF(s_szBuf)) )
d9317fd4
VZ
726 {
727 // it must be a new predefined format we don't know the name of
f6bcfd97 728 wxSprintf(s_szBuf, wxT("unknown CF (0x%04x)"), format.GetFormatId());
d9317fd4 729 }
8e193f38 730
d9317fd4 731 return s_szBuf;
8e193f38 732 }
1e8335b0 733
d9317fd4
VZ
734 #ifdef __VISUALC__
735 #pragma warning(default:4063)
736 #endif // VC++
269a5a34
VZ
737}
738
1e8335b0
VZ
739#endif // Debug
740
3f480da3 741// ----------------------------------------------------------------------------
9e2896e5 742// wxBitmapDataObject supports CF_DIB format
3f480da3
VZ
743// ----------------------------------------------------------------------------
744
9e2896e5 745size_t wxBitmapDataObject::GetDataSize() const
3f480da3 746{
9e2896e5 747 return wxConvertBitmapToDIB(NULL, GetBitmap());
3f480da3
VZ
748}
749
9e2896e5 750bool wxBitmapDataObject::GetDataHere(void *buf) const
3f480da3 751{
0d0512bd 752 return wxConvertBitmapToDIB((LPBITMAPINFO)buf, GetBitmap()) != 0;
3f480da3
VZ
753}
754
9e2896e5 755bool wxBitmapDataObject::SetData(size_t len, const void *buf)
3f480da3 756{
0d0512bd 757 wxBitmap bitmap(wxConvertDIBToBitmap((const LPBITMAPINFO)buf));
9e2896e5
VZ
758
759 if ( !bitmap.Ok() ) {
760 wxFAIL_MSG(wxT("pasting/dropping invalid bitmap"));
3f480da3 761
9e2896e5
VZ
762 return FALSE;
763 }
764
765 SetBitmap(bitmap);
3f480da3 766
9e2896e5 767 return TRUE;
3f480da3
VZ
768}
769
9e2896e5
VZ
770// ----------------------------------------------------------------------------
771// wxBitmapDataObject2 supports CF_BITMAP format
772// ----------------------------------------------------------------------------
773
774// the bitmaps aren't passed by value as other types of data (i.e. by copying
775// the data into a global memory chunk and passing it to the clipboard or
776// another application or whatever), but by handle, so these generic functions
777// don't make much sense to them.
778
779size_t wxBitmapDataObject2::GetDataSize() const
3f480da3 780{
9e2896e5 781 return 0;
3f480da3
VZ
782}
783
9e2896e5 784bool wxBitmapDataObject2::GetDataHere(void *pBuf) const
3f480da3 785{
9e2896e5
VZ
786 // we put a bitmap handle into pBuf
787 *(WXHBITMAP *)pBuf = GetBitmap().GetHBITMAP();
788
789 return TRUE;
3f480da3
VZ
790}
791
265b0c07 792bool wxBitmapDataObject2::SetData(size_t WXUNUSED(len), const void *pBuf)
3f480da3 793{
9e2896e5 794 HBITMAP hbmp = *(HBITMAP *)pBuf;
3f480da3 795
9e2896e5
VZ
796 BITMAP bmp;
797 if ( !GetObject(hbmp, sizeof(BITMAP), &bmp) )
798 {
f6bcfd97 799 wxLogLastError(wxT("GetObject(HBITMAP)"));
9e2896e5 800 }
8e193f38 801
9e2896e5
VZ
802 wxBitmap bitmap(bmp.bmWidth, bmp.bmHeight, bmp.bmPlanes);
803 bitmap.SetHBITMAP((WXHBITMAP)hbmp);
d59ceba5 804
9e2896e5
VZ
805 if ( !bitmap.Ok() ) {
806 wxFAIL_MSG(wxT("pasting/dropping invalid bitmap"));
807
808 return FALSE;
809 }
810
811 SetBitmap(bitmap);
812
813 return TRUE;
d59ceba5
VZ
814}
815
9e2896e5 816#if 0
8e193f38
VZ
817
818size_t wxBitmapDataObject::GetDataSize(const wxDataFormat& format) const
819{
d59ceba5
VZ
820 if ( format.GetFormatId() == CF_DIB )
821 {
822 // create the DIB
823 ScreenHDC hdc;
824
825 // shouldn't be selected into a DC or GetDIBits() would fail
826 wxASSERT_MSG( !m_bitmap.GetSelectedInto(),
827 wxT("can't copy bitmap selected into wxMemoryDC") );
828
829 // first get the info
830 BITMAPINFO bi;
831 if ( !GetDIBits(hdc, (HBITMAP)m_bitmap.GetHBITMAP(), 0, 0,
832 NULL, &bi, DIB_RGB_COLORS) )
833 {
f6bcfd97 834 wxLogLastError(wxT("GetDIBits(NULL)"));
d59ceba5
VZ
835
836 return 0;
837 }
838
839 return sizeof(BITMAPINFO) + bi.bmiHeader.biSizeImage;
840 }
841 else // CF_BITMAP
842 {
843 // no data to copy - we don't pass HBITMAP via global memory
844 return 0;
845 }
8e193f38
VZ
846}
847
d59ceba5 848bool wxBitmapDataObject::GetDataHere(const wxDataFormat& format,
8e193f38
VZ
849 void *pBuf) const
850{
d59ceba5
VZ
851 wxASSERT_MSG( m_bitmap.Ok(), wxT("copying invalid bitmap") );
852
853 HBITMAP hbmp = (HBITMAP)m_bitmap.GetHBITMAP();
854 if ( format.GetFormatId() == CF_DIB )
855 {
856 // create the DIB
857 ScreenHDC hdc;
858
859 // shouldn't be selected into a DC or GetDIBits() would fail
860 wxASSERT_MSG( !m_bitmap.GetSelectedInto(),
861 wxT("can't copy bitmap selected into wxMemoryDC") );
862
863 // first get the info
864 BITMAPINFO *pbi = (BITMAPINFO *)pBuf;
865 if ( !GetDIBits(hdc, hbmp, 0, 0, NULL, pbi, DIB_RGB_COLORS) )
866 {
f6bcfd97 867 wxLogLastError(wxT("GetDIBits(NULL)"));
d59ceba5
VZ
868
869 return 0;
870 }
871
872 // and now copy the bits
873 if ( !GetDIBits(hdc, hbmp, 0, pbi->bmiHeader.biHeight, pbi + 1,
874 pbi, DIB_RGB_COLORS) )
875 {
f6bcfd97 876 wxLogLastError(wxT("GetDIBits"));
d59ceba5
VZ
877
878 return FALSE;
879 }
880 }
881 else // CF_BITMAP
882 {
883 // we put a bitmap handle into pBuf
884 *(HBITMAP *)pBuf = hbmp;
885 }
886
887 return TRUE;
888}
889
9e2896e5
VZ
890bool wxBitmapDataObject::SetData(const wxDataFormat& format,
891 size_t size, const void *pBuf)
d59ceba5
VZ
892{
893 HBITMAP hbmp;
894 if ( format.GetFormatId() == CF_DIB )
895 {
896 // here we get BITMAPINFO struct followed by the actual bitmap bits and
897 // BITMAPINFO starts with BITMAPINFOHEADER followed by colour info
898 ScreenHDC hdc;
899
900 BITMAPINFO *pbmi = (BITMAPINFO *)pBuf;
901 BITMAPINFOHEADER *pbmih = &pbmi->bmiHeader;
902 hbmp = CreateDIBitmap(hdc, pbmih, CBM_INIT,
903 pbmi + 1, pbmi, DIB_RGB_COLORS);
904 if ( !hbmp )
905 {
f6bcfd97 906 wxLogLastError(wxT("CreateDIBitmap"));
d59ceba5
VZ
907 }
908
909 m_bitmap.SetWidth(pbmih->biWidth);
910 m_bitmap.SetHeight(pbmih->biHeight);
911 }
912 else // CF_BITMAP
913 {
914 // it's easy with bitmaps: we pass them by handle
915 hbmp = *(HBITMAP *)pBuf;
916
917 BITMAP bmp;
918 if ( !GetObject(hbmp, sizeof(BITMAP), &bmp) )
919 {
f6bcfd97 920 wxLogLastError(wxT("GetObject(HBITMAP)"));
d59ceba5
VZ
921 }
922
923 m_bitmap.SetWidth(bmp.bmWidth);
924 m_bitmap.SetHeight(bmp.bmHeight);
925 m_bitmap.SetDepth(bmp.bmPlanes);
926 }
927
928 m_bitmap.SetHBITMAP((WXHBITMAP)hbmp);
929
930 wxASSERT_MSG( m_bitmap.Ok(), wxT("pasting invalid bitmap") );
931
932 return TRUE;
8e193f38
VZ
933}
934
9e2896e5
VZ
935#endif // 0
936
937// ----------------------------------------------------------------------------
938// wxFileDataObject
939// ----------------------------------------------------------------------------
940
941bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *pData)
942{
943 m_filenames.Empty();
944
945 // the documentation states that the first member of DROPFILES structure is
946 // a "DWORD offset of double NUL terminated file list". What they mean by
947 // this (I wonder if you see it immediately) is that the list starts at
948 // ((char *)&(pDropFiles.pFiles)) + pDropFiles.pFiles. We're also advised
949 // to use DragQueryFile to work with this structure, but not told where and
950 // how to get HDROP.
951 HDROP hdrop = (HDROP)pData; // NB: it works, but I'm not sure about it
952
953 // get number of files (magic value -1)
954 UINT nFiles = ::DragQueryFile(hdrop, (unsigned)-1, NULL, 0u);
955
51edda6a
VZ
956 wxCHECK_MSG ( nFiles != (UINT)-1, FALSE, wxT("wrong HDROP handle") );
957
9e2896e5
VZ
958 // for each file get the length, allocate memory and then get the name
959 wxString str;
960 UINT len, n;
961 for ( n = 0; n < nFiles; n++ ) {
962 // +1 for terminating NUL
963 len = ::DragQueryFile(hdrop, n, NULL, 0) + 1;
964
965 UINT len2 = ::DragQueryFile(hdrop, n, str.GetWriteBuf(len), len);
966 str.UngetWriteBuf();
967 m_filenames.Add(str);
968
969 if ( len2 != len - 1 ) {
f6bcfd97
BP
970 wxLogDebug(wxT("In wxFileDropTarget::OnDrop DragQueryFile returned\
971 %d characters, %d expected."), len2, len - 1);
9e2896e5
VZ
972 }
973 }
974
975 return TRUE;
976}
977
8b85d24e
VZ
978void wxFileDataObject::AddFile(const wxString& file)
979{
980 // just add file to filenames array
981 // all useful data (such as DROPFILES struct) will be
982 // created later as necessary
983 m_filenames.Add(file);
984}
985
986size_t wxFileDataObject::GetDataSize() const
987{
988 // size returned will be the size of the DROPFILES structure,
989 // plus the list of filesnames (null byte separated), plus
990 // a double null at the end
991
992 // if no filenames in list, size is 0
dd10a646
VZ
993 if ( m_filenames.GetCount() == 0 )
994 return 0;
8b85d24e
VZ
995
996 // inital size of DROPFILES struct + null byte
997 size_t sz = sizeof(DROPFILES) + 1;
998
dd10a646
VZ
999 size_t count = m_filenames.GetCount();
1000 for ( size_t i = 0; i < count; i++ )
8b85d24e
VZ
1001 {
1002 // add filename length plus null byte
1003 sz += m_filenames[i].Len() + 1;
1004 }
dd10a646 1005
8b85d24e
VZ
1006 return sz;
1007}
1008
1009bool wxFileDataObject::GetDataHere(void *pData) const
1010{
1011 // pData points to an externally allocated memory block
1012 // created using the size returned by GetDataSize()
1013
1014 // if pData is NULL, or there are no files, return
dd10a646
VZ
1015 if ( !pData || m_filenames.GetCount() == 0 )
1016 return FALSE;
8b85d24e
VZ
1017
1018 // convert data pointer to a DROPFILES struct pointer
1019 LPDROPFILES pDrop = (LPDROPFILES) pData;
1020
1021 // initialize DROPFILES struct
1022 pDrop->pFiles = sizeof(DROPFILES);
dd10a646
VZ
1023 pDrop->fNC = FALSE; // not non-client coords
1024#if wxUSE_UNICODE
1025 pDrop->fWide = TRUE;
1026#else // ANSI
8b85d24e 1027 pDrop->fWide = FALSE;
dd10a646 1028#endif // Unicode/Ansi
8b85d24e
VZ
1029
1030 // set start of filenames list (null separated)
51babd09 1031 wxChar *pbuf = (wxChar*) ((BYTE *)pDrop + sizeof(DROPFILES));
8b85d24e 1032
dd10a646
VZ
1033 size_t count = m_filenames.GetCount();
1034 for (size_t i = 0; i < count; i++ )
8b85d24e
VZ
1035 {
1036 // copy filename to pbuf and add null terminator
1037 size_t len = m_filenames[i].Len();
1038 memcpy(pbuf, m_filenames[i], len);
1039 pbuf += len;
dd10a646 1040 *pbuf++ = wxT('\0');
8b85d24e 1041 }
dd10a646
VZ
1042
1043 *pbuf = wxT('\0'); // add final null terminator
8b85d24e
VZ
1044
1045 return TRUE;
1046}
1047
269a5a34
VZ
1048// ----------------------------------------------------------------------------
1049// private functions
1050// ----------------------------------------------------------------------------
8e193f38 1051
8ee9d618
VZ
1052static size_t wxGetNumOfBitmapColors(size_t bitsPerPixel)
1053{
1054 switch ( bitsPerPixel )
1055 {
1056 case 1:
1057 // monochrome bitmap, 2 entries
1058 return 2;
1059
1060 case 4:
1061 return 16;
1062
1063 case 8:
1064 return 256;
1065
1066 case 24:
1067 // may be used with 24bit bitmaps, but we don't use it here - fall
1068 // through
1069
1070 case 16:
1071 case 32:
1072 // bmiColors not used at all with these bitmaps
1073 return 0;
1074
1075 default:
1076 wxFAIL_MSG( wxT("unknown bitmap format") );
1077 return 0;
1078 }
1079}
9e2896e5 1080
0d0512bd 1081size_t wxConvertBitmapToDIB(LPBITMAPINFO pbi, const wxBitmap& bitmap)
9e2896e5 1082{
8ee9d618
VZ
1083 wxASSERT_MSG( bitmap.Ok(), wxT("invalid bmp can't be converted to DIB") );
1084
9e2896e5
VZ
1085 // shouldn't be selected into a DC or GetDIBits() would fail
1086 wxASSERT_MSG( !bitmap.GetSelectedInto(),
1087 wxT("can't copy bitmap selected into wxMemoryDC") );
1088
8ee9d618
VZ
1089 // prepare all the info we need
1090 BITMAP bm;
9e2896e5 1091 HBITMAP hbmp = (HBITMAP)bitmap.GetHBITMAP();
8ee9d618
VZ
1092 if ( !GetObject(hbmp, sizeof(bm), &bm) )
1093 {
f6bcfd97 1094 wxLogLastError(wxT("GetObject(bitmap)"));
8ee9d618
VZ
1095
1096 return 0;
1097 }
1098
1099 // calculate the number of bits per pixel and the number of items in
1100 // bmiColors array (whose meaning depends on the bitmap format)
1101 WORD biBits = bm.bmPlanes * bm.bmBitsPixel;
1102 WORD biColors = wxGetNumOfBitmapColors(biBits);
9e2896e5 1103
8ee9d618 1104 BITMAPINFO bi2;
9e2896e5 1105
8ee9d618
VZ
1106 bool wantSizeOnly = pbi == NULL;
1107 if ( wantSizeOnly )
1108 pbi = &bi2;
1109
1110 // just for convenience
1111 BITMAPINFOHEADER& bi = pbi->bmiHeader;
1112
1113 bi.biSize = sizeof(BITMAPINFOHEADER);
1114 bi.biWidth = bm.bmWidth;
1115 bi.biHeight = bm.bmHeight;
1116 bi.biPlanes = 1;
1117 bi.biBitCount = biBits;
1118 bi.biCompression = BI_RGB;
1119 bi.biSizeImage = 0;
1120 bi.biXPelsPerMeter = 0;
1121 bi.biYPelsPerMeter = 0;
1122 bi.biClrUsed = 0;
1123 bi.biClrImportant = 0;
1124
1125 // memory we need for BITMAPINFO only
1126 DWORD dwLen = bi.biSize + biColors * sizeof(RGBQUAD);
1127
1128 // first get the image size
9e2896e5 1129 ScreenHDC hdc;
8ee9d618 1130 if ( !GetDIBits(hdc, hbmp, 0, bi.biHeight, NULL, pbi, DIB_RGB_COLORS) )
9e2896e5 1131 {
f6bcfd97 1132 wxLogLastError(wxT("GetDIBits(NULL)"));
9e2896e5
VZ
1133
1134 return 0;
1135 }
1136
8ee9d618 1137 if ( wantSizeOnly )
9e2896e5 1138 {
8ee9d618
VZ
1139 // size of the header + size of the image
1140 return dwLen + bi.biSizeImage;
9e2896e5
VZ
1141 }
1142
1143 // and now copy the bits
8ee9d618
VZ
1144 void *image = (char *)pbi + dwLen;
1145 if ( !GetDIBits(hdc, hbmp, 0, bi.biHeight, image, pbi, DIB_RGB_COLORS) )
9e2896e5 1146 {
f6bcfd97 1147 wxLogLastError(wxT("GetDIBits"));
9e2896e5
VZ
1148
1149 return 0;
1150 }
1151
8ee9d618 1152 return dwLen + bi.biSizeImage;
9e2896e5
VZ
1153}
1154
0d0512bd 1155wxBitmap wxConvertDIBToBitmap(const LPBITMAPINFO pbmi)
9e2896e5
VZ
1156{
1157 // here we get BITMAPINFO struct followed by the actual bitmap bits and
1158 // BITMAPINFO starts with BITMAPINFOHEADER followed by colour info
1159 const BITMAPINFOHEADER *pbmih = &pbmi->bmiHeader;
1160
8ee9d618
VZ
1161 // offset of image from the beginning of the header
1162 DWORD ofs = wxGetNumOfBitmapColors(pbmih->biBitCount) * sizeof(RGBQUAD);
1163 void *image = (char *)pbmih + sizeof(BITMAPINFOHEADER) + ofs;
1164
9e2896e5
VZ
1165 ScreenHDC hdc;
1166 HBITMAP hbmp = CreateDIBitmap(hdc, pbmih, CBM_INIT,
8ee9d618 1167 image, pbmi, DIB_RGB_COLORS);
9e2896e5
VZ
1168 if ( !hbmp )
1169 {
f6bcfd97 1170 wxLogLastError(wxT("CreateDIBitmap"));
9e2896e5
VZ
1171 }
1172
1173 wxBitmap bitmap(pbmih->biWidth, pbmih->biHeight, pbmih->biBitCount);
1174 bitmap.SetHBITMAP((WXHBITMAP)hbmp);
1175
1176 return bitmap;
1177}
1178
8e193f38
VZ
1179#ifdef __WXDEBUG__
1180
d59ceba5
VZ
1181static const wxChar *GetTymedName(DWORD tymed)
1182{
1183 static wxChar s_szBuf[128];
1184 switch ( tymed ) {
1185 case TYMED_HGLOBAL: return wxT("TYMED_HGLOBAL");
1186 case TYMED_FILE: return wxT("TYMED_FILE");
1187 case TYMED_ISTREAM: return wxT("TYMED_ISTREAM");
1188 case TYMED_ISTORAGE: return wxT("TYMED_ISTORAGE");
1189 case TYMED_GDI: return wxT("TYMED_GDI");
1190 case TYMED_MFPICT: return wxT("TYMED_MFPICT");
1191 case TYMED_ENHMF: return wxT("TYMED_ENHMF");
1192 default:
dfd2e675 1193 wxSprintf(s_szBuf, wxT("type of media format %ld (unknown)"), tymed);
d59ceba5
VZ
1194 return s_szBuf;
1195 }
269a5a34 1196}
5260b1c5 1197
8e193f38 1198#endif // Debug
2845ddc2 1199
d59ceba5 1200#endif // not using OLE at all
5260b1c5 1201