向窗口句柄发送字符串
来源:互联网 发布:矩阵的三种范数怎么求 编辑:程序博客网 时间:2024/05/17 22:55
用剪贴板进行粘贴和复制unicode 字符串
包括汉字.
HLOCAL LocalAlloc(
UINT uFlags,
UINT uBytes
);
This function allocates the specified number of bytes from the heap. In the linear Microsoft® Windows® CE application
programming interface (API) environment, there is no difference between the local heap and the global heap.
#include <wceatl.h>
#define GlobalAlloc LocalAlloc
LPVOID GlobalLock(
HGLOBAL hMem // handle to global memory object
);
The GlobalLock function locks a global memory object and returns a pointer to the first byte of the object's memory
block.
Note The global functions are slower than other memory management functions and do not provide as many features.
Therefore, new applications should use the heap functions. However, the global functions are still used with DDE and the
clipboard functions.
BOOL GlobalUnlock(
HGLOBAL hMem // handle to global memory object
);
The GlobalUnlock function decrements the lock count associated with a memory object that was allocated with
GMEM_MOVEABLE. This function has no effect on memory objects allocated with GMEM_FIXED.
Note The global functions are slower than other memory management functions and do not provide as many features.
Therefore, new applications should use the heap functions. However, the global functions are still used with DDE and the
clipboard functions.
//wxg add 2007 -8-30
BOOL CopyAndPaste( LPTSTR pstr)
{
HGLOBAL hglbCopy;
LPTSTR lpstrCopy= NULL;
if (!OpenClipboard(g_hwndTran))
return 0L ;
EmptyClipboard();
// Allocate a global memory object for the text.
hglbCopy = GlobalAlloc(GMEM_MOVEABLE, wcslen(pstr)*2+2);
if (hglbCopy == NULL)
{
CloseClipboard();
return 0L ;
}
lpstrCopy = (LPTSTR)GlobalLock(hglbCopy);
memset(lpstrCopy,0,wcslen(pstr)*2+2);
memcpy(lpstrCopy, pstr, wcslen(pstr)*2);
*(lpstrCopy+wcslen(pstr)*2)=_T('/0');
*(lpstrCopy+wcslen(pstr)*2+1)=_T('/0');
GlobalUnlock(hglbCopy);
// Place the handle on the clipboard.
SetClipboardData(CF_UNICODETEXT, hglbCopy);
CloseClipboard();
//SetFocus(g_hwndTran);
::SendMessage(g_hwndTran, WM_PASTE, 0, 0);
GlobalFree(hglbCopy);
memset(lpstrCopy,0,wcslen(pstr)*2+2);
return TRUE;
}
Best Regards To All!
- 向窗口句柄发送字符串
- 向目标窗口发送字符串消息
- 向窗口发送消息
- 在java程序中如何能获取到另一个程序的windows句柄,又如何使用这个句柄向这个窗口发送消息
- 向指定窗口发送消息
- 如何向窗口发送消息
- 子窗口向父窗口发送消息
- 子窗口向父窗口发送消息
- 子窗口向父窗口发送消息
- 向指定HWND发送字符串
- VB实现向窗口发送按键消息
- Delphi向QQ2011窗口发送登录消息
- 使用C# 向记事本窗口发送消息
- MFC 向指定窗口发送自定义消息
- MFC 向指定窗口发送自定义消息
- 向CMD窗口发送CTRL+C
- WPF向指定窗口发送键盘指令
- MFC 向指定窗口发送自定义消息
- C语言中static用法介绍
- 如何在ASP.NET 2.0中使用Web Parts
- Log4j日志管理系统简单使用说明
- PHP获得字符串的宽度(像素px)
- Log4j源代码阅读—Logger创建
- 向窗口句柄发送字符串
- ASP.NET 2.0中使用webpart系列控件
- C#如何查找ArrayList 中的某个数据?(附解决方案及源码)
- 如何实现一个循环缓冲区模型
- 路由与交换机的备份
- 在ASP.NET中实现Url Rewriting
- ASP.NET构架与安全机制之Http请求处理
- 数码管显示
- Oracle中SQLPLUS 常用指令收集与技巧