Page 1 of 2

#PB_Window_Maximize (dont want hide taskbar) !?

Posted: Wed Mar 01, 2006 1:26 am
by va!n
When open a window and using this flag for a windows app, it starts at maximized but it will be in front of the taskbar! Is there any way to maxmize the app at programstart but dont be in front nor behind the taskbar!? (hope you guys know what i mean!? ;)

Posted: Wed Mar 01, 2006 1:51 am
by va!n
ok, i found a way ;) if someone know another way, please tell me, thx!

EDITED:
When starting this example, the window seems to be 2-3 pixel widther as it should !? (you can notice this on the CLOSE button and its white border on XP)

Code: Select all

GetWindowRect_(GetDesktopWindow_(),rect.rect)
Debug "Full-Screen"
Debug rect\left
Debug rect\top
Debug rect\right
Debug rect\bottom

SystemParametersInfo_(#SPI_GETWORKAREA,0,rect.rect,0)
Debug "Desktop-Area"
Debug rect\left
Debug rect\top
Debug rect\right
Debug rect\bottom

lWindowWidth  = rect\right
lWindowHeight = rect\bottom

OpenWindow(0,0,0,lwindowWidth, lWindowHeight,  #PB_Window_SystemMenu, "Maximize and dont hide Taskbar")

Repeat
  Select WaitWindowEvent()
     Case #PB_Event_CloseWindow
        quit = 1
  EndSelect
Until quit

End

Posted: Wed Mar 01, 2006 3:47 am
by va!n
ah, i thought it works... but now i see it does not really work as i need and thought :twisted:

Posted: Wed Mar 01, 2006 5:44 am
by Sparkie
You need to account for the window caption height as well. When you use width and height in OpenWindow(), you are setting the size of the window client area.

Code: Select all

captionH = GetSystemMetrics_(#SM_CYCAPTION)

SystemParametersInfo_(#SPI_GETWORKAREA, 0, winRect.RECT, 0) 

WinWidth  = winRect\right - winRect\left - 10
WinHeight = winRect\bottom - winRect\top - captionH - 10

If OpenWindow(0, 0, 0, WinWidth, WinHeight,  #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget | #PB_Window_Maximize | #PB_Window_SizeGadget | #PB_Window_SystemMenu, "Maximize and dont hide Taskbar") And CreateGadgetList(WindowID(0))
  CreateStatusBar(0, WindowID(0))
  StatusBarText(0, 0, "Can you see this statusbar and the taskbar?")
  Repeat 
    Select WaitWindowEvent() 
      Case #PB_Event_CloseWindow 
        quit = 1 
    EndSelect 
  Until quit 
EndIf
End

Posted: Wed Mar 01, 2006 6:11 am
by USCode
Interesting. How come PB applications using #PB_Window_Maximize don't maximize up to the task bar automatically, like all other apps do?

Posted: Wed Mar 01, 2006 6:27 am
by Sparkie
I was curious about that myself and I SWEAR the first couple of time I tried, it wouldn't size to fit. Trying it once again, I see it does indeed size itself to fit. Hmmmm...need to go back and see where I went wrong the first time.

Thanks for waking me up USCode ;)

Everyone can just ignore my code above :oops:

Posted: Wed Mar 01, 2006 6:42 am
by va!n
@Sparkie
Thanks for helping... btw, i dont know if its a bug or a feature to maximize the full screen (hinding taskbar)

Posted: Wed Mar 01, 2006 6:42 am
by Sparkie
OK, I see where I confused myself. My first attempts were to open the window to its maximized size without using the #PB_Window_Maximize flag. In other words the window was not actually maximized but yet sized nearly equal to it's maximized state. I then combined my various code and it was all fubar after that. :roll: Sorry for all the confusion. :(

On that note, I will say good night. :)

Posted: Wed Mar 01, 2006 6:46 am
by Sparkie
I may regret not going to bed but what the hell...

My taskbar remains visible here va!n. :?

Posted: Wed Mar 01, 2006 6:59 am
by Sparkie
@va!n:

Right click taskbar
Select Properties

Is Keep the taskbar on top of other windows checked :?:

Posted: Wed Mar 01, 2006 7:11 am
by va!n
yes, sorry for confusing i.e. ! with your codesnip the widnow is maximized and the taskbar is still visible :)

when i talked about "its a bug or a feature (to hide the taskbar)", i mean the #MAXIMIZE flag from purebasic... but now i will go to bed too, good night ;)

Posted: Wed Mar 01, 2006 8:35 am
by Trond
To maximize a window, it needs to have the MaximizeGadget flag. This is a Windows limitation.

Code: Select all

; Maximized
OpenWindow(0, 0, 0, 400, 300, #PB_Window_MaximizeGadget | #PB_Window_Maximize, "")

; Not maximized but covers the whole screen instead
; OpenWindow(0, 0, 0, 400, 300, #PB_Window_Maximize, "")

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
  EndSelect
ForEver

Posted: Wed Mar 01, 2006 2:56 pm
by va!n
@Trond:
Thanks a lot for this tip! Now it works as wished :D

Posted: Wed Mar 15, 2006 8:40 pm
by paleozord
When I try to run that code posted above:

Code: Select all

OpenWindow(0, 0, 0, 400, 300, #PB_Window_MaximizeGadget | #PB_Window_Maximize, "")
I get the error "Constant not found: #PB_Window_Maximize"

PB doesn't even recognize that that flag exists. What am I doing wrong?

Posted: Wed Mar 15, 2006 8:52 pm
by netmaestro
What version of PB are you running? Most of what gets posted these days is v4.0 beta code, I don't believe that flag exists in 3.94 or the demo version. For 3.94 you may need to maximize the window explicitly with:

Code: Select all

OpenWindow(0, 0, 0, 400, 300, #PB_Window_MaximizeGadget , "") 
ShowWindow_(WindowID(0),#SW_MAXIMIZE)
or you can use the equivalent windows flag:

Code: Select all

OpenWindow(0, 0, 0, 400, 300, #PB_Window_MaximizeGadget | #WS_MAXIMIZE , "")