Very nice replication, by the way!Alguimist wrote:With the advent of Tab3, the Tab2 will not be deprecated though, because it allows controls to be created outside the tab control, which can be very useful in some cases, for example, in a settings dialog, as follows:
Obsolete test build - Tab3 control with autosizing, SetTimer improvements
Re: New test builds - Tab3 control, Menu improvements, LoadPicture, new vars
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: New test builds - Tab3 control, Menu improvements, LoadPicture, new vars
Sorry, my bad.lexikos wrote:No. I was, for a short time a few weeks ago.
Yes, that's what I do in this case. And it actually reduces flickering dramatically. But I remember some discussions about AHK's 'noob-friendliness'.lexikos wrote:If that was the cause, you could just set the bitmap via STM_SETIMAGE.
Re: New test builds - Tab3 control, Menu improvements, LoadPicture, new vars
On my slow Windows 7 system and my fast Windows 10 system, it makes absolutely no difference. Either way (via STM_SETIMAGE or GuiControl), the control's background is erased when the picture changes, causing the same amount of flicker.
Re: New test builds - Tab3 control, Menu improvements, LoadPicture, new vars
Currently I'm running Win 10 on a lenovo Ideapad with a Core i3 2310-M CPU @ 2.10 GHz, 4 GB RAM, and Intel HD Graphics 3000. With STM_SETIMAGE (which I'm using since Win XP) and even with the new optionHBITMAP:... I can observe almost no flickering here, whereas GuiControl, , Pic, %PicPath% clearly flickers.lexikos wrote:... it makes absolutely no difference
Code: Select all
#NoEnv
SetBatchLines, -1
Pics := []
Loop, Files, %A_WinDir%\Web\Wallpaper\*.jpg, R
{
Pics.Push(A_LoopFileLongPath)
If (Pics.Length() > 5)
Break
}
Gui, Add, Pic, w600 h-1 vPic AltSubmit, % Pics.1
Gui, Add, Button, gChangeGui, Change using GuiControl
Gui, Add, Button, x+10 yp wp gChangeHBM, Change using HBITMAP
Gui, Show, , Test
Return
GuiClose:
GuiEscape:
ExitApp
ChangeGui:
Random, Idx, 1, 5
GuiControl, , Pic, % Pics[Idx]
Return
ChangeHBM:
Random, Idx, 1, 5
HBM := LoadPicture(Pics[Idx])
GuiControl, , Pic, HBITMAP:%HBM%
Return
Re: New test builds - Tab3 control, Menu improvements, LoadPicture, new vars
With your previous script, replacing GuiControl with LoadPicture and STM_SETIMAGE made absolutely no difference to the results on my computers.
With your new script, using a filename vs handle makes absolutely no difference on Windows XP. Using LoadPicture on Windows 7/10, it appears to flicker less often. I believe this is due to the timing with which the desktop window manager updates the screen. I suppose that at 60Hz, you have between 0 and 16ms to erase the control's background and paint the new image before the screen updates. Loading the picture from file before calling GuiControl would reduce the time between removing the old bitmap and painting the new one onto the window (or more precisely, the window's off-screen buffer), thereby reducing (but not eliminating) the chance that you will see flicker.
I will see what I can do.
With your new script, using a filename vs handle makes absolutely no difference on Windows XP. Using LoadPicture on Windows 7/10, it appears to flicker less often. I believe this is due to the timing with which the desktop window manager updates the screen. I suppose that at 60Hz, you have between 0 and 16ms to erase the control's background and paint the new image before the screen updates. Loading the picture from file before calling GuiControl would reduce the time between removing the old bitmap and painting the new one onto the window (or more precisely, the window's off-screen buffer), thereby reducing (but not eliminating) the chance that you will see flicker.
I will see what I can do.
Re: New test builds - Tab3 control, Menu improvements, LoadPicture, new vars
Thanks for your efforts. After playing around with the pictures for a while I remembered the other options to reduce flickering. I don't know why I forget them frequently, sorry.
BackgroundTrans (if the images aren't transparent) or GuiControl, -/+Redraw seem to have at least the same effect here. So a hint in the docs to use these option might be sufficient.
BackgroundTrans (if the images aren't transparent) or GuiControl, -/+Redraw seem to have at least the same effect here. So a hint in the docs to use these option might be sufficient.
Re: New test build - Tab3 control
Are you interested in adding built-in support for radio groups?lexikos wrote:v1.1.22.07-19+g6c206a4
Menu improvements:
Added options for the Add and Insert sub-commands. The parameter formerly known as Pn can contain a list of options, with the same syntax as Gui/GuiControl: space/tab delimited, optional + or - prefix.
- Radio: If checked, a bullet point is used instead of a check mark.
...
CheckMenuRadioItem wrote:Checks a specified menu item and makes it a radio item. At the same time, the function clears all other menu items in the associated group and clears the radio-item type flag for those items.
Source
Re: New test builds - Tab3 control, Menu improvements, LoadPicture, new vars
No, I am not interested. It looks trivial to do with DllCall and MenuGetHandle, or even Menu Check/Uncheck and a loop.
Re: New test builds - Tab3 control, Menu improvements, LoadPicture, new vars
LoadPicture():
I am not sure if this is relevant:
Converting single-image ico to png: My first test (using AutoHotkey112207_27_g615a1ce_w.exe) shows that with LoadPicture() the transparency is lost (!) even on newer Windows versions.
https://autohotkey.com/boards/viewtopic.php?f=5&t=10611
I am not sure if this is relevant:
Converting single-image ico to png: My first test (using AutoHotkey112207_27_g615a1ce_w.exe) shows that with LoadPicture() the transparency is lost (!) even on newer Windows versions.
https://autohotkey.com/boards/viewtopic.php?f=5&t=10611
For me as a newbie it is frustrating to fail due to "little" problems in projects in which the entire concept and even complex functions are working perfectly...
Re: New test builds - Tab3 control, Menu improvements, LoadPicture, new vars
No, it's not relevant. LoadPicture preserves the transparency. GdipCreateBitmapFromHBITMAP does not. See other thread.
Re: New test builds - Tab3 control, Menu improvements, LoadPicture, new vars
My conclusion so far for Tab3: works without any problems
Is there a plan to release it?
Is there a plan to release it?
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
Re: New test builds - Tab3 control, Menu improvements, LoadPicture, new vars
It seems that the color parameter of the Gui Font command is being ignored inside a Tab3 for Text and GroupBox controls.
Code: Select all
;Gui Font, s8 Bold c0x0080C0, Segoe UI
Gui Add, Tab3, x0 y0 w241 h238, Tab 1|Tab 2
Gui Font, s8 Bold c0x0080C0, Segoe UI
Gui Add, GroupBox, x9 y25 w221 h203, GroupBox
Gui Add, Edit, x63 y50 w156 h23, Edit
Gui Add, Text, x21 y50 w40 h22 +0x200, Text
Gui Add, ListView, x19 y83 w201 h133, ListView
LV_Add("", "Test")
Gui Show, w239 h237, Window
Return
GuiEscape:
GuiClose:
ExitApp
Re: New test builds - Tab3 control, Menu improvements, LoadPicture, new vars
@jNizM: I intend to look into auto-sizing of the control before releasing it.
@Alguimist: It is overridden by the theme. I'll see if that can be "fixed" without breaking the themed background (which is a gradient on XP).
@Alguimist: It is overridden by the theme. I'll see if that can be "fixed" without breaking the themed background (which is a gradient on XP).
Re: New test build - Tab3 control
I just realized that if you want the bottom edge of the tab control plus the current margin (which would be y+m if the tab control was the previous control), in many cases you can just specify x (absolute or xm) and omit y. It will default to placing the control below the lowest control.I wrote:...jNizM wrote:How can you add the Edit after the tab with y+10 if you dont know how big the Tab is on a non static Gui?
Also, it's actually very easy: just add the y+10 control after the tab control but before the tab's contents, as demonstrated by tab-order.ahk (#2 control). It messes up the tab order for Tab and Tab2, but Tab3 is okay.
Code: Select all
Gui Add, Tab,, One
Gui Add, Text,, Inside the tab control.
Gui Tab
Gui Add, Text, xm, Outside the tab control.
Gui Show
Re: New test builds - Tab3 control, Menu improvements, LoadPicture, new vars
Hello lexikos,
when will the changes regarding to v1.1.22.07-19+g6c206a4 (menues / pictures / icons) be released? Do you already have a timeline? The results of my tests seem to be faultless.
when will the changes regarding to v1.1.22.07-19+g6c206a4 (menues / pictures / icons) be released? Do you already have a timeline? The results of my tests seem to be faultless.
Re: New test builds - Tab3 control, Menu improvements, LoadPicture, new vars
There are some complications with Tab3 auto-sizing and control positioning which I will need to sort out (and test) before integrating Tab3. As my motivation has been low lately, I intend to include only the non-Tab changes in the next release. But first, I have to finish writing the documentation. It could be a few days or a few weeks, depending on my level of interest.
Re: New test builds - Tab3 control, Menu improvements, LoadPicture, new vars
No problem for me.As my motivation has been low lately, I intend to include only the non-Tab changes in the next release.
Well, so what would boost your level of interest in case it's low?It could be a few days or a few weeks, depending on my level of interest.
Re: New test builds - Tab3 control, Menu improvements, LoadPicture, new vars
Maybe a good beer (or two)just me wrote:Well, so what would boost your level of interest in case it's low?It could be a few days or a few weeks, depending on my level of interest.
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
Re: New test builds - Tab3 control, Menu improvements, LoadPicture, new vars
test menu & LoadPicture()
thanks for update!
Code: Select all
BlockInput, On
ToolTip Loading... (ESC=ExitApp)
;********************************************************************************
;BUILD MENU
;********************************************************************************
;Radio Option
Menu, Radio_Option, Add, Item 1, Radio_Option, +Radio
Menu, Radio_Option, Add, Item 2, Radio_Option, +Radio
Menu, Radio_Option, Check, Item 2
Menu, MyMenu, Add, Radio Option, :Radio_Option
;separator line -----------------------
Menu, MyMenu, Add
;CheckMark
Menu, Toggle_Check, Add, Item 1, Toggle_Check
Menu, Toggle_Check, Add, Item 2, Toggle_Check
Menu, Toggle_Check, ToggleCheck, Item 2
Menu, MyMenu, Add, ToggleCheck, :Toggle_Check
;separator line -----------------------
Menu, MyMenu, Add
;+Break and +BarBreak Options
Menu, Menu_Options, Add, Radio, Menu_Options, +Break
Menu, Menu_Options, Add
Menu, Menu_Options, Add, Item 1, Menu_Options, +Radio
Menu, Menu_Options, Add, Item 2, Menu_Options, +Radio
Menu, Menu_Options, Check, Item 2
Menu, Menu_Options, Add, CheckMark, Menu_Options, +Break
Menu, Menu_Options, Add
Menu, Menu_Options, Add, Item 1%A_Space%, Menu_Options
Menu, Menu_Options, Check, Item 1%A_Space%
Menu, Menu_Options, Add, Item 2%A_Space%, Menu_Options
Menu, Menu_Options, Add, Submenu, Menu_Options, +BarBreak
Menu, Menu_Options, Add
Loop, 10
Menu, Options_SubMenu, Add, Item %A_Index%, Options_SubMenu
Menu, Menu_Options, Add, Item 1%A_Space%%A_Space%, :Options_SubMenu
Menu, MyMenu, Add, Options, :Menu_Options
;separator line -----------------------
Menu, MyMenu, Add
;color and icons
Menu, Color_And_Icons, Add, Random Color, Color_And_Icons
Menu, Color_And_Icons, Icon, Random Color, %A_WinDir%\explorer.exe
Menu, Color_And_Icons, Add, Remove Color, Color_And_Icons
Menu, Color_And_Icons, Icon, Remove Color, %A_WinDir%\regedit.exe
Menu, Color_And_Icons, Add
Menu, Color_And_Icons, Add, Hello`, I have a very nice icon, Color_And_Icons
Menu, Color_And_Icons, Icon, Hello`, I have a very nice icon, %A_WinDir%\hh.exe, 1, 0
Menu, Color_And_Icons, Color, Blue
Menu, MyMenu, Add, Menu Color And Icons, :Color_And_Icons
;separator line -----------------------
Menu, MyMenu, Add
;other
Menu, Other_Menu_Insert, Add, i'm alone `;'(, Other_Menu_Insert
Menu, Other_Menu, Add, Insert, :Other_Menu_Insert
Menu, MyMenu, Add, Edit Me`, Please!, :Other_Menu
;separator line -----------------------
Menu, MyMenu, Add
;passing LoadPicture() HANDLE
Count := 1
Loop, Files, %A_WinDir%\*.exe
{ hBitmap%A_Index% := LoadPicture(A_LoopFileFullPath, "GDI+ Icon1")
if !hBitmap%A_Index%
continue
Item_Name := "Item " Count " (" DllCall("Shell32.dll\ExtractIcon", "Ptr", A_ScriptHwnd, "Str", A_LoopFileFullPath, "UInt", -1) ")"
try {
Menu, Bitmap_Or_Icon_Handle, Add, %Item_Name%, Bitmap_Or_Icon_Handle
Menu, Bitmap_Or_Icon_Handle, Icon, %Item_Name%, % "HBITMAP:*" hBitmap%A_Index%,, 0
} catch {
try Menu, Bitmap_Or_Icon_Handle, Delete, %Item_Name%
continue
} Count++
} if (Count>1)
Menu, MyMenu, Add, Bitmaps EveryWhere!, :Bitmap_Or_Icon_Handle
;********************************************************************************
;SHOW MENU
;********************************************************************************
Menu, MyMenu, Add
Menu, MyMenu, Add, Exit%A_Tab%(ESC`, TAB=SHOW), ExitApp
BlockInput, Off
ToolTip
Show_Menu:
Menu, MyMenu, Show, 0, 0
return
;********************************************************************************
;EXITAPP
;********************************************************************************
;exitapp
~Esc::
ExitApp:
ExitApp
~TAB::gosub, Show_Menu
;********************************************************************************
;MENU LABELS
;********************************************************************************
;Radio Option
Radio_Option:
Menu, %A_ThisMenu%, Check, %A_ThisMenuItem%
Menu, %A_ThisMenu%, UnCheck, % A_ThisMenuItem="Item 1"?"Item 2":"Item 1"
gosub, Show_Menu
return
;CheckMark
Toggle_Check:
Menu, %A_ThisMenu%, ToggleCheck, %A_ThisMenuItem%
gosub, Show_Menu
return
;+Right, +Break and +BarBreak Options
Menu_Options:
Options_SubMenu:
gosub, Show_Menu
return
;color and icons
Color_And_Icons:
if (A_ThisMenuItem="Remove Color")
Menu, %A_ThisMenu%, Color
else if (A_ThisMenuItem="Random Color") {
Random, RandColor_Red, 0, 255
Random, RandColor_Green, 0, 255
Random, RandColor_Blue, 0, 255
RandColor_RGB := (RandColor_Red << 16) + (RandColor_Green << 8) + RandColor_Blue
Menu, %A_ThisMenu%, Color, %RandColor_RGB%
} else
ToolTip % A_ThisMenuItem
gosub, Show_Menu
return
;other
Other_Menu:
if (A_ThisMenuItem=="Insert Below Me") {
Menu, %A_ThisMenu%, Insert, % A_ThisMenuItemPos+1 "&", Below You :), Other_Menu, %A_ThisMenu%, Insert,
} else if (A_ThisMenuItem=="Below You :)") {
Loop {
try Menu, %A_ThisMenu%, Rename, %A_ThisMenuItemPos%&, bad boy %A_Index%
catch
continue
break
}
} gosub, Show_Menu
return
Other_Menu_Insert:
Menu, %A_ThisMenu%, Insert, %A_ThisMenuItem%, Insert Below Me, Other_Menu
try Menu, %A_ThisMenu%, Rename, %A_ThisMenuItemPos%&, Thanks!`, My Friend
gosub, Show_Menu
return
;passing LoadPicture() HANDLE
Bitmap_Or_Icon_Handle:
gosub, Show_Menu
return
New test build - autosizing Tab3, SetTimer improvements
v1.1.23.03-13+gfc20377
Tab3
Includes Tab3 control as before, with the addition that its width and/or height (if left unspecified) are automatically calculated based on the contents of the tab control.
These changes may break scripts.
If the Label parameter is completely omitted (not an empty variable or expression), it defaults to the timer which launched the current thread. This should make it much easier for timers which use bound functions to delete themselves (by calling SetTimer,, Delete). Since SetTimer, label behaves like SetTimer, label, On for timers which already exist, SetTimer with no parameters will re-enable the timer which launched the thread.
If Label is an object created by the script (not a function or label) and Period is negative, the timer is deleted automatically after it is run. This occurs after the timer function returns, but only if the timer did not re-enable itself. This is effectively the same as if the timer function calls SetTimer,, Delete. Note that because the timer is deleted, its Period and Priority are not retained, which differs from the previous behaviour. Again, this change does not affect functions or labels.
Previously (since v1.1.01) the default value of Label was %A_ThisLabel%, even if there is no timer running or there is a timer running but it called a function. Scripts that relied on this weird behaviour will break.
If Label is omitted and the current thread was not started by a timer (or the timer has been deleted), an error is raised.
If Label is an expression which resolves to an object or empty string, an error is raised. This is to help debugging, because AutoHotkey v1 does not support passing objects to commands; instead, SetTimer receives only an empty string. Note that % variable is optimized at load time to become %variable%, so you can still pass an object this way.
If Label is specified but resolves to an empty variable, an error is raised. This is for consistency (and see below).
I also believe it would be extremely rare that one would need an expression or variable to resolve to either "the current timer" or "some other timer". It seems more likely that any empty variable or expression is simply an error. If you need to work around this, you can conditionally call SetTimer,, xxx or SetTimer, label, xxx, or (in some cases) use A_ThisLabel or A_ThisFunc.
SetTimer and other commands
When passing a function reference (not a custom object) to SetTimer, Hotkey, GuiControl or Menu, the parameter count of the function is now checked against the number of parameters that the command will supply. If the function requires too many parameters, an error is raised or ErrorLevel is set (as appropriate). This validation was already done for functions passed by name.
Tab3
Includes Tab3 control as before, with the addition that its width and/or height (if left unspecified) are automatically calculated based on the contents of the tab control.
- If only one dimension is specified, the other dimension is calculated automatically.
- Autosizing occurs only once, either when you call Gui Show for the first time or when you call Gui Tab with a different tab control number/name (or none at all). This is done so that the next control you add can be relative to the Tab control. Any controls you add after that will not be taken into account (and you can utilize this fact).
- Controls on all tabs of that tab control are taken into account.
These changes may break scripts.
If the Label parameter is completely omitted (not an empty variable or expression), it defaults to the timer which launched the current thread. This should make it much easier for timers which use bound functions to delete themselves (by calling SetTimer,, Delete). Since SetTimer, label behaves like SetTimer, label, On for timers which already exist, SetTimer with no parameters will re-enable the timer which launched the thread.
If Label is an object created by the script (not a function or label) and Period is negative, the timer is deleted automatically after it is run. This occurs after the timer function returns, but only if the timer did not re-enable itself. This is effectively the same as if the timer function calls SetTimer,, Delete. Note that because the timer is deleted, its Period and Priority are not retained, which differs from the previous behaviour. Again, this change does not affect functions or labels.
Previously (since v1.1.01) the default value of Label was %A_ThisLabel%, even if there is no timer running or there is a timer running but it called a function. Scripts that relied on this weird behaviour will break.
If Label is omitted and the current thread was not started by a timer (or the timer has been deleted), an error is raised.
If Label is an expression which resolves to an object or empty string, an error is raised. This is to help debugging, because AutoHotkey v1 does not support passing objects to commands; instead, SetTimer receives only an empty string. Note that % variable is optimized at load time to become %variable%, so you can still pass an object this way.
If Label is specified but resolves to an empty variable, an error is raised. This is for consistency (and see below).
I also believe it would be extremely rare that one would need an expression or variable to resolve to either "the current timer" or "some other timer". It seems more likely that any empty variable or expression is simply an error. If you need to work around this, you can conditionally call SetTimer,, xxx or SetTimer, label, xxx, or (in some cases) use A_ThisLabel or A_ThisFunc.
SetTimer and other commands
When passing a function reference (not a custom object) to SetTimer, Hotkey, GuiControl or Menu, the parameter count of the function is now checked against the number of parameters that the command will supply. If the function requires too many parameters, an error is raised or ErrorLevel is set (as appropriate). This validation was already done for functions passed by name.
Who is online
Users browsing this forum: No registered users and 4 guests