?
Solved

Drag and Drop enabling

Posted on 2000-02-16
31
Medium Priority
?
746 Views
Last Modified: 2013-11-20
I have a CStatic Derived class and I want to enable the ability to drag and drop files onto it.

The static control is created on the dialog app using the following code:

m_stcPortal.Create("", WS_VISIBLE|SS_NOTIFY|SS_SUNKEN, C3DPortal::GetRect(IDC_STATIC_PORTAL, this),(CWnd*)this);

I have implemented the following in the header:

//{{AFX_MSG(C3DPortal)
afx_msg void OnDropFiles(HDROP hDropInfo);
//}}AFX_MSG

...and in the cpp file:

int C3DPortal::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
   ...

   DragAcceptFiles(TRUE);

   ...
}

void C3DPortal::OnDropFiles(HDROP hDropInfo)
{
   ...
}

BEGIN_MESSAGE_MAP(C3DPortal, CStatic)
      //{{AFX_MSG_MAP(C3DPortal)
      ON_WM_DROPFILES()
          .
          .
          .
      //}}AFX_MSG_MAP
END_MESSAGE_MAP()






BUT:

There is still a "no-drag-allowed" icon showing when I drag a file over this control....

Why?
0
Comment
Question by:jhattingh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 18
  • 13
31 Comments
 
LVL 1

Expert Comment

by:ScottyDawg
ID: 2527708
Also call DragAcceptFiles(true) in your InitInstance(...). Does this help?
0
 
LVL 1

Author Comment

by:jhattingh
ID: 2527737
Thanks for the response.

DragAcceptFiles() doesn't take one parameter when called from the initinstance....?

0
 
LVL 1

Expert Comment

by:ScottyDawg
ID: 2527770
this is what the AppWizard does

// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;

if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
    return FALSE;

m_pMainWnd = pMainFrame;

// Enable drag/drop open
m_pMainWnd->DragAcceptFiles();
0
Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

 
LVL 1

Author Comment

by:jhattingh
ID: 2527791
DragAcceptFiles() asserts on the following:

ASSERT(::IsWindow(m_hWnd));

P.S. This is a dialog app

0
 
LVL 1

Accepted Solution

by:
ScottyDawg earned 400 total points
ID: 2527833
jhattingh,

I just knocked up a quick dialog based app and add 1 CStatic control to it. Then using class wizard I added a CStatic variable to my app called m_wndDropTarget. In OnInitDialog I did the following:

BOOL CTestDlg::OnInitDialog()
{
    CDialog::OnInitDialog()

....
....
....    
   
    m_wndDropTarget.DragAcceptFiles();

}

when I dragged a file over the static the mouse pointer changed from a no entry sign to the accept cursor. Hope this helps :)
0
 
LVL 1

Author Comment

by:jhattingh
ID: 2527854
Code changed:

m_stcPortal.Create("", WS_VISIBLE|SS_NOTIFY|SS_SUNKEN/*|WS_EX_ACCEPTFILES*/, C3DPortal::GetRect(IDC_STATIC_PORTAL, this),(CWnd*)this);

m_stcPortal.DragAcceptFiles(true);

..
..
..
..

Still not accepting files...?

Thanks for your persistence!
0
 
LVL 1

Expert Comment

by:ScottyDawg
ID: 2527868
hmmm....I think you'll need the WS_CHILD style to. If that doesn't help I've got another idea or two to try...we'll get there in the end I'm sure :)
0
 
LVL 1

Author Comment

by:jhattingh
ID: 2527880
Thanks...

tried it...


Need the other ideas... ;)
0
 
LVL 1

Expert Comment

by:ScottyDawg
ID: 2527887
*hahaha*

1st of all, can you create a new dialog app and follow what I did. If that at least doesn't work we definitely got a problem.
0
 
LVL 1

Author Comment

by:jhattingh
ID: 2527922
Adjusted points to 60
0
 
LVL 1

Author Comment

by:jhattingh
ID: 2527923
Ok....

1. Added CStatic Member variable to the dlg class

