Raveendra Pai U
Raveendra Pai U

Reputation: 135

Drag and Drop Support for win32 GUI

I've created non-MFC GUI with simple Edit controls and buttons using win32 API. Now i got the requirement to drag and drop the Browser URL into the one of the edit control of my GUI Application, How can i do this ? is Win32 Api support this feature ?

Upvotes: 0

Views: 19392

Answers (4)

Peter
Peter

Reputation: 1275

For other sources to learn more about Drag & Drop features of Win32 here is a link that explains more about it with examples http://anton.maurovic.com/posts/win32-api-approach-to-windows-drag-and-drop/

Maybe you can’t implement drag-and-drop in Windows without some COM code, but Anders Karlsson has a straightforward wrapper that will appeal to C/C++ coders that normally prefer the simple flavour of the Windows (Win32) API.

The goal here is to explain how to do this without the need for COM in your application.

Upvotes: 0

Lex
Lex

Reputation: 319

Yes, of couse Win32 API support Drag-Drop feature. You should see MSDN RegisterDragDrop function.

Upvotes: 1

rohank
rohank

Reputation: 81

COM can be used in following way:

IDropSource interface
Implemented by the object containing the dragged data, referred to as the drag source. The IDropSource interface is one of the interfaces you implement to provide drag-and-drop operations in your application. It contains methods used in any application used as a data source in a drag-and-drop operation. The data source application in a drag-and-drop operation is responsible for:

Determining the data being dragged based on the user's selection. Initiating the drag-and-drop operation based on the user's mouse actions. Generating some of the visual feedback during the drag-and-drop operation, such as setting the cursor and highlighting the data selected for the drag-and-drop operation. Canceling or completing the drag-and-drop operation based on the user's mouse actions. Performing any action on the original data caused by the drop operation, such as deleting the data on a drag move. IDropSource contains the methods for generating visual feedback to the end user and for canceling or completing the drag-and-drop operation. You also need to call the DoDragDrop, RegisterDragDrop, and RevokeDragDrop functions in drag-and-drop operations.

IDropTarget interface
Implemented by the object that is intended to accept the drop, referred to as the drop target.The IDropTarget interface is one of the interfaces you implement to provide drag-and-drop operations in your application. It contains methods used in any application that can be a target for data during a drag-and-drop operation. A drop-target application is responsible for:

Determining the effect of the drop on the target application. Incorporating any valid dropped data when the drop occurs. Communicating target feedback to the source so the source application can provide appropriate visual feedback such as setting the cursor. Implementing drag scrolling. Registering and revoking its application windows as drop targets. The IDropTarget interface contains methods that handle all these responsibilities except registering and revoking the application window as a drop target, for which you must call the RegisterDragDrop and the RevokeDragDrop functions.

DoDragDrop function
Implemented by OLE and used to initiate a drag and drop operation. Once the operation is in progress, it facilitates communication between the drag source and the drop target.


    Carries out an OLE drag and drop operation.

WINOLEAPI DoDragDrop(
  IDataObject * pDataObject,  //Pointer to the data object
  IDropSource * pDropSource,  //Pointer to the source
  DWORD dwOKEffect,           //Effects allowed by the source
  DWORD * pdwEffect           //Pointer to effects on the source
);


Upvotes: 2

Related Questions