如何在视觉C++中编写"if textbox is empty"

How to write "if textbox is empty" in Visual C++

本文关键字:if textbox is empty 视觉 C++      更新时间:2023-10-16

我正在用Visual C++编写一个程序,我需要测试文本框是否为空。例如(在伪代码中):

if ( textBox is empty ) { 
   // etc..
}

如何测试这种情况?

if(string.isNullOrEmpty(textbox.text)){//Your code Here}

大概是这样的。

如果你是直接做Win32,那么它是这样的:

if ( SendMessage( hWndTextBox, WM_GETTEXTLENGTH, 0, 0 ) == 0 )
{
}

如果是 MFC,则:

if ( textBox.GetWindowTextLength() == 0 )
{
}