2. Called the same create function w/same parameters

3. Called DragAcceptFiles(true);

   .
   .
   .
   .

It works...! Hmmmm. What's up with my Other app I wonder?
0
 
LVL 1

Expert Comment

by:ScottyDawg
ID: 2527947
righty....

with this same dialog app add your CPortal class to it and declare a CPortal variable m_wndPortal (or whatever you want).


Now in OnInitDialog call

BOOL CDialog::OnInitDialog()
{
   CDialog::OnInitDialog();

   VERIFY(m_wndPortal.SubclassDlgItem(IDC_PORTAL_STATIC, this));
}

where IDC_PORTAL_STATIC is the ID of the static control on the dialog.

Does it work now?
0
 
LVL 1

Author Comment

by:jhattingh
ID: 2528048
It's exceptional.... that is to say, exceptioning!

In D3DRM.dll

So then the problem may be related to the coolest component of my CStatic derived class.

hmmmm.

I'd like it resolved, but I'm happy to drop (without a drag!) the 'question' if you think it's getting too hairy...

Jason
0
 
LVL 1

Expert Comment

by:ScottyDawg
ID: 2528091
sure I'll help if I can, but unless I see the source I don't know where to look next....

Are you overriding OnPaint() in the CStatic and doing something flash? or are you doing something in OnMouseMove() or OnSetCursor(), these could be the problems too...
0
 
LVL 1

Author Comment

by:jhattingh
ID: 2528113
I am doing a bit of overriding... Would you like me to send you the zipped project?
0
 
LVL 1

Expert Comment

by:ScottyDawg
ID: 2528131
go for it

scotnielsen@hotmail.com
0
 
LVL 1

Author Comment

by:jhattingh
ID: 2528157
Adjusted points to 70
0
 
LVL 1

Author Comment

by:jhattingh
ID: 2528158
Ok, I've sent it.
0
 
LVL 1

Expert Comment

by:ScottyDawg
ID: 2528475
on its way back
0
 
LVL 1

Author Comment

by:jhattingh
ID: 2528922
Adjusted points to 80
0
 
LVL 1

Author Comment

by:jhattingh
ID: 2528923
Ok got your mail - sounds cool! Thank you.
0
 
LVL 1

Expert Comment

by:ScottyDawg
ID: 2530496
is it working?
0
 
LVL 1

Author Comment

by:jhattingh
ID: 2530587
Adjusted points to 90
0
 
LVL 1

Author Comment

by:jhattingh
ID: 2530588
The mail you sent didn't have any code in or attached, and the EE posts haven't either - I was expecting an additional email with the code.... until you asked "Is it working?"

You must have accidentally not attached code to the email.

Can't wait...!
0
 
LVL 1

Author Comment

by:jhattingh
ID: 2530590
The mail you sent didn't have any code in or attached, and the EE posts haven't either - I was expecting an additional email with the code.... until you asked "Is it working?"

You must have accidentally not attached code to the email.

Can't wait...!
0
 
LVL 1

Expert Comment

by:ScottyDawg
ID: 2530596
ack! That'll be hotmail for you. Hang on a sec.
0
 
LVL 1

Author Comment

by:jhattingh
ID: 2530629
Adjusted points to 100
0
 
LVL 1

Author Comment

by:jhattingh
ID: 2530630
The dragdrop stuff appears to working... but it's removed the classes previous ability...<grin>

When I run the app, the control no longer can load and display 3D objects as it used to...
0
 
LVL 1

Expert Comment

by:ScottyDawg
ID: 2530650
I commented out the SetTimer call cos that was making it crash.

Also, it never seemed to come out of the OnPaint() function...
0
 
LVL 1

Author Comment

by:jhattingh
ID: 2531273
Still having problems with it, but I think it's about time I closed this question since you have more than answered my original question
0
 
LVL 1

Expert Comment

by:ScottyDawg
ID: 2531307
I think the biggest problem is the Group Box you had surrounding the entire set of dialog controls. Once I removed this, things went a lot smoother

:)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question