博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
使对话框支持 文件拖放操作
阅读量:3658 次
发布时间:2019-05-21

本文共 755 字,大约阅读时间需要 2 分钟。

///

// 为对话框增加拖放操作支持
1, 对话框.h中(消息映射表中)
    afx_msg void OnDropFiles(HDROP hDropInfo);
2, .cpp中
    ON_WM_DROPFILES()
增加函数,函数实现的功能就看各人需要了.
void CLooklogDlg::OnDropFiles(HDROP hDropInfo)
{
    // TODO: Add your message handler code here and/or call default
    CString filename[1000];//该数组限制了最多只能拖放1000个文件。
    //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    int filecount=DragQueryFile(hDropInfo,0xffffffff,0,0);//取得所拖放的文件数。
    for(int i=0;i<min(filecount, 1000);i++)
    {
        DragQueryFile(hDropInfo,i,filename[i].GetBuffer(512),512);
        filename[i].ReleaseBuffer();
    }
    AfxMessageBox(filename[0]);
 
    //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    CDialog::OnDropFiles(hDropInfo);
}
3, 最后记得在对应对话框的资源属性中, Extended Styles页中, 勾选 Accept Files 的复选框.

OK, 就这么简单的.

 

转自:

转载地址:http://demfn.baihongyu.com/

你可能感兴趣的文章
jquery 给input text元素赋值,js修改表单的值
查看>>
idea 端口被占用
查看>>
layui 获取select option value 获取text
查看>>
springBoot 配置url 访问图片
查看>>
用JQuery获取事件源怎么写
查看>>
intellij idea中去除@Autowired注入对象的红色波浪线提示
查看>>
Spring Cloud 分布式事务管理
查看>>
什么是微服务
查看>>
springCloud分布式事务实战(一)案例需求及实现步骤
查看>>
Springboot配置时间格式
查看>>
mybatis 注解方式插入,主键由uuid函数生成
查看>>
springboot上传文件大小限制的配置
查看>>
springboot 配置访问本地图片
查看>>
springboot 基于@Scheduled注解 实现定时任务
查看>>
Springboot配置拦截器
查看>>
mysql 查询近三个月数据
查看>>
java 获取文本一行一行读
查看>>
SpringBoot启动时的Banner设置
查看>>
Springboot 使用 webSocket
查看>>
springboot 项目中在普通类中调用dao层的mapper 出现空指针异常
查看>>