GuiControl_Ex - Extending GuiControls - 2023/04/03 - v2.0.2

Post your working scripts, libraries and tools.
User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: GuiControl_Ex - Extending GuiControls - 2022/01/09 - beta.3

Post by TheArkive » 26 Apr 2022, 14:06

AHK_user wrote:
25 Apr 2022, 15:55
Your code seems amazing, I just converted mine to V2, and cleaned it up during the process. (And got a lot of learningfull help.)
I even do not have tested the options, there was no documentation in the original script :lol: :lol: :lol:
Thanks for the kind words :) Yah, that lib stretched my brain a bit, I totally forgot about the docs. And I think I may have included some unnecessary functions just for the sake of trying to make "everything" accessible, rather than focusing on the most useful parts.
AHK_user wrote:
25 Apr 2022, 15:55
Another idea is to see the toolbar more similar to the menubar syntax, define the buttons seperately and connect the toolbar to the gui

Something like:

Code: Select all

MyToolbar := Toolbar(generaloptions)
oToolbarButton1 := MyToolbar.Add(options, "buttontext 1", callback1, IconNumber, PartNumber)
oToolbarButton2 := MyToolbar.Add(options, "buttontext 2", callback2, IconNumber, PartNumber)
MyGui.ToolBar := MyToolbar 

callback1(GuiObject,ToolbarObject){
	MsgBox(ToolbarObject.text)
}

callback2(GuiObject,ToolbarObject){
}
This seems logical ahk syntax and gives flexibility for later expansion, setting,... :D
I'll address this part in the IronToolbar thread.

AHK_user
Posts: 515
Joined: 04 Dec 2015, 14:52
Location: Belgium

Re: GuiControl_Ex - Extending GuiControls - 2022/01/09 - beta.3

Post by AHK_user » 11 May 2022, 16:43

Another valuable extension of this library would be an option to add an in-cell edit option to the listview.

I found a working V1 script, it even allows you to block specific columns, quite impressive.
https://github.com/AHK-just-me/Class_LV_InCellEdit/blob/master/Sources/Class_LV_InCellEdit.ahk

User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: GuiControl_Ex - Extending GuiControls - 2022/01/09 - beta.3

Post by TheArkive » 13 May 2022, 09:39

@AHK_user
Yes indeed I've been thinking about that. I think just me has written this already written this for v2 here.

It's kind of an intense addon, and that is just the minimal version. I guess I can probably retrofit just me's script so that it fits into this framework.

AHK_user
Posts: 515
Joined: 04 Dec 2015, 14:52
Location: Belgium

Re: GuiControl_Ex - Extending GuiControls - 2022/01/09 - beta.3

Post by AHK_user » 20 May 2022, 14:00

I have started to extend the listview a little in a different direction, to add some extra easy-to use and logical properties and methods. incell should also be added in the future, but I really like these improvements, as they make the listview a lot more userfriendly and intuitive.

lv.table => get or set the content of the listview as a table (tab and linefeeds)
lv.selection.table => returns the selection of the listview as a table (tab and linefeeds)
lv.selection.rows => returns the selection of the listview as a table (tab and linefeeds)
lv.rows => returns the number of rows
lv.colunms=> returns the number of colunms
lv.Checked(row) => returns the checked status
lv.headerArray := ["test","test2"] => quickly set or get the headers
lv.SetExplorerTheme() => change the theme
lv.GetObject(Options := "", aHeaders:="") => retrieve the content as an array of objects (aHeaders can be used to change the properties names, as no spaces are allowed.
lv.GetObject(aRows, aProps := "") => set the content of the listview as an object

for row, rowcontent in lv => loop over the content :D :D :D I really like this one

lv.Filter(SearchString, colNumber:="") => quickly filter the list

Some missing functions:
=> It should also be possible to loop over lv.selection
=> inserting data at the selected line

You can find the code in the following post:
viewtopic.php?f=82&t=104041&p=463269#p463269
Last edited by AHK_user on 21 May 2022, 06:58, edited 2 times in total.

User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: GuiControl_Ex - Extending GuiControls - 2022/01/09 - beta.3

Post by TheArkive » 21 May 2022, 03:30

@AHK_user

I like the extra functionality!

I think at this point, if I start to add more to this lib, especially larger code snippits, I'll add them as separate modules.

Right now, my time to code is much more limited than it usually is, and this lib is a bit lower on my priority list at the moment. But I haven't forgotten about all the other suggestions you've made in this thread ;) I do like them, i just need the time to analyze and implement.

