闪光灯实现的基本对话框输入
Basic dialog box input for a strobe light implementation
我已经使用连接到串行端口的继电器开关将一个摄影闪光灯连接到我的计算机。以下代码导致闪光灯以4Hz闪烁10次:
#include <windows.h>
//Initialise Windows module
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil)
{
//Define the serial port precedure
HANDLE hSerial;
int freq = 4;
int iterations = 10;
int x;
for ( x = 0; x < iterations; x++)
{
//Fire the flash (open the serial port, and immediately close it)
hSerial = CreateFile("COM1",GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
CloseHandle(hSerial);
//Sleep in between flashes for specified duration
Sleep (1000/freq);
}
return 0;
}
如何在程序开始时实现对话框,以便用户可以输入"freq"answers"迭代"的值?
-
打开Visual Studio,新建,项目,Visual C++、Windows窗体应用这会给你一个GUI,您可以在其中拖放你需要。如果您没有VisualStudio也许你的IDE类似的东西?
-
让它成为一个控制台应用程序,在命令行中接受数据。从以任何其他编程语言/框架创建的GUI中使用适当的命令行调用应用程序。
-
在C#中制作GUI,并使用p/Invoke调用CreateFile;没那么难。
顺便说一句,CreateFile/CloseHandle方法真的有效吗?我觉得这有点"古怪",我不确定这是最好的方法。也许另一个答案或评论也会触及这一方面。
相关文章:
- 如何在Qbutton的帮助下更改Q对话框的宽度
- 当对话框被接受时,如何用参数调用槽
- WinAPI 在单击第一个对话框上的按钮控件并销毁第一个对话框后创建第二个对话框
- 如何多次询问来自QML对话框的输入?
- 选择文件对话框错误
- 自定义对话框(源自QDialog)不会关闭(Android)
- 如何在 MFC 对话框中使用 OnDraw
- 在C++中创建文件夹选取器对话框的最简单方法是什么?
- 从资源视图访问对话框时出现问题
- 如何检测窗口当前是否正在运行模式对话框?
- "最小化"按钮不会出现在 MFC 对话框中
- 如何获取QNetworkConfiguration UserChoice对话框?
- 表单显示对话框函数错误,并且不执行下面的语句
- 如何在 VC6 中的对话框中将图标设置为按钮
- 如何在主窗口标签的对话框中显示QLineEdit的输入
- q输入对话框使 Unity 任务栏和标题栏在全屏应用程序中可见
- 自定义运行对话框输入
- 处理对话框上的键盘输入 - Windows
- 闪光灯实现的基本对话框输入
- 在程序中稍后传递一个双精度-使用对话框进行输入