Page 1 of 2
How to open a window full client size?
Posted: Sat Apr 12, 2008 11:50 pm
by Derek
What I want is a window opened on the client area of the screen which is full size and not resizeable.
Trouble is unless I include the #pb_window_sizegadget in the second window command then the resize command that is used to position the window in the corner actually moves the window slightly to the left and up.
The reason for the resize command is because the #pb_screen_centered part is not actually centering on the client area but on the whole screen, but that's another story.
Also, this code seems to work if the taskbar is on the bottom or right of the screen but if it's on the top or left then a full screen sized window gets created.
Code: Select all
OpenWindow(0,0,0,200,200,"",#PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_Invisible)
GetWindowRect_(WindowID(0),win.RECT)
widthtoadd=(win\right-win\left)-200
heighttoadd=(win\bottom-win\top)-200
SystemParametersInfo_(#SPI_GETWORKAREA,0,@screen.RECT,0)
windowwidth = screen\right-widthtoadd
windowheight = screen\bottom-heighttoadd
CloseWindow(0)
OpenWindow(0,0,0,WindowWidth,WindowHeight,"",#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget)
;ResizeWindow(0,0,0,#PB_Ignore,#PB_Ignore)
Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow
So what I'm asking is how do you create a window with borders that aren't half off screen which takes up only the client area and also takes into account where the taskbar is?
Or how do you stop a window from being resized when you have to include the #pb_window_sizegadget?
Posted: Sun Apr 13, 2008 12:09 am
by Sparkie
Does something like this work for you?
Code: Select all
SystemParametersInfo_(#SPI_GETWORKAREA,0,@screen.RECT,0)
captionheight = GetSystemMetrics_(#SM_CYCAPTION)
borderwidth = GetSystemMetrics_(#SM_CXFIXEDFRAME)
borderheight = GetSystemMetrics_(#SM_CYFIXEDFRAME)
windowwidth = screen\right-screen\left-(borderwidth*2)
windowheight = screen\bottom-screen\top-captionheight-(borderheight*2)
OpenWindow(0,0,0,windowwidth,windowheight,"",#PB_Window_SystemMenu|#PB_Window_Maximize|#PB_Window_MaximizeGadget)
Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow
Posted: Sun Apr 13, 2008 12:14 am
by Fluid Byte
See if this works for you (test with all taskbar locations):
Code: Select all
SystemParametersInfo_(#SPI_GETWORKAREA,0,rcwa.RECT,0)
BorderWidth = GetSystemMetrics_(#SM_CXFIXEDFRAME)
CaptionHeight = GetSystemMetrics_(#SM_CYCAPTION)
WinWidth = rcwa\right - rcwa\left - (BorderWidth * 2)
WinHeight = rcwa\bottom - rcwa\top - CaptionHeight - (BorderWidth * 2)
OpenWindow(0,rcwa\left,rcwa\top,WinWidth,WinHeight,"void",#PB_Window_SystemMenu)
While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
[edit]
God damn it Sparkman!

Posted: Sun Apr 13, 2008 12:19 am
by Fluid Byte
Because:
Derek wrote:So what I'm asking is how do you create a window with borders that aren't half off screen which takes up only the client area and also takes into account where the taskbar is?
[edit]
Hah Mistrel! You deleted that post. Got ya!

Posted: Sun Apr 13, 2008 12:38 am
by netmaestro
Or how do you stop a window from being resized when you have to include the #pb_window_sizegadget?
Example:
Code: Select all
Global wr.RECT
Procedure WinProc(hwnd, msg, wparam, lparam)
result=#PB_ProcessPureBasicEvents
Select msg
Case #WM_MOVING, #WM_SIZING
*dragrect.RECT = lparam
With *dragrect
\left = wr\left
\top = wr\top
\right = wr\right
\bottom = wr\bottom
EndWith
result = #True
EndSelect
ProcedureReturn result
EndProcedure
OpenWindow(0,0,0,640,480,"Sizable but.. nope",#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget)
GetWindowRect_(WindowID(0), wr)
SetWindowCallback(@WinProc())
Repeat:Until WaitWindowEvent()=#WM_CLOSE
Posted: Sun Apr 13, 2008 12:50 am
by Sparkie
Fluid Byte wrote:God damn it Sparkman!
T e m p e r . . . t e m p e r, Fluid Byte

Posted: Sun Apr 13, 2008 1:02 am
by Mistrel
Fluid Byte wrote:Because:
Derek wrote:So what I'm asking is how do you create a window with borders that aren't half off screen which takes up only the client area and also takes into account where the taskbar is?
[edit]
Hah Mistrel! You deleted that post. Got ya!

I would have played with it further but when I realized that he wanted it to be taskbar friendly I had to withdraw. I don't use the Windows taskbar and therefore can't test the code. :roll:
Sparkie wrote:Fluid Byte wrote:God damn it Sparkman!
T e m p e r . . . t e m p e r, Fluid Byte

I was tempted to reserve the first reply. I knew Sparkie would beat me to it!
Posted: Sun Apr 13, 2008 2:12 am
by akj
This works OK within Window ME:
Code: Select all
; GUI metrics
Define winx, winy, winw, winh
winw = GetSystemMetrics_(#SM_CXFULLSCREEN)
winh = GetSystemMetrics_(#SM_CYFULLSCREEN)
winx = -3: winy = -3 ; Force the window to start as though maximised
; Create GUI
#winMain = 0
Define flags = #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_TitleBar
OpenWindow(#winMain, winx, winy, winw, winh, "Test", flags)
; Eventloop
Repeat
Until WaitWindowEvent(#winMain)=#PB_Event_CloseWindow
End
Posted: Sun Apr 13, 2008 3:06 am
by Fluid Byte
@Sparkman:
I find it a bit frightening that our codes are so similar. Even the variable names!
Well, the temper ....
I try to control it!




Posted: Sun Apr 13, 2008 3:17 am
by Sparkie
Fluid Byte wrote:I find it a bit frightening that our codes are so similar.
GMTA
Fluid Byte wrote:Well, the temper .... I try to control it!
...and you're doing a damn good job....keep it up!

Posted: Sun Apr 13, 2008 9:04 am
by Trond
Can anyone tell me why this isn't enough?
Code: Select all
OpenWindow(0, 0, 0, 512, 384, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_Maximize)
CreateGadgetList(WindowID(0))
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
Posted: Sun Apr 13, 2008 9:20 am
by Derek
@Sparkie, trouble is the gadgets don't go exactly into the corners.
Code: Select all
SystemParametersInfo_(#SPI_GETWORKAREA,0,@screen.RECT,0)
captionheight = GetSystemMetrics_(#SM_CYCAPTION)
borderwidth = GetSystemMetrics_(#SM_CXFIXEDFRAME)
borderheight = GetSystemMetrics_(#SM_CYFIXEDFRAME)
windowwidth = screen\right-screen\left-(borderwidth*2)
windowheight = screen\bottom-screen\top-captionheight-(borderheight*2)
OpenWindow(0,0,0,windowwidth,windowheight,"",#PB_Window_SystemMenu|#PB_Window_Maximize|#PB_Window_MaximizeGadget)
CreateGadgetList(WindowID(0))
ButtonGadget(0,0,0,100,100,"")
ButtonGadget(1,windowwidth-100,0,100,100,"")
ButtonGadget(2,0,windowheight-100,100,100,"")
ButtonGadget(3,windowwidth-100,windowheight-100,100,100,"")
Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow
It's probably me just being padantic, I'm just trying to get it looking right.

Posted: Sun Apr 13, 2008 9:24 am
by Derek
@Trond, the thing is that the maximised window doesn't quite reach the right hand side and also continues under the taskbar. At least on vista it does.
@Fluid, I'll give your code a try, thanks.
@netmaestro, thanks, if that works ok then that'll be the way I go.

Posted: Sun Apr 13, 2008 10:02 am
by Derek
Here's the final bit of code.
Looks neat and tidy on mine anyway.
Thanks to everyone for the help.
Code: Select all
OpenWindow(0,0,0,200,200,"",#PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_Invisible)
GetWindowRect_(WindowID(0),win.RECT)
width_to_subtract=(win\right-win\left)-200
height_to_subtract=(win\bottom-win\top)-200
SystemParametersInfo_(#SPI_GETWORKAREA,0,@screen.RECT,0)
windowwidth = (screen\right-screen\left)-width_to_subtract
windowheight = (screen\bottom-screen\top)-height_to_subtract
ResizeWindow(0,screen\left,screen\top,WindowWidth,WindowHeight)
HideWindow(0,0)
Global wr.RECT
Procedure WinProc(hwnd, msg, wparam, lparam)
result=#PB_ProcessPureBasicEvents
Select msg
Case #WM_MOVING, #WM_SIZING
*dragrect.RECT = lparam
With *dragrect
\left = wr\left
\top = wr\top
\right = wr\right
\bottom = wr\bottom
EndWith
result = #True
EndSelect
ProcedureReturn result
EndProcedure
GetWindowRect_(WindowID(0), wr)
SetWindowCallback(@WinProc())
CreateGadgetList(WindowID(0))
ButtonGadget(0,0,0,100,100,"")
ButtonGadget(1,windowwidth-100,0,100,100,"")
ButtonGadget(2,0,windowheight-100,100,100,"")
ButtonGadget(3,windowwidth-100,windowheight-100,100,100,"")
Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow
Posted: Sun Apr 13, 2008 10:40 am
by Trond
Derek wrote:@Trond, the thing is that the maximised window doesn't quite reach the right hand side and also continues under the taskbar. At least on vista it does.
@Fluid, I'll give your code a try, thanks.
@netmaestro, thanks, if that works ok then that'll be the way I go.

I see now what you want. You want to create a maximized window that isn't maximized. That's what I call evil, simply because there's a very good reason the borders are removed from maximized windows. The only reason have to have the borders anyways is if you want to resize the window, which you want to prohibit (that's also evil, because resize-border means: this window can be resized. It's like having a button that does nothing).
What I want is a window opened on the client area of the screen which is full size and not resizeable.
This done like this:
Code: Select all
OpenWindow(0, 0, 0, 512, 384, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_Maximize | #PB_Window_SizeGadget)
CreateGadgetList(WindowID(0))
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver