Reputation: 1434
How would I drag and drop something into a static control? It looks like I need to create a sub class of COleDropTarget and include that as a member variable in a custom CStatic. That doesn't appear to be working though. When I try and drag something onto the Static control I get the drop denied cursor.
Upvotes: 2
Views: 1332
Reputation: 11
In addition to the PreSubClassWindow() addition, you also have to set your CStatic control to have the Notify flag set in its resource parameters. Otherwise the control won't let the app know about mouse movements and hence not trigger the OnDragEnter() method.
Upvotes: 1
Reputation: 16943
The static control's m_hWnd
must be valid when you call COleDropTarget::Register
, which is why it doesn't work from within your CMyStatic
constructor. What you can do is override CWnd::PreSubclassWindow
within your CMyStatic
class:
class CMyStatic : public CStatic {
...
virtual void PreSubclassWindow();
};
void CMyStatic::PreSubclassWindow()
{
CStatic::PreSubclassWindow();
m_MyDropTarget.Register(this);
}
There's a really good article here on CodeProject that you may find helpful.
Upvotes: 3