You must call SetWindowPos or MoveWindow on your window handle and call SHAppBarMessage with ABM_SETPOS
I had posted a basic sample recently in this thread : C# WinForm Making a TopBar App
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi there!
I'm creating an AppBar in .net MAUI, and I want my app to sit at the top of the screen and reduce the working area. The area used by the AppBar shouldn't be covered by any other window.
I'm using the setWindowPos function(from user32.dll) to resize the working area, but it seems to work only on Windows 11 version 21H2. I also checked in Windows 10 versions 21H2, 22H2, and windows 11 version 22H2(+Patched) but setWindowPos returns false in all of them.
What might be the reason for this behavior? and what can I adjust in my code to make it work on other versions as well?
p.s: GetDesktopWindow and SystemParametersInfo are also from user32.dll
IntPtr desktopWindow = GetDesktopWindow();
var setPos = SetWindowPos(desktopWindow, IntPtr.Zero, 0, _APPBARHEIGHT, 0, 0, (uint) (SetWindowPosFlags.SWP_NOSIZE | SetWindowPosFlags.SWP_NOZORDER));//only in windows 11 v21H2 return true
RECT rect = new RECT();
rect.Left = 0;
rect.Top = _APPBARHEIGHT;
rect.Right = _ScreenWidth;
rect.Bottom = _ScreenHeight - _APPBARHEIGHT;
var sysparam = SystemParametersInfo(0x002F, 0, ref rect, 0x0002);//return true
Thanks!
You must call SetWindowPos or MoveWindow on your window handle and call SHAppBarMessage with ABM_SETPOS
I had posted a basic sample recently in this thread : C# WinForm Making a TopBar App