PB 6.21 : #PB_Ignore BUG ?

Post bugreports for the Windows version here
User avatar
Blue
Addict
Addict
Posts: 966
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

PB 6.21 : #PB_Ignore BUG ?

Post by Blue »

In the following short code, you will see that #PB_Ignore always returns the same value for X and Y parameters, no matter which one it is asked to replace.

Is that the expected behaviour ?

PS: UHD monitor with "Enable DPI aware" CHECKED. But I don't think that's relevant.

Code: Select all

;
; ------------------------------------
; #PB_Ignore BUG ? 
; Blue August 2025 
; from PureBasic Window example file
; ------------------------------------
;
  #winW  = 320 : #winH  = 260
  #winX  = 234 : #winY  = 200
  #gX = 10 : #gW = 310 : #gH = 20

If OpenWindow(0, #winX, #winY, #winW, #winH, "Window #0", #PB_Window_SystemMenu)
  gY = 10
  TextGadget(00,#gX,gY,#gW,#gH, "Reference window positionned at (" + WindowX(0) + "," + WindowY(0)+")")
  gY + #gh + 2
  TextGadget(01,#gX,gY,#gW,#gH, "as requested. Nothing wrong here.")
  gY + #gh + 2
  TextGadget(02,#gX,gY,#gW,#gH, "But look at the others...")
EndIf

If OpenWindow(1, #winX, #PB_Ignore, #winW, #winH, "Window #1", #PB_Window_SystemMenu)
  gY = 10
  TextGadget(10,#gX,gY,#gW,#gH, "Ah ah! This window ")
  gY + #gh + 2
  TextGadget(11,#gX,gY,#gW,#gH, "is NOT at the requested X position. (" + #winX +").")
  gY + #gh + 2
  TextGadget(12,#gX,gY,#gW,#gH, "It is at (" + WindowX(1) + "," + WindowY(1)+"),")
  gY + #gh + 2
  TextGadget(13,#gX,gY,#gW,#gH, "but it should be at (" + #winX + ","+ WindowX(1) +")")
EndIf

If OpenWindow(2, #PB_Ignore, #winY, #winW, #winH, "Window #2", #PB_Window_SystemMenu)
  gY = 10
  TextGadget(20,#gX,gY,#gW,#gH, "Ah ah! This window ")
  gY + #gh + 2
  TextGadget(21,#gX,gY,#gW,#gH, "is NOT at the requested Y position (" + #winY +").")
  gY + #gh + 2
  TextGadget(22,#gX,gY,#gW,#gH, "It is at (" + WindowX(2) + "," + WindowY(2)+"),")
  gY + #gh + 2
  TextGadget(23,#gX,gY,#gW,#gH, "but it should be at ("+WindowX(2) +","+ #winY +")")
  Repeat
    event = WaitWindowEvent()
    If event = #PB_Event_CloseWindow
      Break
    EndIf
  ForEver
EndIf

End
PB Forums : Proof positive that 2 heads (or more...) are better than one :idea:
Axolotl
Addict
Addict
Posts: 819
Joined: Wed Dec 31, 2008 3:36 pm

Re: PB 6.21 : #PB_Ignore BUG ?

Post by Axolotl »

Well, I guess this is a tricky question.
First I have to admit that I have no idea how the OpenWindow() is working inside, so I made some assumptions.

Code: Select all

; First 
If x = #PB_Ignore 
  x = #CW_USEDEFAULT ; the original constant for windowsOS CreateWindowEx_() 
EndIf
If y = #PB_Ignore
  y = #CW_USEDEFAULT 
EndIf 

; Second 
; 
Procedure OpenWindow()    
; .....
  Flags = #WS_VISIBLE|#WS_OVERLAPPEDWINDOW
;.....
  hWnd = CreateWindowEx_(#WS_EX_WINDOWEDGE, #ClassName$, Caption$, Flags, X, Y, .....) 
; .....
EndProcedure 

Under these circumstances, the following help text (perhaps) provides an explanation for the behavior.
Parameter: X and Y (borrowed from MSDN....)

The initial horizontal position of the window.
For an overlapped or pop-up window, the x parameter is the initial x-coordinate of the window's upper-left corner, in screen coordinates.
If x is set to CW_USEDEFAULT, the system selects the default position for the window's upper-left corner and ignores the y parameter. CW_USEDEFAULT is valid only for overlapped windows; if it is specified for a pop-up or child window, the x and y parameters are set to zero.

If an overlapped window is created with the WS_VISIBLE style bit set and the x parameter is set to CW_USEDEFAULT, then the y parameter determines how the window is shown. If the y parameter is CW_USEDEFAULT, then the window manager calls ShowWindow with the SW_SHOW flag after the window has been created. If the y parameter is some other value, then the window manager calls ShowWindow with that value as the nCmdShow parameter.
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
User avatar
Blue
Addict
Addict
Posts: 966
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Re: PB 6.21 : #PB_Ignore BUG ?

Post by Blue »

You're right, Axolotl.

This is NOT a bug !

My expectations were wrong.
PB Forums : Proof positive that 2 heads (or more...) are better than one :idea:
Post Reply