c++ - 尝试在 MFC 上实现 TextBox 错误消息

标签 c++ winapi mfc

我正在使用 MFC。
我正在尝试实现带有错误图标消息的验证文本框。
即:
enter image description here

但是当我点击文本框时,“x”图标消失了。
我在尝试什么:

m_myXIcon->SetWindowPos(&CWnd::wndTopMost, 0, 0, 0, 0,
  SWP_NOMOVE|SWP_NOSIZE);


我该如何解决?
谢谢! :)

最佳答案

您需要确保文本区域不与您的图标重叠。为此,使用 CEdit::SetMargins

CEdit::SetMargins

Call this method to set the left and right margins of this edit control. Syntax

void SetMargins(
   UINT nLeft,
   UINT nRight 
);

Parameters

nLeft

The width of the new left margin, in pixels.

nRight

The width of the new right margin, in pixels.

关于c++ - 尝试在 MFC 上实现 TextBox 错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35549624/

相关文章:

view - 在 MFC 中获取现有但非事件 View

c++ - 模仿MFC的动态基础机制

c++ - 打包的结构没有预期的大小

c++ - 如果成员函数需要多个参数,则使用 mem_fun_ref

windows - SetSecurityInfo 因 PROCESS_TERMINATE 而失败

c++ - 当主 GUI 线程被阻塞时,如何从工作线程创建无模式对话框?

c++ - easy_curl_perform 返回错误 26(写入错误)

c++ - vector 的迭代器---测试结束

ChangeDisplaySettings 成功但不执行任何操作。我如何让它工作?

c++ - 如何优雅地从 COM 错误中恢复?