My Go Language learning Tour six: Make a win simple pop-up window

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed. As a win enthusiasts, I have to say, usually after learning a new language I will be very eager to make a pop-up window to test the language in the win form effect, here not much to say, first on the code.
Package Mainimport ("Github.com/lxn/go-winapi" "Syscall" "StrConv") Func _text (_str string) *uint16{return syscall. Stringtoutf16ptr (_STR)}func _tostring (_n int32) String{return StrConv. Itoa (int (_n))}func main () {var hwnd winapi. Hwndcxscreen: = WINAPI. GetSystemMetrics (WINAPI. Sm_cxscreen) Cyscreen: = WinAPI. GetSystemMetrics (WINAPI. Sm_cyscreen) WINAPI. MessageBox (Hwnd,_text ("Hello everyone, my screen width is:" + _tostring (cxscreen) + "height is:" + _tostring (cyscreen)), _text ("Golang window Test"), WinAPI. MB_OK)}
Remember the format mentioned before, it is no longer described here, focus on my writing this effect encountered problems and solutions
Import ("Github.com/lxn/go-winapi" "Syscall" "StrConv")
When using import, here is the introduction of the GO-WINAPI package, it is obvious that the default installation go in case this package is not, so we need to get this package, get the way, you can directly use go get github.com/lxn/ Go-winapi gets this package and installs it automatically for you under the GO environment you configured, but the installation might prompt you for a bug that git can't find, the workaround is to install this Git program, not here, because I'm useless, I used another way to open this URL directly   Github.com/lxn/go-winapi then download the compressed package, and then come back to your own Src/pkg/github.com/lxn/go-weinapi directory to extract it, of course, not necessarily this directory, if you change this directory, Please import the path you have changed when importing. What's more, it's worth noting that when you need a function in a package, but don't know what to do or how to use it, please go directly to this package to see, there are corresponding files, a little bit of English can be.
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.