在Windows程序中输入简单的值 [英] Simple value input in a Windows program

查看:105
本文介绍了在Windows程序中输入简单的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Win32环境中运行的程序。在程序开始之前,我想设置一个变量。唯一的原因是它是一个Win32程序是因为我正在访问串行端口。我不在乎我如何输入变量 - 它是一个数字,我想一个对话框编辑框将是最好的 - 但我不知道如何去与这个与Win32!

I have a program that runs in the Win32 environment. There is one variable that I would like to set before the program begins. The only reason it is a Win32 program is because I am accessing serial ports. I don't care how I input the variable - it is a number and I suppose a dialog edit box would be best - but I don't know how to go about this with Win32!

忽略大部分程序,我的代码如下:

Ignoring the bulk of the program, my code is as follows:

#include <windows.h>

//Initialise Windows module
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil)

{
 int variable;

 //ACTION USING THE VARIABLE OCCURS HERE

 return 0;
}


推荐答案

不需要Windows应用程序。你可以创建一个简单的基于控制台的应用程序,它将仍然是win32的架构。

To access serial port, you don't need windows application. You can create a simple console based application, it will be a still win32 by architecture.

使用控制台应用程序的优点是,您可以使用C样式scanf或C ++样式cin从用户读取输入。

The advantages being using a console application would that you could use 'C' style scanf or C++ style cin to read the input from user.

对于Windows应用程序,需要创建一个带有文本框的对话框,并显示窗口并等待用户输入,让用户按下确定按钮或输入..

For the windows application, you need to create a dialog with text box in it and Show the window and wait for user to input, let user to press a 'OK' button or enter.. thats a lot of process..

只是写一个控制台应用程序..这样做..否则使用MFC ..

Just write a console application.. That will do.. Otherwise use MFC..

这篇关于在Windows程序中输入简单的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