News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

ImageList_BeginDrag

Started by TNick, March 02, 2007, 02:41:07 PM

Previous topic - Next topic

TNick

Hello!

I was trying to add drag - drop to a treeview and I've found this example in win32.hlp
Quote
// Main_OnBeginDrag - begins dragging an item in a tree-view control.
// hwndTV - handle of the image list
// lpnmtv - address of information about the item being dragged
void Main_OnBeginDrag(HWND hwndTV, NM_TREEVIEW *lpnmtv)
{
    HIMAGELIST himl;    // handle of image list
    RECT rcItem;        // bounding rectangle of item
    DWORD dwLevel;      // heading level of item
    DWORD dwIndent;     // amount that child items are indented

    // Tell the tree-view control to create an image to use

    // for dragging.
    himl = TreeView_CreateDragImage(hwndTV, lpnmtv->itemNew.hItem);

    // Get the bounding rectangle of the item being dragged.
    TreeView_GetItemRect(hwndTV, lpnmtv->itemNew.hItem, &rcItem, TRUE);

    // Get the heading level and the amount that the child items are
    // indented.
    dwLevel = lpnmtv->itemNew.lParam;
    dwIndent = (DWORD) SendMessage(hwndTV, TVM_GETINDENT, 0, 0);

    // Start the drag operation.
    ImageList_BeginDrag(himl, hwndTV, 0,

        lpnmtv->ptDrag.x,
        lpnmtv->ptDrag.y,
        lpnmtv->ptDrag.x - ((dwLevel - 1) * dwIndent),
        lpnmtv->ptDrag.y - rcItem.top);

    // Hide the mouse cursor, and direct mouse input to the
    // parent window.
    ShowCursor(FALSE);
    SetCapture(GetParent(hwndTV));
    g_fDragging = TRUE;
    return;
}

Now, if my understanging of this piece of code is right, ImageList_BeginDrag is called with 7 args, but it's prototype is waiting for only 5.
I tried to use it with 5 args, but the image doesn't appear, just the items are highlited.

Thanks for any help.

Regards,
Nick

TNick

Or, maybe, someone has a working example involving a tree control and a drag-and-drop operation?

Nick

TNick


Tripper

My win32.hlp says the format is:

The ImageList_BeginDrag function begins dragging an image.

BOOL ImageList_BeginDrag(

    HIMAGELIST himlTrack,
    int iTrack,
    int dxHotspot,
    int dyHotspot
   );


Parameters

himlTrack

Handle to the image list.

iTrack

Index of the image to drag.

dxHotspot and dyHotspot

Location of the drag position relative to the upper-left corner of the image.



Return Values

If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero.

Remarks

This function creates a temporary image list that is used for dragging. In response to subsequent WM_MOUSEMOVE messages, you can move the drag image by using the ImageList_DragMove function. To end the drag operation, you can use the ImageList_EndDrag function.


Maybe worth a try :D

sinsi

Here's some stuff from the SDK

[attachment deleted by admin]
Light travels faster than sound, that's why some people seem bright until you hear them.

TNick

Tripper, you are right, they are 4
Sinsi, thanks for that file. I've created a project using the file that you provide, wich is attached. It doesn't work. It looks like TVM_CREATEDRAGIMAGE is failing,but I can't tell why...
Future help would be greatly appreciated!

Nick

[attachment deleted by admin]

akane

TNick, you need first to assign any imagelist to your treeview control.
QuoteRemarks

If you create a tree-view control without an associated image list, you cannot use the TVM_CREATEDRAGIMAGE message to create the image to display during a drag operation
ps. if you posted same question for aurora, an example is waiting but the post is missing :d
sapero.

TNick

Ohohoo, I missed that part. I was under the impression that TreeView_CreateDragImage will create aimage list, too.
Now, I would like an example for aurora, please! :)

Thanks
Nick