注册 登录
编程论坛 C++教室

C++输入框

m3440426898 发布于 2022-07-04 19:45, 1507 次点击
各位大佬:
    请问C++中如何出现一个输入对话框,MessageBox只能输出信息,该如何让用户输入信息,最简洁的方法,和MessageBox的界面差不多的那种。
4 回复
#2
apull2022-07-05 10:11
EasyX中有
bool InputBox(LPTSTR pString, int nMaxCount, LPCTSTR pPrompt = NULL, LPCTSTR pTitle = NULL, LPCTSTR pDefault = NULL, int width = 0, int height = 0, bool bOnlyOK = true);
#3
m34404268982022-07-05 15:40
回复 2楼 apull
能不能给个具体示例呀,参数都不会填。
#4
apull2022-07-05 17:11
程序代码:

#include <iostream>
#include <graphics.h>
#include <windows.h>
using namespace std;
int main()
{
    // 初始化绘图窗口
    initgraph(640, 480);

    // 定义字符串缓冲区,并接收用户输入
    WCHAR s[10];
    WCHAR p[20] = L"请输入数字";
    InputBox((LPTSTR)s, 10, (LPCTSTR)p);

    wcout << s << endl;

    closegraph();

    system("pause");
    return 0;
}
#5
m34404268982022-07-05 20:24
回复 4楼 apull
谢谢,谢谢!
1