TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
purce
NA
3
0
Drag and Drop between c++ OLE and C#
Jul 16 2004 2:05 AM
Im working on a project where part of the project is in C++ and the other part is in C#. I want to enable draging and droping text between the 2 parts. So in my C++ I have a drag function from a tree void CDragsourceDlg::OnBegindragTree1(NMHDR* pNMHDR, LRESULT* pResult) { HGLOBAL hGlobal = GlobalAlloc( GMEM_MOVEABLE, 5); LPSTR pChar = (LPSTR) GlobalLock( hGlobal ); strcpy(pChar, "test"); GlobalUnlock (hGlobal); COleDataSource data; data.CacheGlobalData (CF_TEXT, hGlobal); data.DoDragDrop(DROPEFFECT_COPY, NULL, NULL); *pResult = 0; } and in C# i have a text box recieving the text private void textBox1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.Text)) e.Effect = DragDropEffects.Copy; else e.Effect = DragDropEffects.None; } private void textBox1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { textBox1.Text = e.Data.GetData(DataFormats.Text).ToString(); } Now the text gets across into my C# text box .. but the C++ program asserts and crashes on exit. Its easy enough to test with 2 simple programs .. and I have no idea what is causing the problem. Is there another way I should be implementing my source or destination?
Reply
Answers (
1
)
Dragging image inside the RichTextBox
Difference between Error and Exception