How to open a window full client size?

Just starting out? Need help? Post your questions and find answers here.
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

Unfortunately #pb_window_maximised doesn't extend the window fully to the right but it does extend it under the taskbar so part of the gadget is hidden.

Code: Select all

OpenWindow(0, 0, 0, 512, 384, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_Maximize | #PB_Window_SizeGadget) 
CreateGadgetList(WindowID(0)) 
y=WindowHeight(0)
TextGadget(0,100,y-20,100,20,"can you see me",#PB_Text_Border)
Repeat 
  Select WaitWindowEvent() 
    Case #PB_Event_CloseWindow 
      Break 
  EndSelect 
ForEver
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Derek wrote:Unfortunately #pb_window_maximised doesn't extend the window fully to the right but it does extend it under the taskbar so part of the gadget is hidden.

Code: Select all

OpenWindow(0, 0, 0, 512, 384, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_Maximize | #PB_Window_SizeGadget) 
CreateGadgetList(WindowID(0)) 
y=WindowHeight(0)
TextGadget(0,100,y-20,100,20,"can you see me",#PB_Text_Border)
Repeat 
  Select WaitWindowEvent() 
    Case #PB_Event_CloseWindow 
      Break 
  EndSelect 
ForEver
1. It does go fully to the right. If it doesn't, then something is wrong on your end.
2. If you remove #PB_Window_SizeGadget (which was done in my first example) then YES, I can see the gadget.
However, with your code, a gadget placed at that position would NOT be visible. So I added #PB_Window_SizeGadget and then my code creates a window the same size as yours. The real reason the gadget doesn't show in your example is that WindowHeight() returns the wrong value. The window still has the size you wanted.
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

Well using this code with windows vista business only stretches near to the corner.

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
http://www.dlwebsite.pwp.blueyonder.co.uk/topright.bmp

Also, having windowheight() return the wrong size doesn't help. :lol:
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

You should post a bug report about the window not maximizing properly. It should really fill out to the corner.
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

Anyone else getting this with Vista? Presumably it works ok with XP.
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Derek wrote:Anyone else getting this with Vista?
No problem here with Vista HomePremium.

Now that I see exactly what it is you're looking for, I modified my original code...
Window is max size with borders and all gadgets being visible
Window cannot be moved
SysMenu item Move is disabled
Taskbar location (left/right/top/bottom) is taken into account

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) 
windowx=screen\left
windowy=screen\top
Procedure.l WinCallback(hwnd,msg,wParam,lParam) 
  result=#PB_ProcessPureBasicEvents 
  Select msg 
    Case #WM_WINDOWPOSCHANGING
      result=0
  EndSelect 
  ProcedureReturn result 
EndProcedure 

Procedure.l DisableMenuMove(hwnd)
  hMenu=GetSystemMenu_(hwnd,0)
  mii.MENUITEMINFO
  mii\cbSize=SizeOf(MENUITEMINFO)
  mii\fMask=#MIIM_STRING
  mii\dwTypeData=0
  GetMenuItemInfo_(hMenu,#SC_MOVE,0,@mii.MENUITEMINFO)
  mItem$ = Space(mii\cch+1)
  mii\dwTypeData=@mItem$
  mii\cch+1
  GetMenuItemInfo_(hMenu,#SC_MOVE,0,@mii.MENUITEMINFO)
  ModifyMenu_(hMenu,#SC_MOVE,#MF_GRAYED|#MF_BYCOMMAND,0,mItem$)
  DrawMenuBar_(hwnd)
EndProcedure
  
OpenWindow(0,windowx,windowy,windowwidth,windowheight,"",#PB_Window_SystemMenu) 
CreateGadgetList(WindowID(0)) 
ButtonGadget(0,0,0,100,100,"") 
ButtonGadget(1,WindowWidth(0)-100,0,100,100,"") 
ButtonGadget(2,0,WindowHeight(0)-100,100,100,"") 
ButtonGadget(3,WindowWidth(0)-100,WindowHeight(0)-100,100,100,"") 
DisableMenuMove(WindowID(0))
SetWindowCallback(@WinCallback())
Repeat 
  
Until WaitWindowEvent()=#PB_Event_CloseWindow 
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

Dereks code = close but not quite filled.

Sparkie's code = filled completely.

Vista64 ultimate.

cheers
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

Thanks Sparkie, works great. :D
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

rsts wrote: Vista64 ultimate.
Perhaps a Vista64 issue?
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

No, mines vista 32. I posted a bug report and freak had a solution.
Post Reply