名字不能取太长 2022-02-21 13:16 采纳率: 78%
浏览 30
已结题

DrawText绘制的文本框出现了奇怪字符

img


代码如上图,请问下图啦字后面那一坨奇怪字符是怎么回事?如何解决?

img

  • 写回答

1条回答 默认 最新

  • 赵4老师 2022-02-21 13:41
    关注

    sizeof(buf)
    应改为
    wcslen(buf)

    5

    -1

    DrawText
    The DrawText function draws formatted text in the specified rectangle. It formats the text according to the specified method (expanding tabs, justifying characters, breaking lines, and so forth).

    int DrawText(
    HDC hDC, // handle to device context
    LPCTSTR lpString, // pointer to string to draw
    int nCount, // string length, in characters
    LPRECT lpRect, // pointer to struct with formatting dimensions
    UINT uFormat // text-drawing flags
    );

    Parameters
    hDC
    Handle to the device context.
    lpString
    Pointer to the string to be drawn. If the nCount parameter is –1, the string must be null-terminated.
    If uFormat includes DT_MODIFYSTRING, the function could add up to four additional characters to this string. The buffer containing the string should be large enough to accommodate these extra characters.

    nCount
    Specifies the number of characters in the string. If nCount is –1, then the lpString parameter is assumed to be a pointer to a null-terminated string and DrawText computes the character count automatically.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 2月22日
  • 已采纳回答 2月21日
  • 创建了问题 2月21日

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度