lxn / walk

A Windows GUI toolkit for the Go Programming Language
Other
6.78k stars 885 forks source link

How to move a frameless window? #767

Open distance00 opened 3 years ago

distance00 commented 3 years ago

I was trying to move a frameless window created by following code I found here. `package main

import ( "github.com/lxn/walk" . "github.com/lxn/walk/declarative" "github.com/lxn/win" )

func main() { var mw *walk.MainWindow

MainWindow{
    AssignTo: &mw,
    Title:    "Title",
    Size:     Size{550, 380},
    Layout:   VBox{},

}.Create()

flag := win.GetWindowLong(mw.Handle(), win.GWL_STYLE)
flag |= win.WS_OVERLAPPED  // always on top
flag &= ^win.WS_BORDER     // no border(min/max/close)
flag &= ^win.WS_THICKFRAME // fixed size
flag &= ^win.WS_CAPTION
win.SetWindowLong(mw.Handle(), win.GWL_STYLE, flag)
mw.Run()

} Here is what I can come up with package main

import ( "github.com/lxn/walk" . "github.com/lxn/walk/declarative" "github.com/lxn/win" )

func main() { var mw *walk.MainWindow

MainWindow{
    AssignTo: &mw,
    Title:    "Title",
    Size:     Size{550, 380},
    Layout:   VBox{},
    OnMouseDown: func() {
        win.SendMessage(mw.Handle(), win.WM_SYSCOMMAND, win.SC_MOVE+win.HTCaption, 0) 
    },

}.Create()

flag := win.GetWindowLong(mw.Handle(), win.GWL_STYLE) flag |= win.WS_OVERLAPPED // always on top flag &= ^win.WS_BORDER // no border(min/max/close) flag &= ^win.WS_THICKFRAME // fixed size flag &= ^win.WS_CAPTION win.SetWindowLong(mw.Handle(), win.GWL_STYLE, flag) mw.Run() }` But turns out Win doesn't have HTCaption, is there any way to do it?

distance00 commented 3 years ago

Cannot use func literal (type func()) as type walk.MouseEventHandler in field value, can't use it on ImageView either.