Windows window size bug or not?

Just starting out? Need help? Post your questions and find answers here.
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Windows window size bug or not?

Post by infratec »

Hi,

I came across a strange behavior on WIndows:

Code: Select all

OpenWindow(0, 0, 0, 0, 0, "", #PB_Window_MaximizeGadget|#PB_Window_Maximize)
;OpenWindow(0, 0, 0, 0, 0, "", #PB_Window_SystemMenu|#PB_Window_Maximize)
Debug Str(WindowWidth(0)) + "/" + Str(WindowHeight(0))
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
The menu is in general the same, but without the MaximizeGadget the window goes above the Windows menu.

Bug or no bug?

What do I do with a window which overlaps the system menu?
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Windows window size bug or not?

Post by infratec »

Also strange:

Code: Select all

CompilerIf #PB_Compiler_IsMainFile
  EnableExplicit
CompilerEndIf


Structure GetMaxWindowDesktopInfo_Structure
  InnerX.i
  InnerY.i
  FrameX.i
  FrameY.i
  InnerWidth.i
  InnerHeight.i
  FrameWidth.i
  FrameHeight.i
EndStructure

Procedure.i GetMaxWindowDesktopInfo(*Info.GetMaxWindowDesktopInfo_Structure)
  
  Protected.i Win, Event, Result
  
  Win = OpenWindow(#PB_Any, 0, 0, 0, 0, "", #PB_Window_MaximizeGadget|#PB_Window_Maximize|#PB_Window_Invisible)
  If Win
    AddWindowTimer(Win, 1, 10)
    Repeat
      Event = WaitWindowEvent()
      If Event = #PB_Event_Timer And EventTimer() = 1
        RemoveWindowTimer(Win, 1)
        Break
      EndIf
    ForEver
    *Info\InnerX = WindowX(Win, #PB_Window_InnerCoordinate)
    *Info\InnerY = WindowY(Win, #PB_Window_InnerCoordinate)
    *Info\FrameX = WindowX(Win, #PB_Window_FrameCoordinate)
    *Info\FrameY = WindowY(Win, #PB_Window_FrameCoordinate)
    *Info\InnerWidth = WindowWidth(Win, #PB_Window_InnerCoordinate)
    *Info\InnerHeight = WindowHeight(Win, #PB_Window_InnerCoordinate)
    *Info\FrameWidth = WindowWidth(Win, #PB_Window_FrameCoordinate)
    *Info\FrameHeight = WindowHeight(Win, #PB_Window_FrameCoordinate)
    CloseWindow(Win)
    Result = #True
  Else
    MessageRequester("Error", "Can't open window.", #PB_MessageRequester_Error)
  EndIf
  
  ProcedureReturn Result
  
EndProcedure


CompilerIf #PB_Compiler_IsMainFile
  
  Define Info.GetMaxWindowDesktopInfo_Structure, Event.i
  
  If GetMaxWindowDesktopInfo(@Info)
    Debug Str(Info\FrameX) + "/" + Str(Info\FrameY) + " " + Str(Info\InnerX) + "/" + Str(Info\InnerY) + " " + Str(Info\InnerWidth) + "/" + Str(Info\InnerHeight) + " " + Str(Info\FrameWidth) + "/" + Str(Info\FrameHeight)
    
    OpenWindow(0, Info\FrameX, Info\FrameY, Info\InnerWidth, Info\InnerHeight, "Max", #PB_Window_MaximizeGadget)
    CanvasGadget(0, 0, 0, Info\InnerWidth, Info\InnerHeight)
    If StartDrawing(CanvasOutput(0))
      Plot(0, 0, #Red)
      Plot(Info\InnerWidth - 1, 0, #Red)
      StopDrawing()
    EndIf
    Repeat
      Event = WaitWindowEvent()
      If Event = #PB_Event_MaximizeWindow
        Debug WindowX(0)
      EndIf
    Until Event = #PB_Event_CloseWindow
    
  EndIf
  
CompilerEndIf
Results in: 0/0 3/26 1280/961 1286/990

My screen resolution is 1280/1024

FrameX and FrameY is 0/0, that's expected.
But InnerWidth is 1280. That's my screen size! So the inner window is not fully displayed, since InnerX is 3 on my PC.
This would result in 3 pixels not visible on the right side of the inner window area.

The opened window at 0/0 is not displayed at 0/0.
But if I press the maximize Gadget, it is placed correct, I can see both red points.
But then the x cordinate needs to be -3, whichj is the case.

Then the initial #PB_Window_Maximize is not correct.
Last edited by infratec on Sat Jul 27, 2024 10:13 pm, edited 3 times in total.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4991
Joined: Sun Apr 12, 2009 6:27 am

Re: Windows window size bug or not?

Post by RASHAD »

Hi Berned
This case was discussed before
Use SizeGadget and DPI aware to get the right width and height and shown taskbar

Code: Select all

Enable DPI
  dpix.f = DesktopResolutionX()
  dpiy.f = DesktopResolutionY()

;OpenWindow(0, 0, 0, 0, 0, "", #PB_Window_MaximizeGadget|#PB_Window_Maximize)
OpenWindow(0, 0, 0, 0, 0, "", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_Maximize)
Debug Str(WindowWidth(0)*dpix) + "/" + Str(WindowHeight(0)*dpiy)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Egypt my love
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Windows window size bug or not?

Post by infratec »

I have no screen scaling. Which means it is 100%.

Your code returns 1.0 for dpix and dpiy

DPI in PB 6.11 is enabled by default.
Post Reply