Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

AutoHotkey_L v1.1.04


  • Please log in to reply
47 replies to this topic
  • Guests
  • Last active:
  • Joined: --

No - depending on how you use it. Moreover, it is necessary for creating multiple unnamed GUIs (see here):

Loop, 2 {

	x := A_Index*250

	Gui, New, ToolWindow LabelGui HWNDGui%A_Index%, Window%A_Index%

	Gui, Show, x%x% y100 w200 h100

}

return



GuiClose:

	ExitApp

Interesting, but isn't it inconsistent? I think unnamed GUI means a GUI witch uses a blank name. So, I expected this would do the same, but it does't.
Loop, 2 {

   x := A_Index*250

   Gui, test:New, ToolWindow LabelTest HWNDGui%A_Index%, Window%A_Index%

   Gui, test:Show, x%x% y100 w200 h100

}

return



TestClose:

   ExitApp


jethrow
  • Moderators
  • 2854 posts
  • Last active: May 17 2017 01:57 AM
  • Joined: 24 May 2009

I think unnamed GUI means a GUI which uses a blank name.

No - that would mean there could only be one unnamed GUI. I think you're thinking of the Default GUI. Perhaps I should have used the HWND to reference the GUI in my example:
Loop, 2 {
   x := A_Index*250
   Gui, New, ToolWindow LabelGui HWNDGui%A_Index%, Window%A_Index%
   Gui, % [color=red]Gui%A_Index%[/color] ": Show", x%x% y100 w200 h100 ; Gui%A_Index% contains the HWND
}
return

GuiClose:
   ExitApp
In your example above, the second loop iteration creates a new GUI named "test", which destroys the first one.

  • Guests
  • Last active:
  • Joined: --
OK, when a Window handle is used before the colon sign, it doesn't destroy. On the other hand, when a Gui name is used instead, it destroys. It is really confusing and looks an inconsistent design to me. It leads me to a question, what's the point of using named GUI if all of created GUI can be handled better with their window handles?

jethrow
  • Moderators
  • 2854 posts
  • Last active: May 17 2017 01:57 AM
  • Joined: 24 May 2009

OK, when a Window handle is used before the colon sign, it doesn't destroy. On the other hand, when a Gui name is used instead, it destroys.

It's destroyed if it uses the same Name. My example uses different HWNDs - since it is a Unique Window Identifier:
Loop, 2 {
   x := A_Index*250
   Gui, New, ToolWindow LabelGui HWNDGui%A_Index%, Window%A_Index%
   t .= "LOOP #" A_Index " GUI HWND = " Gui%A_Index% "`n"
   Gui, % Gui%A_Index% ": Show", x%x% y100 w200 h100 ; Gui%A_Index% contains the HWND
}
MsgBox, %t%
return

GuiClose:
   ExitApp

It leads me to a question, what's the point of using named GUI if all of created GUI can be handled better with their window handles?

Good question :wink: . Tradition & Simplicity.

  • Guests
  • Last active:
  • Joined: --
OK, they use different HWNDs so it's all about unnamed GUI. By the way, when was unnamed GUI supported?

Tradition & Simplicity.

If you really care about them, the current design/behaviour of Gui, New should be reviewed. Or named/numbered GUI support should be dropped, that's much simpler.

  • Guests
  • Last active:
  • Joined: --

Loop, 2 {

	x := A_Index*250

	Gui, New, ToolWindow LabelGui HWNDGui%A_Index%, Window%A_Index%

	Gui, Show, x%x% y100 w200 h100

}

return



GuiClose:

	ExitApp

I think this is just fine.
Loop, 2 {

   x := A_Index*250

   Gui, %A_Index%: +ToolWindow LabelGui HWNDGui%A_Index%

   Gui, %A_Index%: Show, x%x% y100 w200 h100, Window%A_Index%

}

return



GuiClose:

   ExitApp


JSLover
  • Members
  • 920 posts
  • Last active: Nov 02 2012 09:54 PM
  • Joined: 20 Dec 2004

Isn't Gui, New just redundant?

...it more explicitly gives you a place to set the new Gui's options & title...without having to Show it 1st.

I don't see the point of using this.

...then don't use it. I wanted this for a long time!

Why should it?

...because, as in my examples, Gui, New is expected to be used at the beginning of a Gui-building section...it's counter-intuitive to NOT set the "default Gui" for the rest of the Gui-building code.

IMO, if you are creating a named GUI, best practice would be to continue to reference that GUI using it's name.

...NO!...that would create really annoying redundant code, which Gui, :Default was designed to eliminate.

Gui, ReallyAnnoyingExample:New
Gui, ReallyAnnoyingExample:Add, Text, , Really, this is annoying & redundant.
Gui, ReallyAnnoyingExample:Show
...using "ReallyAnnoyingExample:" on EVERY Gui statement is, well, really annoying...& redundant.

It don't even matter, if the default behavior sucks, then I'll just use my Gui_New() function...& make it do what I want. I was trying to fight for good default behavior for everyone else, but I guess no one wants to write code like I do...so, whatever.

