最佳答案:
SetCaretPos,是一种计算机用语,函数功能是将插入标记移动到指定坐标上。
详情介绍
SetCaretPos,是一种计算机用语,函数功能是将插入标记移动到指定坐标上。

- 中文名
- SetCaretPos
- 函数功能
- 将插入标记移动到指定坐标上
- 函数原型
- BOOL SetCaretPos
- 头文件
- Winuser.h;
- 库文件
- user32.lib
SetCaretPos简介
函数功能:该函数将插入标记移动到指定的坐标上。如果拥有该插人标记的窗口是使用CS_OWNDC类样式创建的,那么指定的坐标依据与该窗口相关的设备环境的映射模式而定。
函数原型:BOOL SetCaretPos(int X,int Y);
SetCaretPos参数
X:指定插入标记新的X坐标。
Y:指定插入标记新的Y坐标。
返回值:如果函数执行成功,那么返回值为非零;如果函数执行失败,那么返回值为零。若想获取更多错误信息,请调用GetLastError函数。
备注:函数SetCaretPos不管插入标记是否隐藏都将移动它。系统为每个队列提供一个插入标记。窗口只能对自己拥有的插入标记进行位置的设置。

速查:Windows NT:3.1及以上版本;Windows:95及以上版本;Windows CE:1.0及以上版本:头文件:Winuser.h;库文件:user32.lib。
示例:
HWND hwnd, // window handle
int x; // horizontal coordinate of cursor
int y; // vertical coordinate of cursor
int nWidth; // width of cursor
int nHeight; // height of cursor

char *lpszChar; // pointer to character
case WM_SETFOCUS:
// Create a solid black caret.
CreateCaret(hwnd, (HBITMAP) NULL, nWidth, nHeight); // Adjust the caret position, in client coordinates. SetCaretPos(x, y); // Display the caret. ShowCaret(hwnd);
break;


