小编use*_*098的帖子

Drag Drop Win API 32

我正在尝试将ListView项目从我的程序拖放到另一个项目(例如将路径拖到VLC的某个位置,然后播放视频文件).我正在使用CF_HDROP剪贴板格式.CopySelection是将STGMEDIUM hglobal变量设置为DROPFILES结构的原因.

void CopySelection(HWND hwndList, STGMEDIUM &stgmed)
{
    HGLOBAL hMem;
    DROPFILES  *ptr;
    DROPFILES dfiles;
    POINT p;

    // get the selection inside the list control
    int iPos = SendMessage(hwndList, LVM_GETNEXTITEM, (WPARAM)-1,(LPARAM)LVNI_SELECTED);
    cout << "iPos: " << iPos << endl;
    LVITEM item;
    char buffer[256];
    string fileDir = "";
    item.iItem = iPos;
    item.iSubItem = 1;
    item.cchTextMax = 256;
    item.pszText = buffer;
    item.mask = LVIF_TEXT;

    ListView_GetItem(hwndList, &item);
    fileDir += string(item.pszText);
    fileDir += "\\";
    item.iItem = iPos;
    item.iSubItem = 0;

    ListView_GetItem(hwndList, &item);
    fileDir += string(item.pszText); …
Run Code Online (Sandbox Code Playgroud)

c++ api winapi ole

3
推荐指数
1
解决办法
3769
查看次数

标签 统计

api ×1

c++ ×1

ole ×1

winapi ×1