github.com/as/shiny@v0.8.2/driver/win32/lifecycle.go (about) 1 // +build windows 2 3 package win32 4 5 import ( 6 "fmt" 7 "syscall" 8 9 "github.com/as/shiny/event/lifecycle" 10 ) 11 12 type Lifecycle = lifecycle.Event 13 14 var LifecycleEvent func(hwnd syscall.Handle, e lifecycle.Stage) 15 16 func sendFocus(h syscall.Handle, msg uint32, wp, lp uintptr) (res uintptr) { 17 switch msg { 18 case WmSetfocus: 19 LifecycleEvent(h, lifecycle.StageFocused) 20 case WmKillfocus: 21 LifecycleEvent(h, lifecycle.StageVisible) 22 default: 23 panic(fmt.Sprintf("unexpected focus message: %d", msg)) 24 } 25 return DefWindowProc(h, msg, wp, lp) 26 } 27 28 func sendClose(hwnd syscall.Handle, uMsg uint32, wParam, lParam uintptr) (lResult uintptr) { 29 LifecycleEvent(hwnd, lifecycle.StageDead) 30 return 0 31 } 32 33 func sendShow(hwnd syscall.Handle, uMsg uint32, wParam, lParam uintptr) (lResult uintptr) { 34 LifecycleEvent(hwnd, lifecycle.StageVisible) 35 ShowWindow(hwnd, SwShowdefault) 36 sendSize(hwnd) 37 return 0 38 }