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
Solved

CRichEditView drop file

Posted on 1998-06-07
2
255 Views
Last Modified: 2013-11-19
How can I make my Rich  Edit view accept dropped files like Notepad does? i.e.; immediately render it it plain text instead of creating an OLE object.
0
Comment
Question by:midthune
2 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 100 total points
ID: 1316138
You'll need to do a couple of things:

1. Derive a new class from CRichEditView.

2. Override QueryAcceptData to return TRUE if the object supports the format CF_TEXT:


HRESULT CDrvLayView::QueryAcceptData(LPDATAOBJECT lpdataobj, CLIPFORMAT* lpcfFormat,
        DWORD dwReco, BOOL bReally, HGLOBAL hMetaPict)
{
        if (lpcfFormat == NULL)
                return S_FALSE;

        if (!bReally)
                return S_OK;

        COleDataObject obj;
        obj.Attach(lpdataobj);
        if (obj.IsDataAvailable(CF_TEXT))
        {
                *lpcfFormat = CF_TEXT;
                obj.Detach();
                return S_OK;
        }
        else
        {
                obj.Detach();
        }

        TRACE("format = %d\r\n", *lpcfFormat);

        if (*lpcfFormat == CF_TEXT)
                return CRichEditView::QueryAcceptData(lpdataobj, lpcfFormat, dwReco,
                        bReally, hMetaPict);
        else
                return S_FALSE;
}
0
 

Author Comment

by:midthune
ID: 1316139
Silly me. You had answered this question for me before, but my app would only accept text dragged from other apps, not files. Gee, could this have anything to do with the fact that I had never called DragAcceptFiles()? :)
    You've answered my question but would you be so kind as to let me know if there is an easy way to insert the dropped file's text in the open view (at the dropped point without erasing what's currently there) this is an MDI app and the dropped files only work when they are dropped on the frame, not in a view.
    I would ask another question but I only have 25 points left. I would understand if you do not wish to answer this second question. If you do, I will ask a non-question and give you all of my current points when you respond.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
cat dog challenge 18 127
iSeries DB2 Query 2 97
modThree challenge 4 97
wordappend challenge 8 200
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

860 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