如何在mfc中使用剪贴板 [英] how to use clipboard in mfc

查看:90
本文介绍了如何在mfc中使用剪贴板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PLZ帮助我....



你好亲爱的解决了错误



错误C2440:' < function-style-cast>':无法从'CString'转换为'LPCSTR'



我的代码:

plz help me ....

hello dear solved error

error C2440: '<function-style-cast>' : cannot convert from 'CString' to 'LPCSTR'

my code:

char * pchData;
strcpy(pchData, LPCSTR(strData));

推荐答案

您无法将CString复制到字符串指针。从你得到的rror消息,我假设strData是CString类型。如果由于某种原因你需要一个指向以空字符结尾的字符串的指针,你可以要求CString对象通过简单地写出来给你这样的指针

You cannot copy a CString to a string pointer. From the rror message you got, I assume that strData is of type CString. If for whatever reason you need a pointer to a nul-terminated string you can ask the CString object to give you such a pointer by simply writing
const char* pchData = strData;



但是,只要CString对象存在,这个指针就不好了。


Not however that this pointer is only good as long the CString object lives.


你可以使用 CT2A 宏,请参阅 ATL和MFC字符串转换宏 [ ^ ](请仔细阅读文档)。
You might use the CT2A macro, see ATL and MFC String Conversion Macros[^] (please, read carefully the documentation).


这篇关于如何在mfc中使用剪贴板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