先生,我愿意为我的应用程序提供一个基本的gui,因为我选择了Win32 API。但我愿意只为GUI使用win32 API,我愿意坚持使用原生C ++的功能。 我创建了一个像这样的输入框,
Sir, I am willing to have a basic gui for my application for that I've chosen Win32 API. But I am willing to use win32 API only for GUI and I am willing to stick the functionality with native C++. I have created an entry box like this,
entry = CreateWindow(L"EDIT", L"USE SOME INPUT HERE", WS_CHILD | WS_BORDER | WS_VISIBLE|ES_NUMBER, 0, 30, 400, 20, hWnd, (HMENU)NULL, hInst, NULL);我愿意将在文本框中输入的值存储到整数变量。
I am willing to store this value entered in the text box to an integer variable.
SendMessage(entry,WM_GETTEXT,sizeof(buffer) / sizeof(buffer[0]),reinterpret_cast<LPARAM>(buffer));上面的代码将输入存储到变量名称缓冲区,即LPWSTR ,我不知道如何将值转换为整数。 谢谢先生您的时间。 我的尝试: 1.添加ES_NUMBER以防止用户输入除整数之外的其他内容。 2.引用了几篇文章互联网尝试stoi,atoi并没有帮助 3.手动尝试typeconversion例如x =(int)* buffer;但这也没有帮助 请帮我这个先生
The above code will store the input to the variable name buffer which is LPWSTR and I don't know how to get the values into an integer. Thank you sir for your time. What I have tried: 1. Added ES_NUMBER to prevent the user entering another thing than integer. 2. Referred several articles in the internet tried stoi, atoi and that doesn't help 3. Tried typeconversion manually e.g x = (int)*buffer; but that didn't help too Kindly help me with this sir
推荐答案你应该使用C函数 _wtoi [ ^ ]。 You should use the C function _wtoi[^].
更多推荐
将值设置为本机C ++变量时出现问题
发布评论