If you want, go ahead and make some pull requests on the github repo.

User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: GuiControl_Ex - Extending GuiControls - 2023/03/27 - v2.0.2

Post by TheArkive » 27 Mar 2023, 09:57

Update 2023/03/27
  • commented out GuiCtl_Ext class, not currently needed
  • moved methods in GuiCtl_Ext to proper controls, keeping everything self contained per control
  • Added tab props/methods: GetCount(), GetIcon(), GetItems(), GetName(), Insert(), RowCount, SetIcon(), SetName(), SetImageList()
  • Added Gui.SetIcon() - thanks to AHK_User
  • updated / cleaned up example
Last edited by TheArkive on 28 Mar 2023, 06:28, edited 1 time in total.

AHK_user
Posts: 515
Joined: 04 Dec 2015, 14:52
Location: Belgium

Re: GuiControl_Ex - Extending GuiControls - 2023/03/27 - v2.0.2

Post by AHK_user » 27 Mar 2023, 23:08

TheArkive wrote:
27 Mar 2023, 09:57
Update 2023/03/27
  • removed Destroy() method, as it has the same effect as hiding the control
  • commented out GuiCtl_Ext class, not currently needed
  • moved methods in GuiCtl_Ext to proper controls, keeping everything self contained per control
  • Added tab props/methods: GetCount(), GetIcon(), GetItems(), GetName(), Insert(), RowCount, SetIcon(), SetName(), SetImageList()
  • Added Gui.SetIcon() - thanks to AHK_User
  • updated / cleaned up example
@TheArkive I would advice to keep the Destroy Method, it is not the same as hiding the control.
If you destroy a control it is not accesible after the destroy command, so it is more cleaner than hiding it.
Vissual it is the same effect, but beneath the surface it is a totally different command.

