vvin/cmd_alpha.go

32 lines
674 B
Go
Raw Normal View History

2019-11-09 22:56:05 -05:00
package main
2019-11-17 23:45:12 -05:00
import (
"errors"
"github.com/shu-go/rog"
)
2019-11-09 22:56:05 -05:00
type alphaCmd struct {
}
func (c alphaCmd) Run(args []string, g globalCmd) error {
if len(args) != 1 {
return errors.New("an argument is required")
}
alpha := toInt(args[0], 255)
2019-11-17 23:45:12 -05:00
if g.Debug {
rog.Printf("alpha = %v -> %v", args[0], alpha)
}
2019-11-09 22:56:05 -05:00
style, _, _ := getWindowLong.Call(uintptr(g.targetHandle), GWL_EXSTYLE)
setWindowLong.Call(uintptr(g.targetHandle), GWL_EXSTYLE, style|WS_EX_LAYERED)
setLayeredWindowAttributes.Call(uintptr(g.targetHandle), 0, uintptr(alpha), LWA_ALPHA)
if alpha == 255 {
setWindowLong.Call(uintptr(g.targetHandle), GWL_EXSTYLE, style&^WS_EX_LAYERED)
}
return nil
}