UI to collect icons in a row Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
kdaube
Posts: 86
Joined: 02 Nov 2015, 03:11

UI to collect icons in a row

Post by kdaube » 06 Feb 2023, 06:14

Friends, I need your help!
In a larger script I get icons which I want to display collected in a row forming a button bar.
In the simulated screenshot herafter the top icons is constant. in reality it is the selction from a list and then I want to add it to the tool bar by using button Add. After using the button 3 times I shall get this:
Image
How to achieve this?

Code: Select all

; addBtn2Tbar.ahk     icons shall be presented 48 x 48 pix
global x := 20 - 48, n, iconCurBtn
n  := 0                                                     ; # icons collected
iconCurBtn := A_ScriptDir . "\Undefined.png"

  Gui Add, Picture, x100 y020 w048 h048       , %iconCurBtn%  ; will be scaled
  Gui Add, Button,  x100 y080 w120 h025       , Add to collection
  Gui Add, Text,    x020 y120 w350 h025 vAdd  , Accumulate icons below starting at pos 20 pix

  Gui Add, Picture, x%x% y150 w048 h048 vC1a                ;
  Gui Show, w400


Add() {
  newIcon := iconCurBtn                                     ; in reality this depends
  n += 1                                                    ; # icons collected
  x += 48
  loop %n% {
    GuiControl,, C1a,  %newIcon%
  }
}
The GuiControl is incomplete, have no idea how to create a loop for this situation.
Klaus Daube, Zürich, CH

User avatar
mikeyww
Posts: 26440
Joined: 09 Sep 2014, 18:38

Re: UI to collect icons in a row

Post by mikeyww » 06 Feb 2023, 07:30

Code: Select all

#Requires AutoHotkey v1.1.33

image := A_ScriptDir "\test.jpg"

F3::
Gui Add, Picture, x+m, % image
Gui Show, w1000
Return

User avatar
kdaube
Posts: 86
Joined: 02 Nov 2015, 03:11

Re: UI to collect icons in a row  Topic is solved

Post by kdaube » 06 Feb 2023, 08:10

mikeyww, you pointed me into the right direction (I had some trivial errors also...)
This works as intended:

Code: Select all

; addBtn2Tbar.ahk     icons shall be presented 48 x 48 pix
#Requires AutoHotkey v1.1.33
global m := 20 - 48, n, iconCurBtn
n  := 0                                                     ; # icons collected
iconCurBtn := A_ScriptDir . "\Undefined.png"

  Gui Add, Picture, x100 y020 w048 h048       , %iconCurBtn%  ; will be scaled
  Gui Add, Button,  x100 y080 w120 h025 gAdd  , Add to collection
  Gui Add, Text,    x020 y120 w350 h025       , Accumulate icons below starting at pos 20 pix

  Gui Show, w400 h200


Add() {
  Gui, Submit, noHide                                       ; get the varaible content
  newIcon := iconCurBtn                                     ; in reality this depends
  n += 1                                                    ; # icons collected
  m += 48
  Gui Add, Picture, x%m% y150 w048 h048, %newIcon%
  Gui Show
Return
}
Klaus Daube, Zürich, CH

User avatar
kdaube
Posts: 86
Joined: 02 Nov 2015, 03:11

Re: UI to collect icons in a row

Post by kdaube » 06 Feb 2023, 08:29

This is how it looks implemented after selection of 4 buttons from the list:
Image
Klaus Daube, Zürich, CH

Post Reply

Return to “Ask for Help (v1)”