[Solved] Weird window resize issue

Everything else that doesn't fall into one of the other PB categories.
BarryG
Addict
Addict
Posts: 4308
Joined: Thu Apr 18, 2019 8:17 am

[Solved] Weird window resize issue

Post by BarryG »

I've got a window created with the following flags, but as you can see in the screenshots, the last image shows the bottom-right corner never with a diagonal resize arrow, even though the first image shows a diagonal resize arrow. If I put the mouse at the bottom-right corner, it only allows resizing horizontally, and not vertically as well. But the bottom-left corner allows both horizontal and vertical.

Why just the bottom-left and not the bottom-right of the window? Doesn't make sense. Part of a bigger app and I can't recreate it with a snippet. :(

And yes, it must be a tool window so there's no button in the taskbar for it. I don't want an "X" close button either, hence no #PB_Window_SystemMenu.

Code: Select all

OpenWindow(#win,0,0,minw,minh,"Drag and size...",#PB_Window_Tool|#PB_Window_SizeGadget)
Image
Last edited by BarryG on Sun Jan 11, 2026 2:50 am, edited 1 time in total.
User avatar
Michael Vogel
Addict
Addict
Posts: 2836
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: Weird window resize issue

Post by Michael Vogel »

Can't be reproduced here, neither with "Modern Theme support" on or off. Windows 11, PB 6.21 64 bit.

Maybe you'd have to move the mouse cursor some pixels down do the shadow area?

Code: Select all

#Win=0
minw=200
OpenWindow(#win,0,0,minw,minh,"Drag and size...",#PB_Window_Tool|#PB_Window_SizeGadget)

Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
BarryG
Addict
Addict
Posts: 4308
Joined: Thu Apr 18, 2019 8:17 am

Re: Weird window resize issue

Post by BarryG »

I've tried slowly moving the mouse all around the bottom-right corner, including in and out of it by around 20 pixels. Doesn't show a diagonal arrow like it does when I make the same mouse movements on the bottom-left side. Doesn't make sense. If it works on one side, it should also work on the other. I wonder if it's a Windows (the OS) issue.
BarryG
Addict
Addict
Posts: 4308
Joined: Thu Apr 18, 2019 8:17 am

Re: Weird window resize issue

Post by BarryG »

Worked it out! In my main app, I was also doing this to the window:

Code: Select all

SetWindowLongPtr_(win_hWnd,#GWL_EXSTYLE,GetWindowLongPtr_(win_hWnd,#GWL_EXSTYLE)|#WS_EX_LAYERED)
SetLayeredWindowAttributes_(win_hWnd,#Blue,0,#LWA_COLORKEY)
SetWindowColor(#win,#Blue)
If I comment that out, then the bottom-right corner DOES show a resize diagonal icon. Maybe this is a PureBasic bug? If not, how can I make this work?

Here's a standalone snippet (finally!) to show the problem.

Does anyone know how to make the bottom and bottom-right resize work? Basically I want a moveable and sizable see-through (not transparent) window. Thanks!

Code: Select all

#win=0
size=200
OpenWindow(#win,size,size/2,size,size/2,"Drag and size...",#PB_Window_Tool|#PB_Window_SizeGadget)

win_hWnd=WindowID(#win)
SetWindowLongPtr_(win_hWnd,#GWL_EXSTYLE,GetWindowLongPtr_(win_hWnd,#GWL_EXSTYLE)|#WS_EX_LAYERED)
SetLayeredWindowAttributes_(win_hWnd,#Blue,0,#LWA_COLORKEY)
SetWindowColor(#win,#Blue)

Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
Last edited by BarryG on Sat Jan 10, 2026 12:27 pm, edited 1 time in total.
Little John
Addict
Addict
Posts: 4829
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Weird window resize issue

Post by Little John »

BarryG wrote: Sat Jan 10, 2026 8:15 am Basically I want a moveable and sizable transparent window.
This works here as wanted (with PB 6.21 (x64) on Windows 11):
viewtopic.php?t=55536

... also when using

Code: Select all

OpenWindow(0, 0, 0, 230, 90, "Demo", #PB_Window_Tool | #PB_Window_SizeGadget)
BarryG
Addict
Addict
Posts: 4308
Joined: Thu Apr 18, 2019 8:17 am

Re: Weird window resize issue

Post by BarryG »

Not the same thing, Little John. My bad for using the word "transparent" instead of "see-through". Edited my other post. Try my code above to see what I'm asking.
User avatar
ChrisR
Addict
Addict
Posts: 1538
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: Weird window resize issue

Post by ChrisR »

A workaround, but not really great

Code: Select all

#win1=0
#win2=1
size=200

Procedure Resize_Window1()
  ResizeWindow(#win2, WindowX(#win1), WindowY(#win1), WindowWidth(#win1), WindowHeight(#win1))
  SetActiveWindow(#win1)
EndProcedure

Procedure Resize_Window2()
  ResizeWindow(#win1, WindowX(#win2), WindowY(#win2), WindowWidth(#win2), WindowHeight(#win2))
  SetActiveWindow(#win1)
EndProcedure

OpenWindow(#win1,size,size/2,size,size/2,"Drag and size...",#PB_Window_Tool|#PB_Window_SizeGadget)
OpenWindow(#win2,size,size/2,size,size/2,"Drag and size...",#PB_Window_Tool|#PB_Window_SizeGadget)
SetWindowColor(#win1,#Blue)

win_hWnd1=WindowID(#win1)
win_hWnd2=WindowID(#win2)
SetWindowLongPtr_(win_hWnd2,#GWL_EXSTYLE,GetWindowLongPtr_(win_hWnd2,#GWL_EXSTYLE)|#WS_EX_LAYERED)
SetWindowLongPtr_(win_hWnd1,#GWL_EXSTYLE,GetWindowLongPtr_(win_hWnd1,#GWL_EXSTYLE)|#WS_EX_LAYERED)
SetLayeredWindowAttributes_(win_hWnd1,#Blue,0,#LWA_COLORKEY)
SetLayeredWindowAttributes_(win_hWnd2,0,1,#LWA_ALPHA)
SetActiveWindow(#win1)
StickyWindow(#win1, #True)

BindEvent(#PB_Event_MoveWindow, @Resize_Window1(), #win1)
BindEvent(#PB_Event_SizeWindow, @Resize_Window1(), #win1)
BindEvent(#PB_Event_MoveWindow, @Resize_Window2(), #win2)
BindEvent(#PB_Event_SizeWindow, @Resize_Window2(), #win2)

Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
#2

Code: Select all

Procedure SizeWindow()
  If StartDrawing(WindowOutput(EventWindow()))
    Box(0,0,OutputWidth(), OutputHeight(), #Gray)
    RoundBox(8,0,OutputWidth()-16, OutputHeight()-40, 4, 4, #Blue) 
    StopDrawing()
  EndIf
EndProcedure

#win=0
size=200
OpenWindow(#win,size,size/2,size,size/2,"Drag and size...",#PB_Window_Tool|#PB_Window_SizeGadget)

win_hWnd=WindowID(#win)
SetWindowLongPtr_(win_hWnd,#GWL_EXSTYLE,GetWindowLongPtr_(win_hWnd,#GWL_EXSTYLE)|#WS_EX_LAYERED)
SetLayeredWindowAttributes_(win_hWnd,#Blue,0,#LWA_COLORKEY)
BindEvent(#PB_Event_SizeWindow, @SizeWindow(), #win)
PostEvent(#PB_Event_SizeWindow, #win, -1)

Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
User avatar
minimy
Addict
Addict
Posts: 826
Joined: Mon Jul 08, 2013 8:43 pm
Location: off world

Re: Weird window resize issue

Post by minimy »

Hi BarryG, I don't know if you mean this exactly, maybe I misunderstood. This work for me.
As far as I know you can't rescale using the edges of a window #PB_Window_Tool

Code: Select all

#winMain=0:#win=1:size=200
OpenWindow(#winMain,0,0,size,size,"Main",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindow(#win,0,0,size/2,size/2,"Drag and size...",#PB_Window_SizeGadget|#PB_Window_ScreenCentered,WindowID(#winMain))

win_hWnd=WindowID(#win)
SetWindowLongPtr_(win_hWnd,#GWL_EXSTYLE,GetWindowLongPtr_(win_hWnd,#GWL_EXSTYLE)|#WS_EX_LAYERED)
SetLayeredWindowAttributes_(win_hWnd,#Blue,0,#LWA_COLORKEY):SetWindowColor(#win,#Blue)

Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
If translation=Error: reply="Sorry, Im Spanish": Endif
BarryG
Addict
Addict
Posts: 4308
Joined: Thu Apr 18, 2019 8:17 am

Re: [Solved] Weird window resize issue

Post by BarryG »

I can mark this as Solved. :) Both ChrisR's examples work great, and minimy's works until I drag the window off the "Main" window under it (the edges stop letting me drag at that point, until I move the "Main" window back under the "Drag and size" window again). Weird that the see-through window needs another window under it to do the job.
User avatar
minimy
Addict
Addict
Posts: 826
Joined: Mon Jul 08, 2013 8:43 pm
Location: off world

Re: [Solved] Weird window resize issue

Post by minimy »

BarryG wrote: Sun Jan 11, 2026 2:52 am I can mark this as Solved. :) Both ChrisR's examples work great, and minimy's works until I drag the window off the "Main" window under it (the edges stop letting me drag at that point, until I move the "Main" window back under the "Drag and size" window again). Weird that the see-through window needs another window under it to do the job.
This work without main window too. Sorry for the extra code added.

Code: Select all

#win=1:size=200
OpenWindow(#win,0,0,size/2,size/2,"Drag and size...",#PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
win_hWnd=WindowID(#win)
SetWindowLongPtr_(win_hWnd,#GWL_EXSTYLE,GetWindowLongPtr_(win_hWnd,#GWL_EXSTYLE)|#WS_EX_LAYERED)
SetLayeredWindowAttributes_(win_hWnd,#Blue,0,#LWA_COLORKEY):SetWindowColor(#win,#Blue)
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
If translation=Error: reply="Sorry, Im Spanish": Endif
User avatar
Michael Vogel
Addict
Addict
Posts: 2836
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: [Solved] Weird window resize issue

Post by Michael Vogel »

Barry, I was wondering why your code does not work - I've had written a similar code some years ago...
...so I checked my old program and it shows the same effect like yours (when using PB6.21).

My observations after some more testing:
- your code does work with older compilers (checked with PB 5.73)
- your code does work with newer compilers as well (modern theme support disabled)
- your code does not work with newer compilers and active modern theme support
User avatar
ChrisR
Addict
Addict
Posts: 1538
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: [Solved] Weird window resize issue

Post by ChrisR »

Thanks Michael, I confirm that, to be picky, if that helps to fix it:
It also worked with PB 6.00 but no longer since PB 6.01
And to make it works with PB 6.01 and later compilers, in addition to the modern theme support disabled, DPI aware must also be disabled.
breeze4me
Enthusiast
Enthusiast
Posts: 655
Joined: Thu Mar 09, 2006 9:24 am
Location: S. Kor

Re: [Solved] Weird window resize issue

Post by breeze4me »

Removing the following three compatibility-related items from the manifest resource of the compiled executable file resolves the issue, but doing so will likely cause compatibility problems on Windows 8 and later versions.
On Windows 8 and later versions, it appears that the internal layered window handling mechanism has changed.
So it seems better to just use a workaround.

Windows 10 and Windows 11
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
Windows 8.1
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
Windows 8
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
Post Reply