Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CRichEditView drop file

Posted on 1998-06-07
2
Medium Priority
?
275 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
[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
2 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 400 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Suggested Courses

618 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