File tree Expand file tree Collapse file tree 2 files changed +32
-21
lines changed
Expand file tree Collapse file tree 2 files changed +32
-21
lines changed Original file line number Diff line number Diff line change @@ -5,10 +5,6 @@ on: [push, pull_request]
55jobs :
66 build :
77 runs-on : windows-latest
8- env :
9- CGO_ENABLED : 0
10- GOOS : windows
11- GOARCH : amd64
128
139 steps :
1410
@@ -39,14 +35,12 @@ jobs:
3935 cd examples/simple;
4036 windres -i emptyProject/Debug/resource.res -O coff -o vsui.syso;
4137 go build -ldflags="-s -w -H windowsgui"
42- - name : Install go-winres
43- run : go install github.com/tc-hib/go-winres@latest
38+
4439# 取消 winres调用。 生成的资源文件会变成乱码,暂时不知道如果解决。 发布 wowjump release之前需要手动生成 ui.syso.
4540# windres -i ui/ui.rc -O coff -o ui.syso;
4641 - name : check wowjump
4742 run :
4843 cd examples/wowjump;
49- go-winres make --in ui/ui.rc --out ui.syso --arch amd64;
5044 go generate;
5145 go build -ldflags="-s -w -H windowsgui"
5246
Original file line number Diff line number Diff line change @@ -46,6 +46,35 @@ Don't use `go run main.go`, because golang can't load x.syso files.
4646*/
4747package wingui
4848
49+ /*
50+ #include <windows.h>
51+
52+ HWND dlg;
53+
54+ // Message Loop
55+ void MessageLoop(){
56+ MSG msg;
57+ while (GetMessage(&msg, NULL, 0, 0))
58+ {
59+ if(dlg){
60+ if(!IsDialogMessage(dlg, &msg))
61+ {
62+ TranslateMessage(&msg);
63+ DispatchMessage(&msg);
64+ }
65+ }else{
66+ TranslateMessage(&msg);
67+ DispatchMessage(&msg);
68+ }
69+ }
70+
71+ }
72+
73+ void SetCurrentDialog(long long int h){
74+ dlg = (HWND)h;
75+ }
76+ */
77+ import "C"
4978import (
5079 "github.com/lxn/win"
5180 "log"
@@ -70,25 +99,13 @@ func InitHInstance(lpModuleName string) {
7099 log .Println ("hInstance" , hInstance )
71100}
72101
73- var dlg win.HWND
74-
75102// MessageLoop start windows message loop.
76103func MessageLoop () {
77- // message loop
78- var msg win.MSG
79- for win .GetMessage (& msg , 0 , 0 , 0 ) > 0 {
80- if dlg > 0 {
81- if win .IsDialogMessage (dlg , & msg ) {
82- continue
83- }
84- }
85- win .TranslateMessage (& msg )
86- win .DispatchMessage (& msg )
87- }
104+ C .MessageLoop ()
88105}
89106
90107// SetCurrentDialog make sure Message Loop could process dialog msg correct,such as Tabstop msg.
91108// This is a optional method.
92109func SetCurrentDialog (h win.HWND ) {
93- dlg = h
110+ C . SetCurrentDialog ( C . longlong ( uintptr ( h )))
94111}
You can’t perform that action at this time.
0 commit comments