[Implemented] WindowWidth/WindowHeight need borders/caption

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

[Implemented] WindowWidth/WindowHeight need borders/caption

Post 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
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post by Joakim Christiansen »

I like logic, hence I dislike humans but love computers.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

I knew it was requested somewhere but I couldn't find it. :)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Post 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
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
Post Reply