At least named-Gui's & "Gui, New" exists, with that I can create my Gui-functions to do things the way I want.
Useful forum links: New content since: Last visitPast weekPast 2 weeks (links will show YOUR posts, not mine)

OMFG, the AutoHotkey forum is IP.board now (yuck!)...I may not be able to continue coming here (& I love AutoHotkey)...I liked phpBB, but not this...ugh...

Note...
I may not reply to any topics (specifically ones I was previously involved in), mostly cuz I can't find the ones I replied to, to continue helping, but also just cuz I can't stand the new forum...phpBB was soo perfect. This is 100% the opposite of "perfect".

I also semi-plan to start my own, phpBB-based AutoHotkey forum (or take over the old one, if he'll let me)
PM me if you're interested in a new phpBB-based forum (I need to know if anyone would use it)
How (or why) did they create the Neil Armstrong memorial site (neilarmstronginfo.com) BEFORE he died?

  • Guests
  • Last active:
  • Joined: --

Isn't Gui, New just redundant?

...it more explicitly gives you a place to set the new Gui's options & title...without having to Show it 1st.

What's wrong with +LastFound? It creates a GUI without showing it.
Gui, +LastFound
Also options can be set without showing it first.
Gui, +LastFound +ToolWindow LabelGui 
Gui, Show, w100 h100
Now we have to deal with confusing unnamed Gui which used be 1: Gui by default.

...then don't use it. I wanted this for a long time!

...it doesn't mean others also wanted it.

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009

Why should it?

...because, as in my examples, Gui, New is expected to be used at the beginning of a Gui-building section...it's counter-intuitive to NOT set the "default Gui" for the rest of the Gui-building code.

IMO, if you are creating a named GUI, best practice would be to continue to reference that GUI using it's name.

...NO!...that would create really annoying redundant code, which Gui, :Default was designed to eliminate.

I would like to say that I believe Guest is more correct in terms of best practice. It can easily happen that some code sneaks in between during refactoring that changes the default GUI. In that case this could easily lead to bugs. I agree that referencing the GUI each time can get annoying, so maybe you should try my OOP GUI library where you can simply work with GUI objects :) .

aSEioT
  • Members
  • 87 posts
  • Last active:
  • Joined: 31 Oct 2010
Gui, New, hWndhGUI
Is really convinient for us to create a unnamed GUI, and it is great! But I just notice, when we create the GUI use this command, the +Owenr is not working after that. Can this be changed in the future?
Sorry for my noice, it actually worked.
Gui, New, hWndhGUI
Gui, hGui: Show, h200 w400
Gui, New, hWndhGUI2
;Gui, % hGui2 ": +Owner" hGui		; used to be worked, but now is doesn't, Plz reenable this!
Gui, hGui2: +OwnerhGui
Gui, hGui2:Show, h100 w200
Ok, after another trial, I finally found it is nothing to do with +Owner, but the way of current GUI designed.
Gui, New, hWndhGUI
Gui, hGui: Show, h200 w400
Gui, New, hWndhGUI2
tmp := hGUI2
Gui, hGui2: +OwnerhGui
; Gui, % tmp ":Show", h100 w200		 ; tmp actually havn't any effects in this situation, it equal to Gui : Show, h100 w200
; Gui, tmp:Show, h100 w200					; also it not recognize the by auto deref the content of var
Gui, hGui2:Show, h100 w200					; this is only choice for us?
:(

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

But I just notice, when we create the GUI use this command, the +Owenr is not working after that. Can this be changed in the future?

No. 1) +Owenr isn't a valid option. :p 2) +Owner was never supported after creating the GUI. 3) Use +Owner in the options passed to Gui, New.

(but once the window is created, -Owner has no effect). (...) +Owner must be used after the window's owner is created but before the owned window is created



fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
it's.easily possible to support it later on though by calling SetWindowLong(Ptr).

aSEioT
  • Members
  • 87 posts
  • Last active:
  • Joined: 31 Oct 2010

2) Owner was never supported after creating the GUI.

It actually could, as I showed in the demo code.

just me
  • Members
  • 1496 posts
  • Last active: Nov 03 2015 04:32 PM
  • Joined: 28 May 2011
... names are names and variables are variables:
Gui, New, hWndhGUI1
Gui, Show, h200 w400 ; or Gui, [color=red]%[/color]hGUI1[color=red]%[/color]:Show, h200 w400
Gui, New, hWndhGUI2 +Owner[color=red]%[/color]hGUI1[color=red]%[/color]
Gui, Show, h100 w200 ; or Gui, [color=red]%[/color]hGUI2[color=red]%[/color]:Show, h100 w200
Return
GuiCLose:
ExitApp
(I was struggling with this issue for some time too. :wink:)

guest3456
  • Members
  • 1704 posts
  • Last active: Nov 19 2015 11:58 AM
  • Joined: 10 Mar 2011

Isn't Gui, New just redundant?

...it more explicitly gives you a place to set the new Gui's options & title...without having to Show it 1st.


if this is the sole reason for it, there has been the option for a long time to do:

Gui, Show, Hide [more options]