Problem in OLE DRAG AND DROP FROM VB SOURCE APP TO VC++ TARGET APP 
Author Message
 Problem in OLE DRAG AND DROP FROM VB SOURCE APP TO VC++ TARGET APP

I have developed an application in VB 5.0 which is to support drag and
drop operations.
The target application is developed in VC++ 2.0.
The user should be able to drag the text in a text control in one of the
forms of
the VB application and drop on to the view of the target VC++
application.
The target application expects a custom data format, So I register the
data format in the
start drag event of the source application and fill a byte array with
the appropriate
string and call setdata function to place the data on the dataobject.

The following is the exact code:

Public Declare Function RegisterClipboardFormat Lib _
        "user32.dll" Alias "RegisterClipboardFormatA" _
        (ByVal lpszFormat$) As Integer

Private Sub txtDeviceName_MouseDown(Button As Integer, Shift As Integer,
X As Single, Y As Single)
    txtDeviceName.OLEDrag
End Sub

Private Sub txtDeviceName_OLEStartDrag(Data As DataObject,
AllowedEffects As Long)
    Dim MyFormat As Integer
    Dim szFormat As String
    Dim szData As String, szTerminator As String
    Dim I As Integer
    szData = txtDeviceName.Text
    szTerminator = "\0"
    szData = szData + "::"
    ReDim A(Len(szData) + 3)
    For I = 0 To (Len(szData) - 1)
        A(I) = Asc(Mid(szData, I + 1, 1))
    Next I
    A(I + 1) = 0

    szFormat = "Catseye_NodeAddress"
    MyFormat = RegisterClipboardFormat(szFormat)
    If (txtDeviceName.Text <> "") Then

        AllowedEffects = vbDropEffectCopy 'Or vbDropEffectMove
        Data.Clear
        'Data.SetData A, MyFormat
        Data.SetData szData, vbCFText
    Else
        AllowedEffects = vbDropEffectNone
    End If
End Sub

The following is the code of the target VC++ application.

COleDropTarget  m_dropTarget;

void COletestView::OnInitialUpdate()
{
        CView::OnInitialUpdate();

        m_dropTarget.Register(this);
        m_pSelection = NULL;

Quote:
}

DROPEFFECT COletestView::OnDragOver(COleDataObject* pDataObject, DWORD
dwKeyState, CPoint point)
{
        UINT nCatseye = ::RegisterClipboardFormat("Catseye_NodeAddress");
        if(pDataObject->IsDataAvailable(nCatseye))
                return DROPEFFECT_COPY;
        else
                return DROPEFFECT_NONE;
        return CView::OnDragOver(pDataObject, dwKeyState, point);

Quote:
}

BOOL COletestView::OnDrop(COleDataObject* pDataObject, DROPEFFECT
dropEffect, CPoint point)
{
        UINT nCatseye = ::RegisterClipboardFormat("Catseye_NodeAddress");

        HGLOBAL hSer;
        if((hSer = pDataObject->GetGlobalData(nCatseye))!=NULL)
        {
                char* lpStr = (char*) GlobalLock(hSer);
                m_szData = lpStr;
                Invalidate();
                GlobalUnlock(hSer);
        }
        return CView::OnDrop(pDataObject, dropEffect, point);

Quote:
}

The GetGlobalData function returns NULL in the Target application.

NOTE: I developed a test target application in VB 5.0 , in that case it
works fine.

Also, If  the target application specifies the dropeffect as
DROPEFFECT_LINK,
How am to specify it in the allowedeffects parameter of the source
application since
there are only three effects namely vbdropeffectcopy,vbdropeffectmove
and vbdropeffectnone.

But for now even DROPEFFECT_COPY doesn't seem to work.

Am I missing anything important??

Thankyou,

Yours Sincerly,
Rajagopalan Anand.
Senior Software Engineer,
Eutech {*filter*}netics,
Singapore



Sat, 27 May 2000 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. ListBox as OLE Drag Source and OLE Drag Target

2. Drag drop from VB4 app to VB3 app ?

3. Drag and drop an email attachment on an VB app

4. drag and drop from vb 5 app to the desktop (active and normal)

5. Drag&Drop: VB to other apps ?

6. Drag and Drop between 2 VB apps: How??

7. Drag/Drop from system to VB App...

8. Drag and drop from a VB app

9. Explorer drag n drop to my app in VB 4.0 Pro

10. Drag and drop between VB apps

11. Drag and Drop between VB Apps ?

12. Drag and Drop between VB apps

 

 
Powered by phpBB® Forum Software