Re: Window moves by itself
Posted: Thu Mar 16, 2017 3:47 pm
LOL
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
OpenWindow(0, 100, 100, 200, 100, "Test", #PB_Window_SystemMenu)
ButtonGadget(0, 5, 5, 100, 25, "Click")
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
If EventGadget() = 0
Delay(10000)
EndIf
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
Because it just results in the same thing ? Not processing events ? Is that a surprise ?nco2k wrote:it can also happen if you have an event loop, but block your app from processing it for too long.
Where did you read the OS does that when a program is not processing the event queue ?nco2k wrote: after a while the window will move a bit, to notify the user that the app is not responding
Yes, but that not explain why the window is shown in another position, the reason for that is another one.chi wrote:The misaligned window is not the original window, it's the ghost window!
what are you trying to tell me here? i was just responding to Thunder93's statement that he never noticed this behavior, because he always uses an event loop. so no idea why you are even quoting this.DontTalkToMe wrote:Because it just results in the same thing ? Not processing events ? Is that a surprise ?
i didnt, it was just an observation. every app that wasnt specifically targeting vista/7 was behaving this way, which is totally normal behavior.DontTalkToMe wrote:Where did you read the OS does that when a program is not processing the event queue ?
well, they choose to implement it like that. not the first weird decission of microsoft, wont be the last one either.DontTalkToMe wrote:Yes, but that not explain why the window is shown in another position, the reason for that is another one
correct, when you specifically target vista/7, then the ghosting window should stay at the same position. no idea how win8/10 behaves, since i dont use either one of those two.DontTalkToMe wrote:People experiencing this should try to link with /subsystem:windows,6.0 and see if the windows still move.
That is because with Aero enabled the windows X and Y isn't 100, 100 as requested, it's 95, 95 (only visually). For some reasons (MS bug maybe) the ghost window doesn't behave like the real window and shows at 100, 100. That's why it's "moving". If you use SetWindowTheme_(WindowID(0), #Null$, "") to disable the theme, the window doesn't move (but the ghost window is still themed).Yes, but that not explain why the window is shown in another position
Code: Select all
OpenWindow(0, 0, 0, 200, 100, "Test", #PB_Window_SystemMenu) ;|#PB_Window_SizeGadget
;SetWindowTheme_(WindowID(0), #Null, "")
ButtonGadget(0, 5, 5, 100, 25, "Click")
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
If EventGadget() = 0
Delay(10000)
EndIf
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
The code I posted was just a quick example before bed. Even with an event loop, the window still moves around by itself:MrMat wrote:it is just the lack of event loop... Adding that in is fine.
Code: Select all
OpenWindow(1,10,10,50,50,"")
OpenWindow(2,100,10,50,50,"")
OpenWindow(3,200,10,50,50,"")
Sleep_(2000) ; Click Calculator during this time!
GetForegroundWindow_()
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
consensus, not mine.Dude wrote:So the consensus seems to be that we can't use any non-event delays in our apps, lest our windows start moving by themselves.That's something I never knew before.
Code: Select all
#GetForegroundWindow = 1
OpenWindow(1,10,10,50,50,"")
OpenWindow(2,100,10,50,50,"")
OpenWindow(3,200,10,50,50,"")
AddWindowTimer(1, #GetForegroundWindow, 2000)
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Timer And EventTimer() = #GetForegroundWindow
Debug "Timer Triggered"
Debug "Window #: "+EventWindow()
GetForegroundWindow_()
RemoveWindowTimer(EventWindow(), #GetForegroundWindow)
EndIf
Until Event = #PB_Event_CloseWindow
Code: Select all
OpenWindow(0, 100, 100, 200, 100, "Test", #PB_Window_BorderLess|#PB_Window_TitleBar)
SetWindowColor(0, RGB(255, 0, 35))
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
Code: Select all
OpenWindow(0, 100, 100, 200, 100, "Test", #PB_Window_BorderLess|#PB_Window_TitleBar)
StickyWindow(0, 1)
Delay(99999)
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow