使用 OpenCOBOL 进行 Windows GUI 编程?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/845461/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Windows GUI Programming with OpenCOBOL?
提问by David Brown
I'm completely new to COBOL, but I'd like to take a look at the different options for GUI programming on Windows. I don't really like Tcl/Tk, though. Is there some resource for developing a Windows GUIin COBOL in the same manner that one would develop a GUI in C?
我对 COBOL 完全陌生,但我想看看 Windows 上 GUI 编程的不同选项。不过,我不太喜欢 Tcl/Tk。是否有一些资源可以以与在 C 中开发 GUI 相同的方式在 COBOL 中开发Windows GUI?
Thanks!
谢谢!
采纳答案by kloucks
回答by tonyriddle
I used MicroFocus version 2.0 and it supported creating Windows GUI forms with an event driven model. They are now on version 5.1. Although the full version is quite expensive, there is a book with a stripped down learning version here:
我使用了 MicroFocus 2.0 版,它支持使用事件驱动模型创建 Windows GUI 表单。它们现在是 5.1 版。虽然完整版很贵,但这里有一本书有精简版的学习版:
回答by Brian Tiffin
For OpenCOBOL, there is an embedded Tcl/Tk layer by Rildo Pragana (author of TinyCOBOL, his TC Tcl/Tk sample compiled and linked for OpenCOBOL, first try), but if you don't like Tcl/Tk, his toolkit places almost all of the GUI on the Tk side, so:
对于 OpenCOBOL,Rildo Pragana 有一个嵌入式 Tcl/Tk 层(TinyCOBOL 的作者,他为 OpenCOBOL 编译和链接的 TC Tcl/Tk 示例,第一次尝试),但如果你不喜欢 Tcl/Tk,他的工具包几乎放在Tk 端的所有 GUI,所以:
- There is also a GTK+ layer sample
- 还有一个 GTK+ 层示例
Source code looking like:
源代码看起来像:
*> Add a text entry field
CALL "CBL_OC_GTK_ENTRY_NEW"
returning gtk-textentry
END-CALL
*> Connect code to the text entry, passing the entry widget
SET callback TO ENTRY "CBL_OC_activate"
CALL "CBL_OC_G_SIGNAL_CONNECT"
using by value gtk-textentry
by reference "activate" & x"00"
by value callback
by value gtk-textentry
END-CALL
...
*> window is ready to show
CALL "CBL_OC_GTK_WIDGET_SHOW"
using by value gtk-window
END-CALL
*> Start up the event loop, control returned when GTK main exits
CALL "CBL_OC_GTK_MAIN" END-CALL
*> Something terminated the GTK main loop, sys-close or bye or
display "ending..." end-display
- FLTK worked, but I haven't posted the trial source codes.
- GtkHTML widgets worked too.
- A Gambas COBOL GUI layer is hosted on Google Code
- ROOT/CINT can interpret OpenCOBOL generated C, and then you can get interactive graphs from WORKING-STORAGE.
- Qt tested fine, but C++ requires more, albeit thin, wrapper source, so GTK was targeted instead.
- FLTK 有效,但我还没有发布试用源代码。
- GtkHTML 小部件也有效。
- Gambas COBOL GUI 层托管在 Google Code 上
- ROOT/CINT 可以解释 OpenCOBOL 生成的 C,然后您可以从 WORKING-STORAGE 获得交互式图形。
- Qt 测试良好,但 C++ 需要更多(尽管很薄)包装源,因此改为针对 GTK。
Pretty much anything that can be wrapped by C, can be called by OpenCOBOL. That includes the native Microsoft WinAPI.
几乎任何可以被 C 包装的东西,都可以被 OpenCOBOL 调用。这包括本机 Microsoft WinAPI。
While working on the FAQ I found that using Vala really opens up the field for extending COBOL. As both OpenCOBOL and Vala produce intermediate C, the mixing potential is nearly unlimited, and developers can benefit from efforts by either project. I recommend checking out Vala for use from COBOL.
在处理 FAQ 时,我发现使用 Vala 确实为扩展 COBOL 开辟了领域。由于 OpenCOBOL 和 Vala 都生成中间 C,因此混合潜力几乎是无限的,开发人员可以从任一项目的努力中受益。我建议从 COBOL 中查看 Vala 以供使用。
See the OpenCOBOL FAQ, section 5 for working samples. Screen capture image from source code listed at http://opencobol.add1tocobol.com/#does-opencobol-support-the-gimp-toolkit-gtk
有关工作示例,请参阅 OpenCOBOL 常见问题解答的第 5 部分。来自http://opencobol.add1tocobol.com/#does-opencobol-support-the-gimp-toolkit-gtk 中列出的源代码的屏幕截图