Changeset 114
- Timestamp:
- Aug 10, 2006, 7:56:11 PM (19 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/qmime.h
r97 r114 174 174 175 175 #if !defined(QT_NO_DRAGANDDROP) 176 177 class Messenger178 {179 public:180 Messenger();181 virtual ~Messenger();182 HWND hwnd() const { return w; }183 virtual MRESULT message( ULONG msg, MPARAM mp1, MPARAM mp2 ) = 0;184 private:185 HWND w;186 static MRESULT EXPENTRY windowProc( HWND, ULONG, MPARAM, MPARAM );187 };188 176 189 177 class DragWorker … … 216 204 }; 217 205 218 class DefaultDragWorker : public DragWorker, public Messenger206 class DefaultDragWorker : public DragWorker, public QPMObjectWindow 219 207 { 220 208 private: … … 227 215 bool isExclusive() const; 228 216 ULONG itemCount() const; 229 HWND hwnd() const { return Messenger::hwnd(); }217 HWND hwnd() const { return QPMObjectWindow::hwnd(); } 230 218 QCString composeFormatString(); 231 219 bool prepare( const char *drm, const char *drf, DRAGITEM *item, … … 233 221 void defaultFileType( const char *&type, const char *&ext ); 234 222 235 // Messengerinterface223 // QPMObjectWindow interface 236 224 MRESULT message( ULONG msg, MPARAM mp1, MPARAM mp2 ); 237 225 … … 278 266 }; 279 267 280 class DefaultDropWorker : public DropWorker, public Messenger268 class DefaultDropWorker : public DropWorker, public QPMObjectWindow 281 269 { 282 270 private: … … 293 281 QByteArray encodedData( const char *format ) const; 294 282 295 // Messengerinterface283 // QPMObjectWindow interface 296 284 MRESULT message( ULONG msg, MPARAM mp1, MPARAM mp2 ); 297 285 -
trunk/src/kernel/qdnd_pm.cpp
r97 r114 588 588 } 589 589 590 class QPMCoopDragWorker : public QPMMime::DragWorker, QPMMime::Messenger590 class QPMCoopDragWorker : public QPMMime::DragWorker, public QPMObjectWindow 591 591 { 592 592 public: … … 602 602 DRAGINFO *createDragInfo( const char *name, USHORT supportedOps ); 603 603 604 // Messengerinterface604 // QPMObjectWindow interface 605 605 MRESULT message( ULONG msg, MPARAM mp1, MPARAM mp2 ); 606 606 … … 746 746 } 747 747 748 return QPM Mime::Messenger::hwnd();748 return QPMObjectWindow::hwnd(); 749 749 } 750 750 -
trunk/src/kernel/qmime_pm.cpp
r103 r114 211 211 { 212 212 return hex_to_int( (uchar) c ); 213 }214 215 // -----------------------------------------------------------------------------216 217 static QPtrList<HWND> msgWindows;218 219 static void destroyAllMessengerWindows()220 {221 for ( HWND *w = msgWindows.first(); w; w = msgWindows.next() ) {222 Q_ASSERT( *w );223 WinDestroyWindow( *w );224 // tell Messenger the window has been destroyed225 *w = 0;226 }227 }228 229 QPMMime::Messenger::Messenger() : w( 0 )230 {231 static const char *ClassName = "QPMMime::Messenger";232 static bool classRegistered = FALSE;233 if ( !classRegistered ) {234 WinRegisterClass( 0, ClassName, windowProc, 0, QWL_USER + sizeof(PVOID) );235 classRegistered = TRUE;236 // make sure windows are destroyed before the message queue237 qAddPostRoutine ( destroyAllMessengerWindows );238 }239 240 w = WinCreateWindow( HWND_OBJECT, ClassName,241 NULL, 0, 0, 0, 0, 0, NULL,242 HWND_BOTTOM, 0, this, NULL );243 Q_ASSERT( w );244 if ( w )245 msgWindows.append( &w );246 }247 248 QPMMime::Messenger::~Messenger()249 {250 if ( w ) {251 msgWindows.removeRef( &w );252 HWND h = w;253 w = 0; // tell windowProc() we're unsafe254 WinDestroyWindow( h );255 }256 }257 258 //static259 MRESULT EXPENTRY QPMMime::Messenger::windowProc( HWND hwnd, ULONG msg,260 MPARAM mp1, MPARAM mp2 )261 {262 if ( msg == WM_CREATE ) {263 Messenger *that = (Messenger *) mp1;264 if ( !that )265 return (MRESULT) TRUE;266 WinSetWindowPtr( hwnd, QWL_USER, that );267 return (MRESULT) FALSE;268 }269 270 Messenger *that = (Messenger *) WinQueryWindowPtr( hwnd, QWL_USER );271 Q_ASSERT( that );272 273 // Note: before WinCreateWindow() returns to the constructor or after the274 // destructor has been called, w is 0. We use this to determine that the275 // object is in the unsafe state (VTBL is not yet initialized or has been276 // already uninitialized), so message() points to never-never land.277 if ( !that || !that->w )278 return (MRESULT) FALSE;279 280 return that->message( msg, mp1, mp2 );281 213 } 282 214 … … 1754 1686 DropWorker *dropWorkerFor( DRAGINFO *info ); 1755 1687 1756 class NativeFileDrag : public DragWorker, public Messenger1688 class NativeFileDrag : public DragWorker, public QPMObjectWindow 1757 1689 { 1758 1690 public: … … 1761 1693 bool isExclusive() const { return TRUE; } 1762 1694 ULONG itemCount() const { return 0; } // super exclusive 1763 HWND hwnd() const { return Messenger::hwnd(); }1695 HWND hwnd() const { return QPMObjectWindow::hwnd(); } 1764 1696 DRAGINFO *createDragInfo( const char *name, USHORT supportedOps ); 1765 // Messengerinterface (dummy implementation, we don't need to interact)1697 // QPMObjectWindow interface (dummy implementation, we don't need to interact) 1766 1698 MRESULT message( ULONG msg, MPARAM mp1, MPARAM mp2 ) { return 0; } 1767 1699 };
Note:
See TracChangeset
for help on using the changeset viewer.