I use it in the following cases:
- notepad.ahk: it destroys my edit control and recreates it when setting the wrap function (I could not find another way if I did not wanted to accept an second invisible control, that would be harder to handle) sometimes it is not possible to change the options of a control.
- I also have a V2Gui Creator, that lets you draw your ahk v2 Gui`s, I need to be able to delete the controls to keep it clean.

User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: GuiControl_Ex - Extending GuiControls - 2023/03/27 - v2.0.2

Post by TheArkive » 28 Mar 2023, 03:20

Yes I was aware that it is not possible to bring the control back with Destroy(). So in that manner it is not "the same". But the handle for the destroyed control still exists (at least in my tests, that is what happened). It seems that the only real difference is that the control still exists and is hidden, with no possibility to bring it back.

I'll see if I can help find a fix for toggling wrap before just bringing back Destroy().

EDIT: Heh, it didn't take much searching to see that it isn't possible to simply toggle wrap. I'll add Destroy back into the mix.

User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: GuiControl_Ex - Extending GuiControls - 2023/04/03 - v2.0.2

Post by TheArkive » 03 Apr 2023, 08:09

Update 2023/04/03
  • improved structure keeping items that belong together in a single class
  • simplified code for ComboBox auto-complete
  • added several properties / methods (see docs)
  • updated docs

jsong55
Posts: 221
Joined: 30 Mar 2021, 22:02

Re: GuiControl_Ex - Extending GuiControls - 2023/04/03 - v2.0.2

Post by jsong55 » 12 Apr 2023, 19:36

Are there ways to color Gui Edits Text Combo boxes like like viewtopic.php?f=6&t=2197

User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: GuiControl_Ex - Extending GuiControls - 2023/04/03 - v2.0.2

Post by jNizM » 13 Apr 2023, 00:53

jsong55 wrote:
12 Apr 2023, 19:36
Are there ways to color Gui Edits Text Combo boxes like like viewtopic.php?f=6&t=2197
yes. take a look at this:
viewtopic.php?f=92&p=517062#p517062

Especially this section:

Code: Select all

WindowProc(hwnd, uMsg, wParam, lParam)
{
	; code...

		case WM_CTLCOLOREDIT, WM_CTLCOLORLISTBOX:
		{
			DllCall("gdi32\SetTextColor", "Ptr", wParam, "UInt", DarkColors["Font"])
			DllCall("gdi32\SetBkColor", "Ptr", wParam, "UInt", DarkColors["Controls"])
			DllCall("gdi32\SetDCBrushColor", "Ptr", wParam, "UInt", DarkColors["Controls"], "UInt")
			return DllCall("gdi32\GetStockObject", "Int", DC_BRUSH, "Ptr")
		}

	; more code...
}
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile

User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: GuiControl_Ex - Extending GuiControls - 2023/04/03 - v2.0.2

Post by TheArkive » 13 Apr 2023, 14:42

Depending on what you need, this might work:

ctl.Opt("cRed BackgroundBlue")

cColor = text color, and Color can be RRGGBB

BackgroundColor = the background

Works for edit boxes and the edit box of a ComboBox. It does not apply though to the drop-down part of a ComboBox.

jNizM's solution is certainly more comprehensive. AHK doesn't have the built-in ability to color certain parts of several controls, such as scrollbars.

User avatar
TheArkive
Posts: 1027
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: GuiControl_Ex - Extending GuiControls - 2023/04/03 - v2.0.2

Post by TheArkive » 14 Apr 2023, 03:30

@jNizM

I took a closer look finally. Thanks for posting that link. That looks like a good method to include in this lib. I'll see what I can do.

jsong55
Posts: 221
Joined: 30 Mar 2021, 22:02

Re: GuiControl_Ex - Extending GuiControls - 2023/04/03 - v2.0.2

Post by jsong55 » 14 Apr 2023, 05:54

@TheArkive
Can't wait for your implementation of it

AHK_user
Posts: 515
Joined: 04 Dec 2015, 14:52
Location: Belgium

Re: GuiControl_Ex - Extending GuiControls - 2023/04/03 - v2.0.2

Post by AHK_user » 28 Oct 2023, 06:45

Maybe a nice feature to add to my favorite Class, the problems with using guis with multiple monitors is that sometimes it pops up in the wrong monitor. Very annoying.
This function gives an alterative way to show the gui in the monitor where the mouse is positioned.
If only one monitor, or the x or y coordinates are defined in the options.

If interested, i would suggest to change the show method that if the string "MouseCenter" is in the options, this is activated.
This to prevent unintended effects.

Code: Select all

Gui_ShowCenter(GuiObj, Options){
    ; Centers the Gui in the monitor where the mouse is

    ; If 1 monitor, do a normal show
    MonitorCount := SysGet(80)
    if (MonitorCount=1 or (InStr(" " Options," x") and InStr(" " Options," y"))){
        GuiObj.Show(Options)
        return
    }

    GuiObj.Show(Options (InStr(" " Options " ", " Hide ") ? "" : " Hide"))

    ; Get the monitor of the mouse
    CoordMode("Mouse", "Screen")
	MouseGetPos(&mx, &my)
    CurrentMonitorIndex:= 1
	Loop MonitorCount{
		MonitorGet(A_Index, &monitorLeft, &monitorTop, &monitorRight, &monitorBottom)
		if (monitorLeft <= mx && mx <= monitorRight && monitorTop <= my && my <= monitorBottom){
            break
		}
    }

    ; Get Size of Gui window
    RC := Buffer(16)
    DllCall("GetClientRect", "uint", GuiObj.hwnd, "Ptr", rc)
    w := NumGet(rc, 8, "int")
    h := NumGet(rc, 12, "int")

    GuiObj.Show("x" (( monitorRight-monitorLeft - w ) / 2) + monitorLeft " y" (monitorBottom-monitorTop - 30 - h ) / 2 (InStr(" " Options " ", " Hide ") ? " Hide" : ""))
}

Post Reply

Return to “Scripts and Functions (v2)”