Hi, all.
I want my program act as an drag source and do drag and drop asynchronously.
So, I created a class CDataObject which implements interfaces IDataObject and IAsyncOperation .
To begin drag and drop, I wrote the following code:
CDataObject* pDataObj = new CDataObject(... );
if (pDataObj)
{
OleFlushClipboa rd();
HRESULT hr = pDataObj->QueryInterface (IID_IDataObjec t,(LPVOID*)&m_p MyDataObj);
pDataObj->Release();
if (SUCCEEDED(hr) && m_pMyDataObj){
HRESULT hr = pDataObj->QueryInterface (IID_IAsyncOper ation,(LPVOID*) &m_pAsyncOp) ;
if(SUCCEEDED(hr )){
m_pAsyncOp->SetAsyncMode(V ARIANT_TRUE);
IDropSource *pDropSrc = (IDropSource *) new CDropSource;
DWORD dwEffect = 0;
DoDragDrop(m_pM yDataObj,
pDropSrc,
DROPEFFECT_COPY | DROPEFFECT_MOVE ,
&dwEffect);
m_pMyDataObj->Release();
pDropSrc->Release();
...
}
}
}
According to MSDN, if AsyncMode is set to VARIANT_TRUE, The drop target (In my program, the only possible target
is Windows explorer) will do drag and drop asynchronously.
Yet, although I set this flag, windows always do drag and drop in the same thread as the UI of my program.
What's wrong with my code? Can any one help me?
Thank you very much!
p.s. I can not understand this line in MSDN, section IAsyncOperation ::SetAsyncMode, is this the key problem?
If fDoOpAsync is set to VARIANT_TRUE, SetAsyncMode must call IAsyncOperation ::AddRef,
and store the interface pointer for use by IAsyncOperation ::EndOperation. 6 4806
Wei Junping, According to MSDN, if AsyncMode is set to VARIANT_TRUE, The drop target (In my program, the only possible target is Windows explorer) will do drag and drop asynchronously.
I think MSDN says something else. MSDN says that if AsyncMode is set to
VARIANT_TRUE, then the drop target has the *option* of performing data
transfer asychronously. The drop target is not *required* to perform
data transfer asynchronously.
Yet, although I set this flag, windows always do drag and drop in the same thread as the UI of my program. What's wrong with my code?
I think there is nothing wrong with your code. "Asynchrono us" does not
necessarily mean: "in another thread". It just means that DoDragDrop
does not wait for the data transfer to finish before returning. In any
case, DoDragDrop does not return before the mouse button is released. p.s. I can not understand this line in MSDN, section IAsyncOperation ::SetAsyncMode, is this the key problem?
If fDoOpAsync is set to VARIANT_TRUE, SetAsyncMode must call IAsyncOperation ::AddRef, and store the interface pointer for use by IAsyncOperation ::EndOperation.
I do not understand this either, but I do not think it is essential.
Greetings
Bart Jacobs
Thank you very much.
But how can I do drag and drop in a new thread?
Wei Junping wrote: Thank you very much. But how can I do drag and drop in a new thread?
What do you mean?
Do you want to call DoDragDrop in a thread that is different from the
thread that receives the mouse button down message? That would not make
sense, I think.
Or do you want to handle incoming IDataObject calls in a different
thread? I don't know how to achieve that. But I think in most scenarios
it is possible to handle each such incoming call in such a short amount
of time that the responsiveness of the user interface is not impaired.
Or something else?
I want to handle incoming IDataObject calls in a different thread.
Because In my program, I need to download many files from a remote computer via bluetooth.
Thank you!
COM delivers calls to an object in the apartment in which the object is
created. If the object is created in a single-threaded apartment (such
as the OLE GUI thread in which you call DoDragDrop), then calls are
dispatched on that thread, which is not what you want for your
CDataObject instance. Therefore, create the CDataObject on another
thread and marshal the interface pointer to the GUI thread, so that you
can pass it to DoDragDrop.
I wonder how well drop targets, such as Windows Explorer, cope with
IDataObject calls that take a very long time. Perhaps a better design
would be to offer a separate command in your application to "download"
the file, and to allow only completely downloaded files to be dragged
and dropped. Note that Internet Explorer also does not allow one to
drag-and-drop a remote file directly, and this does not seem to have
been fatal to its acceptance :-)
I follow your suggestion
Yet, DoDragDrop doesn't return until the transfer finishes(I do the tranfer in CDataObject::Ge tData) even if I have set asyncmode to VARINT_TRUE
What's wrong with it
Can you give me some sample code
Thank you very much! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Lauren Quantrell |
last post by:
I'm trying to drop a file from Windows Explorer (or desktop, etc.)
onto a field in Access2K and capture the full file path.
I found an posting below that says this is possible but I cannot
simutate it.
Can anyone help?
Thanks
**************************
previous post:
Message 1 in thread
|
by: SamSpade |
last post by:
There seems to be two ways to put things on the clipboard ( I don't mean
different formats): SetClipboardData and OleSetClipboard
If I want to get data off the clipboard do I care how it was put there?
What about Drag/Drop; is there more than one way for the source to make data
available
Is it always OLE?
|
by: Ajay Krishnan Thampi |
last post by:
I have a slight problem implementing 'drag and drop' from a datagrid
to a tree-view. I have pasted my code below. Someone please advice me
on what to do...pretty blur right now.
==code==
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
|
by: jojobar |
last post by:
Hello,
I look at the asp.net 2.0 web parts tutorial on the asp.net web site. I
tried to run it under firefox browser but it did not run.
If I want to use this feature in a commercial product where the user can run
on firefox/mozilla, what would be a good approach.
1. Should I overwrite the javascript code drag-and-drop to make it more
browser independent. If I want to go this route, can anybody provide me a
|
by: VB Programmer |
last post by:
In VB.NET 2005 (winform) any sample code to drag & drop items between 2
listboxes? Thanks!
| |
by: Rajiv Gupta |
last post by:
Hi,
We are using Web Parts in ASP.NET 2.0 and also use there drag and drop
feature extensively. The issue we are unable to resolve is that we need
to avoid is that when a drag and drop happens or any other event in Web
part (edit etc.) the whole .aspx page postbacks. We need to avoid this
postback and use it ajax or asynchronous implementation. we have tried
too much on goolge and every where but are unable to get any solution
for this.
|
by: Darren |
last post by:
I'm trying to create a file using drag and drop.
I want to be able to select a listview item drag it to the shell and create a file.
Each icon in the listview represents a blob in a database.
When I drop onto the shell I want a file created with a specified name containing the data from the database.
I've looked at the FileDrop format but it look to have only the filename and not the data.
TIA
|
by: Romulo NF |
last post by:
Greetings,
I´m back here to show the new version of the drag & drop table columns (original script ). I´ve found some issues with the old script, specially when trying to use 2 tables with drag&drop on the same page (which was not possible). Now i´ve a new concept of the script, more object oriented.
I´ve also commented the whole code so you guys can easier understand it engine.
What exactly we need when trying to make a column drag &...
|
by: Tom Bean |
last post by:
I wrote an C# application that uses drag and drop to copy the contents of
one ListViewItem to another. I call DoDragDrop() in the ItemDrag event
handler, however, the ItemDrag event is being fired when an item in the
ListView is clicked to select it instead of being fired when the item is
dragged.
This is causing a problem when users click on an item and move the moue
(after the mouse button has been released) because the app tries to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |