OpenWindow
OpenWindow
When using the OpenWindow command the width and height is for the client area. But is there away to get a Windows Frame thickness before opening the window?
Like if I wish to open a Window with the height and with of 1920x1080, how do I get the Windows border thickness?
Like if I wish to open a Window with the height and with of 1920x1080, how do I get the Windows border thickness?
Re: OpenWindow
Before only with API (example):
Or u could do something like this and just hide the Window before showing it:
Code: Select all
GetSystemMetrics_(#SM_CXSIZEFRAME)
Code: Select all
If OpenWindow(0,0,0,100,120,"TestWindow",#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_Invisible)
BorderWidth.i = (WindowWidth(0,#PB_Window_FrameCoordinate) - WindowWidth(0,#PB_Window_InnerCoordinate)) / 2
BorderHeightTop.i = WindowHeight(0,#PB_Window_FrameCoordinate) - WindowHeight(0,#PB_Window_InnerCoordinate) - BorderWidth
BorderHeightBottom.i = BorderWidth
MessageRequester("ShowWindow","BorderWidth: " + Str(BorderWidth) + Chr(10) +
"BorderHeightTop: " + Str(BorderHeightTop) + Chr(10) +
"BorderHeightBottom: " + Str(BorderHeightBottom))
HideWindow(0,#False)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
EndIf
Re: OpenWindow
Thanks for the tip, I've tried this so far. No Success.
Code: Select all
EnableExplicit
; Result = ExamineDesktops()
;y = DesktopHeight(0)
;x = DesktopWidth(0)
;Debug Str(x) + "/"+ Str(y)
Define a.rect
Define.i PrimaryWindowHandler, PrimaryWindowEvent
SystemParametersInfo_(#SPI_GETWORKAREA,0,@a,0)
Debug Str(a\left) + "," + Str(a\right) + "," + Str(a\top) + "," + Str(a\bottom)
PrimaryWindowHandler = OpenWindow(#PB_Any, 0,0,a\right,a\bottom - GetSystemMetrics_(#SM_CYSIZEFRAME),"Test", #PB_Window_SystemMenu)
Repeat
PrimaryWindowEvent = WindowEvent()
Select PrimaryWindowEvent
Case #PB_Event_CloseWindow
Break
EndSelect
Delay(1)
ForEver
CloseWindow(PrimaryWindowHandler)
Re: OpenWindow
About GetSystemMetrics:
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
Re: OpenWindow
you could use AdjustWindowRect:
however, if you want your window to be of exact size, you should create a linker option file and target windows vista and greater: /SUBSYSTEM:WINDOWS,6.0
c ya,
nco2k
Code: Select all
Define WinRect.RECT, WinStyle, WinMenu, WinWidth, WinHeight
WinStyle = #WS_CAPTION; change to the style you are planning to use
WinMenu = #False; change to #True if your window has a menubar
WinWidth = 640
WinHeight = 480
AdjustWindowRect_(@WinRect, WinStyle, WinMenu)
OpenWindow(0, 0, 0, WinWidth - (WinRect\right - WinRect\left), WinHeight - (WinRect\bottom - WinRect\top), "Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
Debug WindowWidth(0, #PB_Window_FrameCoordinate)
Debug WindowHeight(0, #PB_Window_FrameCoordinate)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
Re: OpenWindow
Simple and clean
Code: Select all
;AdjustWindowRectEx_(r.RECT,window styles,menu-present flag,extended style)
AdjustWindowRectEx_(r.RECT,#PB_Window_BorderLess,0,0)
Debug r\right
Debug -r\top
AdjustWindowRectEx_(r.RECT,#PB_Window_SystemMenu,0,0)
Debug r\right
Debug -r\top
AdjustWindowRectEx_(r.RECT,#PB_Window_SizeGadget,0,0)
Debug r\right
Debug -r\top
Egypt my love
Re: OpenWindow
pb constants dont necessarily have to match winapi constants. they could contain custom bits, or change in the future, which could produce unwanted side-effects. using pb constants for winapi functions and vice versa, was never officially supported and should be avoided.
c ya,
nco2k
c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
Re: OpenWindow
Thanks for all the tips. I think I'll use this for the time being. It also takes the taskbar into account.
Code: Select all
EnableExplicit
Define.rect a, b
Define.i PrimaryWindowHandler, PrimaryWindowEvent
SystemParametersInfo_(#SPI_GETWORKAREA,0,@b,0)
;Debug Str(b\left) + "," + Str(b\right) + "," + Str(b\top) + "," + Str(b\bottom)
AdjustWindowRectEx_(a,#WS_SYSMENU | #WS_CAPTION,0,0)
;Debug Str(a\left) + "," + Str(a\right) + "," + Str(a\top) + "," + Str(a\bottom)
PrimaryWindowHandler = OpenWindow(#PB_Any, b\left,b\top,b\right-a\right,b\bottom-abs(a\top),"Test", #PB_Window_SystemMenu)
Repeat
PrimaryWindowEvent = WindowEvent()
Select PrimaryWindowEvent
Case #PB_Event_CloseWindow
Break
EndSelect
Delay(1)
ForEver
CloseWindow(PrimaryWindowHandler)
Last edited by GenRabbit on Thu Jan 04, 2018 10:20 pm, edited 1 time in total.
Re: OpenWindow
Adapt it for your needs
Code: Select all
AdjustWindowRectEx_(a.RECT,#WS_SYSMENU | #WS_CAPTION,0,0)
OpenWindow(0,0,0,0,0,"Window & TaskBar",#PB_Window_SystemMenu|#PB_Window_MaximizeGadget | #PB_Window_Invisible)
SetWindowState(0,#PB_Window_Maximize)
SetWindowLongPtr_(WindowID(0), #GWL_STYLE, GetWindowLongPtr_(WindowID(0),#GWL_STYLE)&~ #WS_MAXIMIZEBOX)
ResizeWindow(0,WindowX(0),WindowY(0),WindowWidth(0),WindowHeight(0))
HideWindow(0,0)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
EndSelect
Until Quit = 1
Egypt my love
Re: OpenWindow
No, it doesn't. My taskbar is on the left, so I don't see the window's "Close" button at all. You can't assume the taskbar will always be on the bottom of the screen.GenRabbit wrote:It also takes the taskbar into account.
Re: OpenWindow
@GenRabbit
the window has a border on each side, left/right, top/bottom. currently you only substract one. do it like this:
also consider my suggestion about the linker option file.
c ya,
nco2k
the window has a border on each side, left/right, top/bottom. currently you only substract one. do it like this:
Code: Select all
PrimaryWindowHandler = OpenWindow(#PB_Any, b\left,b\top,(b\right-b\left)-(a\right-a\left),(b\bottom-b\top)-(a\bottom-a\top),"Test", #PB_Window_SystemMenu)
c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
Re: OpenWindow
@GenRabbit
See my previous post
But if you want to use Windows API for Taskbar
See my previous post
But if you want to use Windows API for Taskbar
Code: Select all
SHAppBarMessage_(#ABM_GETTASKBARPOS,@Info.AppBarData)
If Info\uEdge = 0 : Position$ = "left" : EndIf
If Info\uEdge = 1 : Position$ = "top" : EndIf
If Info\uEdge = 2 : Position$ = "right" : EndIf
If Info\uEdge = 3 : Position$ = "bottom" : EndIf
Debug Info\rc\left
Debug Info\rc\top
Debug Info\rc\right
Debug Info\rc\bottom
Debug Position$
Egypt my love
Re: OpenWindow
Thanks. I do not know what you mean by linker option filenco2k wrote:@GenRabbit
the window has a border on each side, left/right, top/bottom. currently you only substract one. do it like this:also consider my suggestion about the linker option file.Code: Select all
PrimaryWindowHandler = OpenWindow(#PB_Any, b\left,b\top,(b\right-b\left)-(a\right-a\left),(b\bottom-b\top)-(a\bottom-a\top),"Test", #PB_Window_SystemMenu)
c ya,
nco2k
I pasted your code into my program.
Last edited by GenRabbit on Thu Jan 04, 2018 10:33 pm, edited 1 time in total.
Re: OpenWindow
Thanks. I hoped my way of doing it also took the taskbars placement into consideration. I prefer to do as much as possible using PB commands rather than API calls due to Hopefully on day make them MAC/Linux compitable.RASHAD wrote:@GenRabbit
See my previous post
But if you want to use Windows API for TaskbarCode: Select all
SHAppBarMessage_(#ABM_GETTASKBARPOS,@Info.AppBarData) If Info\uEdge = 0 : Position$ = "left" : EndIf If Info\uEdge = 1 : Position$ = "top" : EndIf If Info\uEdge = 2 : Position$ = "right" : EndIf If Info\uEdge = 3 : Position$ = "bottom" : EndIf Debug Info\rc\left Debug Info\rc\top Debug Info\rc\right Debug Info\rc\bottom Debug Position$
Re: OpenWindow
That came to me a little later. like "hm... but if the taskbar change position.."Dude wrote:No, it doesn't. My taskbar is on the left, so I don't see the window's "Close" button at all. You can't assume the taskbar will always be on the bottom of the screen.GenRabbit wrote:It also takes the taskbar into account.