#PB_Window_ScreenCentered ignores TaskBar Pos & Size
#PB_Window_ScreenCentered ignores TaskBar Pos & Size
#PB_Window_ScreenCentered centers the window on the screen, without taking the taskbars pos & size into count. compare pb windows with inno setup, msi and tons of other apps to see what i mean. it would be nice, if pb windows would match this behavior.
c ya,
nco2k
c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
-
- Enthusiast
- Posts: 469
- Joined: Sun Mar 16, 2008 9:18 am
Re: #PB_Window_ScreenCentered ignores TaskBar Pos & Size
I think it's because it uses the Win32 CW_CENTERED flags, which doesn't take into account the taskbar either. In another post (http://www.purebasic.fr/english/viewtop ... =3&t=31928) it's explained it's probably due to the fact that not all shells (desktops) have a taskbar.
Re: #PB_Window_ScreenCentered ignores TaskBar Pos & Size
huh, where can i find those? cant find anything in google about it.UserOfPure wrote:I think it's because it uses the Win32 CW_CENTERED flags
with SHAppBarMessage_() its pretty easy to get all the infos you need and if there is no taskbar present, or someone uses an alternative shell, just ignore it and use the current/old behavior.. or maybe i misunderstood what you were trying to say.UserOfPure wrote:it's probably due to the fact that not all shells (desktops) have a taskbar.
c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
-
- Enthusiast
- Posts: 469
- Joined: Sun Mar 16, 2008 9:18 am
Re: #PB_Window_ScreenCentered ignores TaskBar Pos & Size
Perhaps CW_CENTERED is undocumented by MSDN? I've read it before though, on Visual Basic sites. It's a secondary flag like CW_USEDEFAULT. Or maybe some Visual Basic user just used a constant named that and I mistook it for a Win32 constant. Not sure now. As for SHAppBarMessage_() that's Windows only, and PureBasic is cross-platform, so it won't be used in the OpenWindow command (judging by past comments from the team).
Re: #PB_Window_ScreenCentered ignores TaskBar Pos & Size
a windows-window should behave like other windows-windows and a linux-window should behave like other linux-windows. so where exactly is the problem? im not requesting anything weird, just the normal windows behavior.UserOfPure wrote:PureBasic is cross-platform, so it won't be used in the OpenWindow command (judging by past comments from the team).

edit: with SystemParametersInfo_(#SPI_GETWORKAREA, ...) its even more easy.. should be something like this:
Code: Select all
EnableExplicit
Procedure CenterWindow(Window)
Protected hWnd = WindowID(Window)
Protected WindowRect.RECT, WindowX, WindowY, WindowWidth, WindowHeight
Protected DesktopRect.RECT, DesktopX, DesktopY, DesktopWidth, DesktopHeight
If GetWindowRect_(hWnd, @WindowRect.RECT)
If SystemParametersInfo_(#SPI_GETWORKAREA, 0, @DesktopRect.RECT, 0)
DesktopX = DesktopRect\left
DesktopY = DesktopRect\top
DesktopWidth = DesktopRect\right - DesktopRect\left
DesktopHeight = DesktopRect\bottom - DesktopRect\top
Else
;DesktopX = 0
;DesktopY = 0
DesktopWidth = GetSystemMetrics_(#SM_CXSCREEN)
DesktopHeight = GetSystemMetrics_(#SM_CYSCREEN)
EndIf
WindowWidth = WindowRect\right - WindowRect\left
WindowX = Int((DesktopWidth - WindowWidth) / 2)
If WindowX < DesktopX
WindowX = DesktopX
Else
WindowX + DesktopX
EndIf
WindowHeight = WindowRect\bottom - WindowRect\top
WindowY = Int((DesktopHeight - WindowHeight) / 2)
If WindowY < DesktopY
WindowY = DesktopY
Else
WindowY + DesktopY
EndIf
MoveWindow_(hWnd, WindowX, WindowY, WindowWidth, WindowHeight, #True)
EndIf
EndProcedure
If OpenWindow(0, 0, 0, 640, 480, "Test", #PB_Window_SystemMenu | #PB_Window_Invisible)
CenterWindow(0)
HideWindow(0, #False)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf : End
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
Re: #PB_Window_ScreenCentered ignores TaskBar Pos & Size
Amusing you are complaining about PureBasic which is behaving correctly! 
#PB_Window_ScreenCentered
#PB_Window_WindowCentered
Do exactly what they are supposed to.
What you are thinking of is Workspace centering.
Inno setup and all those other apps actually roll their own (I haven't checked Inno's source but I'm pretty sure),
there is no WorkareaCentered flag in the Windows API as far as I know,
I'm not sure there even is a DesktopCentered kind of flag.
But... I guess that a custom function that does a work area + window visible (unobscured/not outside screen or desktop) check and move could be interesting.
Just posted a clip/snap window to work area edge if partly outside which might be of interest to you, check out Tips'nTricks:
http://www.purebasic.fr/english/viewtop ... 12&t=40188
Just modify that to also have a WindowClipVisible(window.i,flags.i) and add a optional center flag and you got the best of both worlds handy.

#PB_Window_ScreenCentered
#PB_Window_WindowCentered
Do exactly what they are supposed to.
What you are thinking of is Workspace centering.
Inno setup and all those other apps actually roll their own (I haven't checked Inno's source but I'm pretty sure),
there is no WorkareaCentered flag in the Windows API as far as I know,
I'm not sure there even is a DesktopCentered kind of flag.
But... I guess that a custom function that does a work area + window visible (unobscured/not outside screen or desktop) check and move could be interesting.
Just posted a clip/snap window to work area edge if partly outside which might be of interest to you, check out Tips'nTricks:
http://www.purebasic.fr/english/viewtop ... 12&t=40188
Just modify that to also have a WindowClipVisible(window.i,flags.i) and add a optional center flag and you got the best of both worlds handy.
Re: #PB_Window_ScreenCentered ignores TaskBar Pos & Size
it just doesnt match with other apps, which are doing that since win95 and i seriously dont see any reason, why anyone would want to ignore the taskbar?!
they could also introduce a #PB_Window_WorkAreaCentered and keep #PB_Window_ScreenCentered as it is, but what for??
c ya,
nco2k

they could also introduce a #PB_Window_WorkAreaCentered and keep #PB_Window_ScreenCentered as it is, but what for??
c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
Re: #PB_Window_ScreenCentered ignores TaskBar Pos & Size
Screen centering has it's uses. The taskbar could be set to auto hide (I assume work area changes when this happens or?).
Or set to be on bottom always (allowing other windows on top, but in this case work area is unchanged or?)
What about applications that want to stay under or over the task bar always? Screen centering is a damn quick way to do this,
so wanting to get rid of it seems rather odd if you ask me.
Screen centering of a window is also important in cases where one window is displayed over a full screen window, in which case the work area would not match the fullscreen window,
and in fact the outer size of the fullscreen window is actually larger than the window, screenceterning flag is in that case a very quick way. (windowcentering might work too though).
The screen centering is a Win API flag, why should Fred remove a Windows API feature?
Now, as to screen centering behaving differently on Win, Mac, Linux, that is a OS implementation difference.
A Workarea Centered would be nice, but it would be more than just a flag, it would require Fred to roll his own code to do this as there exist no such window flag (that I know of) on Windows.
I still find it amusing that you are complaining that PureBasic do not support a feature that...do not exist on Windows
Work area centering are custom coded behavior of apps.
Although it is quite possible that C#/.NET/blah. do have such flags, but then again that is a behavior of the language/framework. Win API still do not have such a feature
Then again I could be wrong and there does exist a workarea or desktop center flag, but I have not seen such at all yet in the WinAPI.
Or set to be on bottom always (allowing other windows on top, but in this case work area is unchanged or?)
What about applications that want to stay under or over the task bar always? Screen centering is a damn quick way to do this,
so wanting to get rid of it seems rather odd if you ask me.
Screen centering of a window is also important in cases where one window is displayed over a full screen window, in which case the work area would not match the fullscreen window,
and in fact the outer size of the fullscreen window is actually larger than the window, screenceterning flag is in that case a very quick way. (windowcentering might work too though).
The screen centering is a Win API flag, why should Fred remove a Windows API feature?
Now, as to screen centering behaving differently on Win, Mac, Linux, that is a OS implementation difference.
A Workarea Centered would be nice, but it would be more than just a flag, it would require Fred to roll his own code to do this as there exist no such window flag (that I know of) on Windows.
I still find it amusing that you are complaining that PureBasic do not support a feature that...do not exist on Windows

Work area centering are custom coded behavior of apps.
Although it is quite possible that C#/.NET/blah. do have such flags, but then again that is a behavior of the language/framework. Win API still do not have such a feature

Then again I could be wrong and there does exist a workarea or desktop center flag, but I have not seen such at all yet in the WinAPI.
Re: #PB_Window_ScreenCentered ignores TaskBar Pos & Size
#PB_Window_ScreenCentered is custom aswell.. :roll:Rescator wrote:The screen centering is a Win API flag, why should Fred remove a Windows API feature?
...
I still find it amusing that you are complaining that PureBasic do not support a feature that...do not exist on Windows
Work area centering are custom coded behavior of apps.
c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
-
- Enthusiast
- Posts: 469
- Joined: Sun Mar 16, 2008 9:18 am
Re: #PB_Window_ScreenCentered ignores TaskBar Pos & Size
Not everyone has the taskbar always visible, you know.nco2k wrote:i seriously dont see any reason, why anyone would want to ignore the taskbar?!
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
Re: #PB_Window_ScreenCentered ignores TaskBar Pos & Size
how should it be "custom"?nco2k wrote:#PB_Window_ScreenCentered is custom aswell..
it's a single Flag for an OS-defined style.
just a PB-name for an API-flag.
oh... and have a nice day.
Re: #PB_Window_ScreenCentered ignores TaskBar Pos & Size
@UserOfPure
if the user's taskbar is visible, an app shouldnt ignore it... did you check my code at all? :roll:
@Kaeru Gaman
and whats the api flag called?
c ya,
nco2k
if the user's taskbar is visible, an app shouldnt ignore it... did you check my code at all? :roll:
@Kaeru Gaman
and whats the api flag called?
c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
Re: #PB_Window_ScreenCentered ignores TaskBar Pos & Size
I don't know.
but I know it's a standard property of the window object from the time when I used VisualStudio.
but I know it's a standard property of the window object from the time when I used VisualStudio.
oh... and have a nice day.
Re: #PB_Window_ScreenCentered ignores TaskBar Pos & Size
Actually, nco2k might be right. I can't seem to find a WinAPI flag. Odd. I always had the idea it was simply a constant for a API constant. (looks at Fred and Freak)
Well in that case, all tat is missing is a workarea center flag, no reason to change the behavior of the screen center nor remove it. (would break many apps).
Odd, I could have sworn it was an API behavior. Live and learn I guess...
Well in that case, all tat is missing is a workarea center flag, no reason to change the behavior of the screen center nor remove it. (would break many apps).
Odd, I could have sworn it was an API behavior. Live and learn I guess...