闪光灯实现的基本对话框输入 [英] Basic dialog box input for a strobe light implementation

查看:166
本文介绍了闪光灯实现的基本对话框输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已使用连接到串行端口的继电器开关将摄影闪光灯装置连接到我的电脑。以下代码导致闪光灯以4Hz闪烁10次,闪烁10次:

I have connected a photographic flash unit to my computer using a relay switch connected to the serial port. The following code causes the strobe to flash at 4Hz for 10 flashes:

#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'和'iterations'的值?

How do I implement dialog boxes at the beginning of the program so that the user can input the values of 'freq' and 'iterations'?

推荐答案


  1. Studio,New,Project,
    Visual C ++,Windows窗体
    应用程序。这将给你一个
    GUI,你可以拖放你需要什么
    。如果你没有Visual
    Studio,那么也许你的IDE有
    类似的东西?

  1. Open Visual Studio, New, Project, Visual C++, Windows Forms Application. This will give you a GUI where you can drag and drop what you need. If you don't have Visual Studio then perhaps your IDE has something similar?

数据在命令行。使用任何其他编程语言/框架中创建的GUI使用相应的命令行调用应用程序。

Make this a console app that accepts the data in the command line. Call the app with an appropriate command line from a GUI created in any other programming language/ framework.

使用C#创建GUI并使用P / Invoke调用创建文件;这不是那么难。

Make the GUI in C# and use P/Invoke to call CreateFile; it's not that hard.

Btw,CreateFile / CloseHandle方法真的有效吗?我发现它有点hacky,我不知道这是最好的方法。也许另一个答案或评论也会触及这方面。

Btw, does the CreateFile/CloseHandle approach really work? I find it to be a bit "hacky" and I'm not sure it's the best approach. Perhaps another answer or a comment will touch this aspect as well.

这篇关于闪光灯实现的基本对话框输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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