walk
walk copied to clipboard
How create a fixed window, no min/max/close, always on top?
Hello, i want to create a window fixed, with out minimize, maximize and close button, and always on top, and i can't do it with walk :(
Hi!
Right now your only option is using Dialog
instead of MainWindow
.
...
Dialog{
FixedSize: true,
}
...
If you need this on MainWindow, I will look into adding it there.
For me it would be useful to have it on the MainWindow and it would be great to set the position of the window as well.
This seems to be related: https://github.com/lxn/walk/issues/626
@lxn I stumbled upon this issue because I was searching for a way to remove the minimize/maximize/close icons on my window (creating a nagging screen like I intend to doesn't make sense when the user can put it into the background so easily). I made two attempts:
- added the
FixedSize
mentioned by you - tried to mimic the approach known from the linked issue and did
SetWinPos
ondlg.Handle()
but this fails because I can't replaceRun
withCreate
and thus am unable to modify the running dialog
But both didn't have the desired effect: the dialog still is missing the icons but it isn't topmost (only topmost relative to its mother MainWindow)
My next approach would be to make the MainWindow topmost, then I would (perhaps ?) have a topmost window with a dependant Dialog, but what I am searching for would be a single element (either MainWindow or Dialog) that has no unwanted icons and is topmost.
Can this be done with walk ?
You can use
MainWindow{
AssignTo: &mainWindow,
...
}.Create()
flag := win.GetWindowLong(mainWindow.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
win.SetWindowLong(mainWindow.Handle(), win.GWL_STYLE, flag)
mainWindow.Run()
@jqjiang819 : Does that also work for dialogs started in some process (vscode -> git -> githook), and switching in Windows to another window, lets say chrome? Aparrently that does not work.
Also win.SetForegroundWindow(mainWindow.Handle())
does not work..
ok the following worked:
win.SetWindowPos(dlg.Handle(),
win.HWND_TOPMOST, 0, 0, 0, 0,
win.SWP_NOACTIVATE|win.SWP_NOMOVE|win.SWP_NOSIZE)
but this is a bit to invasive...