Developing Windows GUI graphical interface program in NIM language

Source: Internet
Author: User

Objective

This article has been supported by the "teacher",

We debug the program together late at night, without his help,

I don't know how long it will take to cross this road

In addition, "centring" and others have also provided help,

They are all from QQ group: "Nim Development concentration camp" 469329878;

Interested friends, can add this group to discuss together

Configuring the GUI development environment

In this blog, I wrote about the construction of the NIM development environment.

The blog says that MinGW is a must,

This is not a problem for developing a common NIM program, but it is not enough to develop GUI programs

There is a problem with the MinGW installation package contained in the official installation package

If you use the Compile command:--app:gui, compiling your program will make an error

If you do not use this compile command, then when you execute your program, you will open a command-line window and then open your GUI program.

I don't know exactly why it went wrong.

(It is possible that the MinGW installation package is 64-bit, it is possible that the installation package is castrated version)

So we're going to install a mingw ourselves,

NIM official website recommended to the MINGW website to download the 64-bit installation package,

MinGW official website, ask you to install an installation tool, and then install the tool to download the MINGW program you need

(To be honest, that installation tool will make you mess)

I used the "musician" recommendation to my TDM installation tool to install MinGW's

Be aware that you must install the 32-bit MinGW

I'm not exactly sure why the 64-bit MINGGW can't do it.

After installation, you need to configure the environment variables to configure the following paths to the environment variables:

C:\TDM-GCC-32\bin

(Of course, if you put the other path down, it is another matter)

You should then configure the Nim bin path to the environment variable as well:

C:\Nim\bin

So you can use the command line to compile your program.

(You use the Aporia official IDE to compile your program, default is not set --app:gui switch )

Developing GUI Programs

Okay, let's write a program.

# Test a Windows GUI applicationimport windows#proc MessageBox (Hwnd:int, Lptext, Lpcaption:cstring, utype:uint): int# {stdcall, import: "MessageBox", Header: "<windows.h>"}discard MessageBox (0, "Chinese try", "Nimrod GUI Application", 0)

In this program we use the Windows module

Here you can see the api:http://nim-lang.org/docs/windows.html provided by the Windows module

You can also use the IUP module or the GTK module to develop GUI programs

Compiling and executing the program

Then use the following command line to compile the program:

Nim C--app:gui-d:release Wingui.nim

Note:

Nim is the compiler

c is the abbreviation of compile

-app:gui is a switch compiled into a GUI program.

-d:release is release compiler switch

Wingui.nim is the program source file

This line of command must be executed in the directory where the program source files are located

After the command executes, the executable file is generated in the same directory

Run this program and you will find the Chinese garbled:

This is you just change the source file to ANSI or gb2312 code, re-save

And then compile it again, just fine.

Developing Windows GUI graphical interface program in NIM language

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.