Page 1 of 1

[Implemented] WindowWidth/WindowHeight need borders/caption

Posted: Sun Sep 02, 2007 6:04 am
by PB
Hi, I'm sure this had been requested before but a quick search didn't show it.
Anyway, I'd like WindowHeight (and WindowWidth too) to be able to return
the ACTUAL height/width, instead of the INNER height/width, because at the
moment WindowHeight() and WindowWidth() don't take border and caption
sizes into account, which is a bit silly. Makes it harder to dock a window on
the Taskbar or in a screen corner. :)

I'd suggest the commands return the real (borders and caption) size, but
with an optional flag like #PB_Window_InnerOnly to return just the client
size if the user wants it.

Code: Select all

Procedure RealWindowWidth(num)
  GetWindowRect_(WindowID(num),win.RECT)
  ProcedureReturn win\right-win\left
EndProcedure

Procedure RealWindowHeight(num)
  GetWindowRect_(WindowID(num),win.RECT)
  ProcedureReturn win\bottom-win\top
EndProcedure

OpenWindow(0,100,100,200,200,"test",#PB_Window_SystemMenu)

Debug WindowWidth(0) ; Returns 200 (just the inner width).
Debug WindowHeight(0) ; Returns 200 (just the inner height).
Debug RealWindowWidth(0) ; Returns 206 (width with borders).
Debug RealWindowHeight(0) ; Returns 230 (height with borders + caption).

Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow

Posted: Sun Sep 02, 2007 8:00 am
by Joakim Christiansen

Posted: Sun Sep 02, 2007 8:49 am
by PB
I knew it was requested somewhere but I couldn't find it. :)

Posted: Sun Sep 02, 2007 2:48 pm
by nco2k
agree. i was also requesting this few years ago. it would be really cool to have this and like i said in the thread from JLC, a possibility to check the window client x/y positions:

Code: Select all

Procedure WindowClientX(Window)
  ClientToScreen_(WindowID(Window), @win.POINT)
  ProcedureReturn win\x
EndProcedure

Procedure WindowClientY(Window)
  ClientToScreen_(WindowID(Window), @win.POINT)
  ProcedureReturn win\y
EndProcedure

OpenWindow(0,100,100,200,200,"test",#PB_Window_SystemMenu)

Debug WindowX(0); x postion of the window itself
Debug WindowY(0); y position of the window itself
Debug WindowClientX(0); x position of the window client area
Debug WindowClientY(0); y position of the window client area

Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
c ya,
nco2k