walk icon indicating copy to clipboard operation
walk copied to clipboard

How create a fixed window, no min/max/close, always on top?

Open jonathanhecl opened this issue 6 years ago • 6 comments

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 :(

jonathanhecl avatar Jul 16 '18 02:07 jonathanhecl

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.

lxn avatar Aug 01 '18 15:08 lxn

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.

degola avatar Sep 04 '18 09:09 degola

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 on dlg.Handle()but this fails because I can't replace Run with Create 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 ?

mar1ged avatar Oct 03 '19 19:10 mar1ged

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 avatar Mar 26 '20 06:03 jqjiang819

@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..

gabyx avatar Jan 15 '22 10:01 gabyx

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...

gabyx avatar Jan 15 '22 11:01 gabyx