将值设置为本机C ++变量时出现问题

编程入门 行业动态 更新时间:2024-10-09 23:14:57
本文介绍了将值设置为本机C ++变量时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

先生,我愿意为我的应用程序提供一个基本的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 ++变量时出现问题

本文发布于:2023-10-31 10:35:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1545827.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:本机   设置为   变量

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!