Opened 17 years ago
Closed 17 years ago
#372 closed Bug (No Bug)
Parent GUI of -1 causes dramatic problems
Reported by: | MeJonah@… | Owned by: | |
---|---|---|---|
Milestone: | Component: | AutoIt | |
Version: | 3.2.12.0 | Severity: | None |
Keywords: | Cc: |
Description
$gui = guicreate("TEST", 100, 100, default, default, default, default, -1)
not even sure how to describe the results precisely- screen starts flickering and no windows will response. Pressing control-alt-delete allows all windows to paint once then they stop responding again. You can terminate the program by pressing control-alt-delete, then clicking on the autoit3.exe on the task manager that comes up, then pressing control-alt-delete so that it registers the click, the pressing terminate, then pressing control alt delete so it registers, then clicking on the yes option.
Present in 3.2.12, and I think it started in the RC for this build because had code that suddenly started doing this.
Tested on Windows XP Pro SP3.
Attachments (0)
Change History (8)
comment:1 Changed 17 years ago by jpm
comment:2 Changed 17 years ago by MeJonah@…
The single line I listed will repro consistently for me.
I am running with dual monitors, if it makes any difference.
comment:3 Changed 17 years ago by Valik
Sounds like you are out of GDI resources. Something else is at fault here. The script you demonstrate should only run for a few milliseconds and then close since you haven't instructed it to stay open. If it's doing anything other than that, and if it's affecting other windows, then you've got a larger issue somewhere else.
comment:4 Changed 17 years ago by MeJonah@…
Just tested on several other computers. Confirmed same behavior on Windows XP Pro SP2, SP3, Windows Vista Business. Some with dual monitors, some without.
I realize that there is no loop to keep the script running, but never-the-less it does not terminate until killed from the task manager.
Same behavior comes from running script or running "compiled" executable.
comment:5 Changed 17 years ago by Valik
Wait a minute, you're passing -1 as an HWND. That's stupid and just plain wrong. Certainly we can guard you from yourself, but do we really have to protect you guys from every single possible obscure and stupid way to shoot yourself in the foot?
I don't care if it worked in the past, you should not pass -1 as the parent HWND. Either pass 0 or a valid HWND.
comment:6 Changed 17 years ago by MeJonah@…
I think I got to using that a long time ago, noting that -1 was the flag for default for many functions (was there a time when there was no default keyword? Seems like it was back then?). I have functions that create windows that sometimes have a parent GUI and some times do not, so I used -1 to indicate default if I didn't want a parent GUI.
I have since changed them all to 0, so it isn't a problem for me anymore. If this is expected behavior then nevermind.
comment:7 Changed 17 years ago by Valik
I wouldn't say that Windows freaking out is expected (though honestly if my theory as to what's going on is right, then yes, I actually do expect it*). But weird things happening isn't unexpected.
Unless we document that you can pass -1, be careful. Sometimes it doesn't make sense to pass -1, for example, when a numeric value is specified and -1 is a valid input. Or, when -1 is a reserved value by the system for something special. Don't just blindly pass -1 assuming it works everywhere because that is not true.
I'm going to leave this open for now in case somebody wants to prevent this internally.
- -1 is the same as HWND_BROADCAST. This is a special "HWND" used to send a message to all top-level windows in the system. CreateWindowEx() likely uses SendMessage(hParent, ...) to query the parent window for information about the parent before constructing (or after constructing) the child. But, since you passed HWND_BROADCAST as the parent, these messages are sent to every top-level window in the system. And for some reason it gets itself stuck in an infinite loop sending a message to all top-level windows. This is my theory, anyway, I didn't bother verifying it with something like Spy++ because it's obviously difficult to use the system under those circumstances (and it's not important enough for me to test remotely).
comment:8 Changed 17 years ago by Jon
- Resolution set to No Bug
- Status changed from new to closed
It's not documented that -1 is OK here, so I'm ok with it and don't think it needs a check. Closing as no bug.
Guidelines for posting comments:
- You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
- In-depth discussions should take place on the forum.
For more information see the full version of the ticket guidelines here.
can you attach a complete repro script? Thanks