Hi Fred
PureBasic is not the newest invention on the marked. Sadly, there is still no way to achieve a proper PB-native frame-measure-return when it comes to resizing windows or centering them using desktopHeight (*desktop) and desktopWidth (*desktop).
Correct centering without using API-functions is impossible when not init-applied to the window on openWindow function.
// HideWindow and windowWidth/windowHeight do
[solved] centerWindow (*window) or getFrameSize (*window)
[solved] centerWindow (*window) or getFrameSize (*window)
Last edited by es_91 on Mon Mar 05, 2018 2:48 pm, edited 1 time in total.
Re: centerWindow (*window) or getFrameSize (*window)
PB already added WindowWidth(Win, #PB_Window_FrameCoordinate) and WindowHeight(Win, #PB_Window_FrameCoordinate), those can help.
But a CenterWindow() function would be nice, and maybe flags for DesktopHeight to get the USABLE heights without API (minus taskbar, etc).
Also, what the OS considers "centered" is not always mathematically centered, for example when you tell MacOS to "center" a window it places it slightly higher than center (for aesthetics).
But a CenterWindow() function would be nice, and maybe flags for DesktopHeight to get the USABLE heights without API (minus taskbar, etc).
Also, what the OS considers "centered" is not always mathematically centered, for example when you tell MacOS to "center" a window it places it slightly higher than center (for aesthetics).
setWindowFlags (*window, flags)
I agree, think the center function should really center on screen by default.
I am sorry, jeever, to omit remembering the #frameCoordinates constants as you mentioned.
Sorry, they DO that job.
It's by the way always sad to have no option to change the flags of a window. Apart from my previous topic titled above, changing the window flags by PB could become as crucial as replacing a window to the screen center.
Is there an approach existing in PB already?
// notice the topic-reachon change
I am sorry, jeever, to omit remembering the #frameCoordinates constants as you mentioned.
Sorry, they DO that job.
It's by the way always sad to have no option to change the flags of a window. Apart from my previous topic titled above, changing the window flags by PB could become as crucial as replacing a window to the screen center.
Is there an approach existing in PB already?
// notice the topic-reachon change
Re: centerWindow (*window) or getFrameSize (*window)
es_91 wrote:Correct centering without using API-functions is impossible when not init-applied to the window on openWindow function.
Code: Select all
HideWindow(Window, #False, #PB_Window_ScreenCentered)
Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
Re: centerWindow (*window) or getFrameSize (*window)
Then I'm sorry. Very sorry not studying the changes.
Thanks, Sicro
Thanks, Sicro
Re: centerWindow (*window) or getFrameSize (*window)
But this Center only works when un-hiding the window from hidden... I don't know why, OS/API reason?HideWindow(Window, #False, #PB_Window_ScreenCentered)
Re: centerWindow (*window) or getFrameSize (*window)
Did you try it, kenmo ?kenmo wrote:But this Center only works when un-hiding the window from hidden... I don't know why, OS/API reason?HideWindow(Window, #False, #PB_Window_ScreenCentered)
In Windows, it works even if the window is not currently hidden.
Code: Select all
winH = 120
winW = 300
If OpenWindow(0, 100, 200, winW, winH, "PureBasic Window", #PB_Window_SystemMenu)
SetWindowColor(0,#Yellow)
TextGadget(0, 20,20,200,20,"Window not centered")
SetGadgetColor(0,#PB_Gadget_BackColor, #Yellow)
gW = 120
gH = 20
ButtonGadget(1,winW-gW-10,winH-gH-10, gW, gH, "Center the window")
Repeat
event = WaitWindowEvent()
Select event
Case #PB_Event_CloseWindow : Break
Case #PB_Event_Gadget :
HideWindow(0, #False,#PB_Window_ScreenCentered)
SetGadgetText(0, "the Window is now centered")
DisableGadget(1,1)
EndSelect
ForEver
EndIf
End
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
"Oh! I see..." replied the blind man.
Re: centerWindow (*window) or getFrameSize (*window)
I did not try it Oops. That's just how I understood the help:
#PB_Window_ScreenCentered: the window will be screen centered (only valid when un-hiding the window).