GridGUI v1.1.11 - Simplify Control Placement and Resizing

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: GridGUI v1.1.9 - Simplify Control Placement and Resizing

28 Sep 2021, 12:52

I made a side with documentation for the project it is still in its early stages but you can find it here https://capnodin.github.io/GridGUI/
Please excuse my spelling I am dyslexic.
ozzii
Posts: 481
Joined: 30 Oct 2013, 06:04

Re: GridGUI v1.1.9 - Simplify Control Placement and Resizing

30 Sep 2021, 04:58

Thanks for the site.
This script is very useful.
I try something but can't manage to do it (sorry I am a little slow with this). But i have really tried.

Code: Select all

#Include %A_ScriptDir%\GridGUI.ahk

myGui := new GridGUI("text", "resize")
myGui.GuiClose := GridGUI.ExitApp
myGui.Color("4389A5")
myGui.Font("bold s13")
myGui.Add(1, 1, "Text", "cWhite", "text", , , , , "C")
myGui.Font("normal s11")
bt := myGui.Add(1, 2, "Button", , "button", exW := 1, exH := 1, fillW := 1, fillH := 0)
bt.callback := Func("bt")
myGui.Add(1, 8, "Text", "cWhite", "", , , , , "C")
btq := myGui.Add(1, 9, "Button", "Default", "Exit", exW := 1, exH := 1, fillW := 1, fillH := 0)
btq.callback := Func("btq")

myGui.AutoSize()
myGui.MinSize()
myGui.Show()
Return

bt()
{
	myGui2 := new GridGUI("Date", "resize")
	myGui2.Add(1, 1, "Text", "cRed", "Date YYYYMM", , , , , "C")
	ed := myGui2.Add(1, 2, "Edit", , , 1, , 1)
	btv := myGui2.Add(1, 3, "Button", , "OK", exW := 1, exH := 1, fillW := 1, fillH := 0)
	btv.callback := Func("Input").Bind(ed)
	myGui2.AutoSize()
	myGui2.MinSize()
	myGui2.Show()
	Return
	
}

Input(edit)
{
	global edit2 := edit.vVar
	msgbox % edit2
	LEnd()
}

LEnd()
{
	msgbox % edit2
}

btq()
{
	exitapp
}
Here are my questions (sorry for all of those) :
Is this the right way to do it?
I don't have my value in the LEnd(). I don't understand why.
How can I close the myGui2 when I click the OK button?
How can I assign the GuiClose when I use the ESC on the gui?

Thank you in advance for the help.
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: GridGUI v1.1.9 - Simplify Control Placement and Resizing

30 Sep 2021, 11:47

@ozzii
I tried to keep the changes to a minimum but personally, I would probably not use globals as much as I did here.
Basically, I added the variable as a global in the LEnd function and bound the second GUI as an additional argument to the ok button so that the GUI could be destroyed since the button will make a new one when clicked. Another way to solve the issue with edit2 would be to make it superglobal, that is declare it as global at the top of the script. Currently GuiEscape is not supported but the same functionality can be created using a conditional hotkey.

Code: Select all

#Include <GridGUI>

myGui := new GridGUI("text", "resize")
myGui.GuiClose := GridGUI.ExitApp
myGui.Color("4389A5")
myGui.Font("bold s13")
myGui.Add(1, 1, "Text", "cWhite", "text", , , , , "C")
myGui.Font("normal s11")
bt := myGui.Add(1, 2, "Button", , "button", exW := 1, exH := 1, fillW := 1, fillH := 0)
bt.callback := Func("bt")
myGui.Add(1, 8, "Text", "cWhite", "", , , , , "C")
btq := myGui.Add(1, 9, "Button", "Default", "Exit", exW := 1, exH := 1, fillW := 1, fillH := 0)
btq.callback := GridGUI.ExitApp

myGui.AutoSize()
myGui.MinSize()
myGui.Show()
Return

#If myGui.WinActive()
	Esc::myGui.GuiClose.Call()
#If

bt() {
	myGui2 := new GridGUI("Date", "resize")
	myGui2.Add(1, 1, "Text", "cRed", "Date YYYYMM", , , , , "C")
	ed := myGui2.Add(1, 2, "Edit", , , 1, , 1)
	btv := myGui2.Add(1, 3, "Button", , "OK", exW := 1, exH := 1, fillW := 1, fillH := 0)
	btv.callback := Func("Input").Bind(myGui2, ed)
	myGui2.AutoSize()
	myGui2.MinSize()
	myGui2.Show()
}

Input(myGui, edit) {
	global edit2 := edit.vVar
	myGui.Destroy()
	msgbox % edit2
	LEnd()
}

LEnd() {
	global edit2
	msgbox % edit2
}
Edit: Also don't worry about asking questions I am happy to see that someone is using my lib.
Please excuse my spelling I am dyslexic.
ozzii
Posts: 481
Joined: 30 Oct 2013, 06:04

Re: GridGUI v1.1.9 - Simplify Control Placement and Resizing

30 Sep 2021, 12:51

I will read and digest this tomorrow and try to understand how to use it.
Big thanks for the help.

I will surely ask some more question (but I hope not).

P.S.: in you example, for me the input example didn't work. I have an error

Code: Select all

Error in #include file "GridGUI-master\GridGUI-lib\Controls.ahk":
     Target label does not exist.

Specifically: gGuiClose

	Line#
	150: {
	151: Gosub,label
	152: }
	154: {
	155: Return,indent "Hwnd	:" this.hwnd "
" indent "Type:
" this.type
	156: }
	004: {
--->	006: Gui,guiHwnd ":Add",type,"+HwndHwnd " options,text
	007: Base.__New(Hwnd, type, options)  
	008: }
	012: {
	014: Base.__New(guiHwnd, "ListView", options, text)  
	015: this.gui := new GridGUI.GUI(, , guiHwnd)  
	016: }
	019: {
ozzii
Posts: 481
Joined: 30 Oct 2013, 06:04

Re: GridGUI v1.1.9 - Simplify Control Placement and Resizing

30 Sep 2021, 12:58

I try also to digest your tab example but couldn't.
Could you make and example with for example one text line, 3 buttons line and that they are not fill the height of the Gui. But that they have they're normal height.
I try just to change the background/font in the tab but without luck. And even the text is not showed ;(

Code: Select all

tab.tabs[1].Color("4389A5")
tab.tabs[1].Font("bold s13")
tab.tabs[1].Add(1, 1, "Text", "cWhite", "Text", , , , , "C")
tab.tabs[1].Font("normal s11")
My brain have difficulties with advanced class/function/uses....

Thank you in advance. And sorry again for the bother
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: GridGUI v1.1.9 - Simplify Control Placement and Resizing

30 Sep 2021, 13:54

ozzii wrote:
30 Sep 2021, 12:51
P.S.: in you example, for me the input example didn't work. I have an error
I have pushed a fix for the error, in regards to the other message I will try to make an example tomorrow, I am writing on the documentation right now.
Please excuse my spelling I am dyslexic.
ozzii
Posts: 481
Joined: 30 Oct 2013, 06:04

Re: GridGUI v1.1.9 - Simplify Control Placement and Resizing

30 Sep 2021, 16:11

Thanks for the input example. I will check this.
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: GridGUI v1.1.9 - Simplify Control Placement and Resizing

01 Oct 2021, 14:41

ozzii wrote:
30 Sep 2021, 12:58
I try also to digest your tab example but couldn't.
Could you make and example with for example one text line, 3 buttons line and that they are not fill the height of the Gui. But that they have they're normal height.
I try just to change the background/font in the tab but without luck. And even the text is not showed ;(

Code: Select all

tab.tabs[1].Color("4389A5")
tab.tabs[1].Font("bold s13")
tab.tabs[1].Add(1, 1, "Text", "cWhite", "Text", , , , , "C")
tab.tabs[1].Font("normal s11")
My brain have difficulties with advanced class/function/uses....

Thank you in advance. And sorry again for the bother
I am not sure if this does what you wanted. The main thing is that the TabControl is not a GUI so you will have to call the GUI commands on the myGui variable. Also it seems that you have to apply the color change before the tab is added to the GUI which happens when it is created.

Code: Select all

#Include <GridGUI>

myGui := new GridGUI("Tab Example", "resize")
myGui.GuiClose := GridGUI.ExitApp

args := {Options: "w0 h0", exW: 1, exH: 1, fillW: true, fillH: true}

myGui.Color("4389A5")
tab := new GridGUI.TabControl(myGui.hwnd, , "Name 1|Name 2|Name 3|Name 4")

myGui.AddControl(1, 1, tab, args)

myGui.Font("bold s13")
tab.tabs[1].Add(1, 1, "Text", "cWhite", "Text")
myGui.Font("normal s11")
tab.tabs[1].Add(1, 2, "Button", , "Button One")
tab.tabs[1].Add(2, 2, "Button", , "Button Two")
tab.tabs[1].Add(3, 2, "Button", , "Button Tree")

myGui.AutoSize()
myGui.Show("w300 h300")
myGui.MinSize()
return
I may add some more function to make it easier to work with tabs in the future, as well as make it possible to set the font directly on individual controls.
Please excuse my spelling I am dyslexic.
Ahk_fan
Posts: 237
Joined: 31 Aug 2018, 14:34
Contact:

Re: GridGUI v1.1.9 - Simplify Control Placement and Resizing

02 Oct 2021, 02:49

One of the usefullst extensions of Autohotkey, Thank you @Capn Odin ! It makes life a little bit easier an dspeeding up working process!
Where can I donate to anything?
regards,
AHK_fan :)
https://hr-anwendungen.de
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: GridGUI v1.1.9 - Simplify Control Placement and Resizing

02 Oct 2021, 03:19

@Ahk_fan You can donate here if you want to paypal.me/CapnOdin
Please excuse my spelling I am dyslexic.
ozzii
Posts: 481
Joined: 30 Oct 2013, 06:04

Re: GridGUI v1.1.9 - Simplify Control Placement and Resizing

02 Oct 2021, 03:29

Thank you @Capn Odin
Thanks for the first explanation, it was really useful, I have managed to do what I want.
And thanks also for this one. I will also try to understand it and adapt to my needs.

Very useful script. The GUI in AHK is not the easiest thing. This help a lot (at least for me).
ozzii
Posts: 481
Joined: 30 Oct 2013, 06:04

Re: GridGUI v1.1.9 - Simplify Control Placement and Resizing

06 Oct 2021, 03:50

Instead of having several callback for each button

Code: Select all

1C:= myGui.Add(1, 2, "Button", , "1C", exW := 1, exH := 1, fillW := 1, fillH := 0)
1C.callback := Func("1C")
1CO := myGui.Add(2, 2, "Button", , "1CO (Omega)", exW := 1, exH := 1, fillW := 1, fillH := 0)
1CO.callback := Func("1CO")
1J := myGui.Add(1, 3, "Button", , "1J", exW := 1, exH := 1, fillW := 1, fillH := 0)
1J.callback := Func("1J")
Is there any way to call the same Func and do a Switch depending of the used button?
The same question differently : How can I catch and test the value of the clicked button?

Code: Select all

1C:= myGui.Add(1, 2, "Button", , "1C", exW := 1, exH := 1, fillW := 1, fillH := 0)
1C.callback := Func("FuncNext")
1CO := myGui.Add(2, 2, "Button", , "1CO (Omega)", exW := 1, exH := 1, fillW := 1, fillH := 0)
1CO.callback := Func("FuncNext")
1J := myGui.Add(1, 3, "Button", , "1J", exW := 1, exH := 1, fillW := 1, fillH := 0)
1J.callback := Func("FuncNext")

FuncNext(){
switch ?????
{
case "1C":
    MsgBox
    return
case "1CO":
    MsgBox
    return
case "1J":
    MsgBox
    return
}
}
ozzii
Posts: 481
Joined: 30 Oct 2013, 06:04

Re: GridGUI v1.1.9 - Simplify Control Placement and Resizing

06 Oct 2021, 04:06

I think I found (even if I don't understand the way it works) with this 1C.callback := Func("FuncNext").Bind(1C) instead of 1C.callback := Func("1C")

Just tell me if it's the 'right' way to do it.
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: GridGUI v1.1.9 - Simplify Control Placement and Resizing

06 Oct 2021, 05:19

ozzii wrote:
06 Oct 2021, 04:06
I think I found (even if I don't understand the way it works) with this 1C.callback := Func("FuncNext").Bind(1C) instead of 1C.callback := Func("1C")

Just tell me if it's the 'right' way to do it.
Yes, using Func(funName).Bind(args) is the way I intended to allow for using the same function for callbacks.
Please excuse my spelling I am dyslexic.
ozzii
Posts: 481
Joined: 30 Oct 2013, 06:04

Re: GridGUI v1.1.9 - Simplify Control Placement and Resizing

06 Oct 2021, 06:01

Thanks you for the feedback.
Now I can continue :dance:
ozzii
Posts: 481
Joined: 30 Oct 2013, 06:04

Re: GridGUI v1.1.9 - Simplify Control Placement and Resizing

07 Oct 2021, 02:56

One more question.. Sorry :oops: :oops: :oops: ...

Is there any way/possibility to have a tooltip (different for each button) when a button is hovered?
If it's easier to do that I can put the Gui not resizable.
Because I need to put some information and put them in the button is not the best way (too messy/crowded/unreadable after that).

Regarding the previously .Bind
Instead of the label of the button (vvar) how can I test the 'id/name' of the button?
Here 1C and 1CO:

Code: Select all

1C:= myGui.Add(1, 2, "Button", , "1C", exW := 1, exH := 1, fillW := 1, fillH := 0)
1C.callback := Func("FuncNext").Bind(1C)
1CO := myGui.Add(2, 2, "Button", , "1CO (Omega)", exW := 1, exH := 1, fillW := 1, fillH := 0)
1CO.callback := Func("FuncNext").Bind(1CO)
instead of 1C and "1CO (Omega)"

I have tested with bt.callback but no luck.
In general, it's easier for my case to test the id/name of the button than his value
ozzii
Posts: 481
Joined: 30 Oct 2013, 06:04

Re: GridGUI v1.1.9 - Simplify Control Placement and Resizing

07 Oct 2021, 07:38

@Capn Odin
Can I sent to you a PM?
I have something with an GUI but I don't really want to spam this post with my personal needs.
Or you prefer here?
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: GridGUI v1.1.9 - Simplify Control Placement and Resizing

09 Oct 2021, 14:31

ozzii wrote:
07 Oct 2021, 02:56
One more question.. Sorry :oops: :oops: :oops: ...

Is there any way/possibility to have a tooltip (different for each button) when a button is hovered?
If it's easier to do that I can put the Gui not resizable.
Because I need to put some information and put them in the button is not the best way (too messy/crowded/unreadable after that).

Regarding the previously .Bind
Instead of the label of the button (vvar) how can I test the 'id/name' of the button?
Here 1C and 1CO:

Code: Select all

1C:= myGui.Add(1, 2, "Button", , "1C", exW := 1, exH := 1, fillW := 1, fillH := 0)
1C.callback := Func("FuncNext").Bind(1C)
1CO := myGui.Add(2, 2, "Button", , "1CO (Omega)", exW := 1, exH := 1, fillW := 1, fillH := 0)
1CO.callback := Func("FuncNext").Bind(1CO)
instead of 1C and "1CO (Omega)"

I have tested with bt.callback but no luck.
In general, it's easier for my case to test the id/name of the button than his value
I have looked at how to add tooltips to the control, I may implement a build-in way to do it in the future but right now I suggest using another lib to handle the tooltips, like GuiControlTips - Tooltips for GUI controls. Here is an example using that lib, which adds tooltips to the buttons in one of my libs examples.

Code: Select all

#Include <GridGUI>

myGui := new GridGUI("Grid Test", "resize")

TT := New GuiControlTips(myGui.hwnd)

myGui.GuiClose := GridGUI.ExitApp
ctrl1 := myGui.Add("1-3", 1, "Edit", , , 1, , 1)
ctrl2 := myGui.Add(1, 2, "Button", , "Button")
ctrl3 := myGui.Add(2, 2, "Edit", "w0", , 1, , 1)
ctrl4 := myGui.Add(3, "2-3", "ActiveX", "w113 h43", "shell explorer")
oWB := ctrl4.vVar
oWB.Navigate("about:<!DOCTYPE HTML><html><body style=""{margin:0;}""><img src=""https://i.imgur.com/FlGrIY3.gif""></body></html>")
oWB.document.body.style.overflow := "hidden"
ctrl5 := myGui.Add(1, 3, "Button", , "Button")
ctrl6 := myGui.Add(2, 3, "Button", , "Button Button")
ctrl7 := myGui.Add("1-3", 4, "Button", , "Button", 1, , 1)

TT.SetDelayTimes(1000, 2000, -1)
; Attach the controls
TT.Attach(ctrl1.hwnd, "Text control's centered Tooltip!", True)
TT.Attach(ctrl2.hwnd, "Edit control's Tooltip!")
TT.Attach(ctrl3.hwnd, "DDL control's Tooltip!")
TT.Attach(ctrl4.hwnd, "DDL control's Tooltip!")
TT.Attach(ctrl5.hwnd, "Edit control's Tooltip!")
TT.Attach(ctrl6.hwnd, "DDL control's Tooltip!")
TT.Attach(ctrl7.hwnd, "DDL control's Tooltip!")

myGui.AutoSize()
myGui.MinSize()
myGui.Show()
return


; ======================================================================================================================
; Namespace:      GuiControlTips
; AHK version:    AHK 1.1.14.03
; Function:       Helper object to simply assign ToolTips for GUI controls
; Tested on:      Win 7 (x64)
; Change history:
;                 1.1.00.01/2020-06-03/just me - fixed missing Static WS_EX_TOPMOST
;                 1.1.00.00/2014-03-06/just me - Added SetDelayTimes()
;                 1.0.01.00/2012-07-29/just me
; ======================================================================================================================
; CLASS GuiControlTips
;
; The class provides four public methods to register (Attach), unregister (Detach), update (Update), and
; disable/enable (Suspend) common ToolTips for GUI controls.
;
; Usage:
; To assign ToolTips to GUI controls you have to create a new instance of GuiControlTips per GUI with
;     MyToolTipObject := New GuiControlTips(HGUI)
; passing the HWND of the GUI.
;
; After this you may assign ToolTips to your GUI controls by calling
;     MyToolTipObject.Attach(HCTRL, "ToolTip text")
; passing the HWND of the control and the ToolTip's text. Pass True/1 for the optional third parameter if you
; want the ToolTip to be shown centered below the control.
;
; To remove a ToolTip call
;     MyToolTipObject.Detach(HCTRL)
; passing the HWND of the control.
;
; To update the ToolTip's text call
;     MyToolTipObject.Update(HCTRL, "New text!")
; passing the HWND of the control and the new text.
;
; To deactivate the ToolTips call
;     MyToolTipObject.Suspend(True),
; to activate them again afterwards call
;     MyToolTipObject.Suspend(False).
;
; To adjust the ToolTips delay times call
;     MyToolTipObject.SetDelayTimesd(),
; specifying the delay times in milliseconds.
;
; That's all you can / have to do!
; ======================================================================================================================
Class GuiControlTips {
   ; ===================================================================================================================
   ; INSTANCE variables
   ; ===================================================================================================================
   HTIP := 0
   HGUI := 0
   CTRL := {}
   ; ===================================================================================================================
   ; CONSTRUCTOR           __New()
   ; ===================================================================================================================
   __New(HGUI) {
      Static CLASS_TOOLTIP      := "tooltips_class32"
      Static CW_USEDEFAULT      := 0x80000000
      Static TTM_SETMAXTIPWIDTH := 0x0418
      Static TTM_SETMARGIN      := 0x041A
      Static WS_EX_TOPMOST      := 0x00000008
      Static WS_STYLES          := 0x80000002 ; WS_POPUP | TTS_NOPREFIX
      ; Create a Tooltip control ...
      HTIP := DllCall("User32.dll\CreateWindowEx", "UInt", WS_EX_TOPMOST, "Str", CLASS_TOOLTIP, "Ptr", 0
                    , "UInt", WS_STYLES
                    , "Int", CW_USEDEFAULT, "Int", CW_USEDEFAULT, "Int", CW_USEDEFAULT, "Int", CW_USEDEFAULT
                    , "Ptr", HGUI, "Ptr", 0, "Ptr", 0, "Ptr", 0, "Ptr")
      If ((ErrorLevel) || !(HTIP))
         Return False
      ; ... prepare it to display multiple lines if required
      DllCall("User32.dll\SendMessage", "Ptr", HTIP, "Int", TTM_SETMAXTIPWIDTH, "Ptr", 0, "Ptr", 0)
      ; ... set the instance variables
      This.HTIP := HTIP
      This.HGUI := HGUI
      If (DllCall("Kernel32.dll\GetVersion", "UInt") & 0xFF) < 6 ; to avoid some XP issues ...
         This.Attach(HGUI, "") ; ... register the GUI with an empty tiptext
   }
   ; ===================================================================================================================
   ; DESTRUCTOR            __Delete()
   ; ===================================================================================================================
   __Delete() {
      If (This.HTIP) {
         DllCall("User32.dll\DestroyWindow", "Ptr", This.HTIP)
      }
   }
   ; ===================================================================================================================
   ; PRIVATE METHOD        SetToolInfo - Create and fill a TOOLINFO structure
   ; ===================================================================================================================
   SetToolInfo(ByRef TOOLINFO, HCTRL, TipTextAddr, CenterTip = 0) {
      Static TTF_IDISHWND  := 0x0001
      Static TTF_CENTERTIP := 0x0002
      Static TTF_SUBCLASS  := 0x0010
      Static OffsetSize  := 0
      Static OffsetFlags := 4
      Static OffsetHwnd  := 8
      Static OffsetID    := OffsetHwnd + A_PtrSize
      Static OffsetRect  := OffsetID + A_PtrSize
      Static OffsetInst  := OffsetRect + 16
      Static OffsetText  := OffsetInst + A_PtrSize
      Static StructSize  := (4 * 6) + (A_PtrSize * 6)
      Flags := TTF_IDISHWND | TTF_SUBCLASS
      If (CenterTip)
         Flags |= TTF_CENTERTIP
      VarSetCapacity(TOOLINFO, StructSize, 0)
      NumPut(StructSize, TOOLINFO, OffsetSize, "UInt")
      NumPut(Flags, TOOLINFO, OffsetFlags, "UInt")
      NumPut(This.HGUI, TOOLINFO, OffsetHwnd, "Ptr")
      NumPut(HCTRL, TOOLINFO, OffsetID, "Ptr")
      NumPut(TipTextAddr, TOOLINFO, OffsetText, "Ptr")
      Return True
   }
   ; ===================================================================================================================
   ; PUBLIC METHOD         Attach         -  Assign a ToolTip to a certain control
   ; Parameters:           HWND           -  Control's HWND
   ;                       TipText        -  ToolTip's text
   ;                       Optional:      ------------------------------------------------------------------------------
   ;                       CenterTip      -  Centers the tooltip window below the control
   ;                                         Values:  True/False
   ;                                         Default: False
   ; Return values:        On success: True
   ;                       On failure: False
   ; ===================================================================================================================
   Attach(HCTRL, TipText, CenterTip = False) {
      Static TTM_ADDTOOL  := A_IsUnicode ? 0x0432 : 0x0404 ; TTM_ADDTOOLW : TTM_ADDTOOLA
      If !(This.HTIP) {
         Return False
      }
      If This.CTRL.HasKey(HCTRL)
         Return False
      TOOLINFO := ""
      This.SetToolInfo(TOOLINFO, HCTRL, &TipText, CenterTip)
      If DllCall("User32.dll\SendMessage", "Ptr", This.HTIP, "Int", TTM_ADDTOOL, "Ptr", 0, "Ptr", &TOOLINFO) {
         This.CTRL[HCTRL] := 1
         Return True
      } Else {
        Return False
      }
   }
   ; ===================================================================================================================
   ; PUBLIC METHOD         Detach         -  Remove the ToolTip for a certain control
   ; Parameters:           HWND           -  Control's HWND
   ; Return values:        On success: True
   ;                       On failure: False
   ; ===================================================================================================================
   Detach(HCTRL) {
      Static TTM_DELTOOL  := A_IsUnicode ? 0x0433 : 0x0405 ; TTM_DELTOOLW : TTM_DELTOOLA
      If !This.CTRL.HasKey(HCTRL)
         Return False
      TOOLINFO := ""
      This.SetToolInfo(TOOLINFO, HCTRL, 0)
      DllCall("User32.dll\SendMessage", "Ptr", This.HTIP, "Int", TTM_DELTOOL, "Ptr", 0, "Ptr", &TOOLINFO)
      This.CTRL.Remove(HCTRL, "")
      Return True
   }
   ; ===================================================================================================================
   ; PUBLIC METHOD         Update         -  Update the ToolTip's text for a certain control
   ; Parameters:           HWND           -  Control's HWND
   ;                       TipText        -  New text                                                      
   ; Return values:        On success: True
   ;                       On failure: False
   ; ===================================================================================================================
   Update(HCTRL, TipText) {
      Static TTM_UPDATETIPTEXT  := A_IsUnicode ? 0x0439 : 0x040C ; TTM_UPDATETIPTEXTW : TTM_UPDATETIPTEXTA
      If !This.CTRL.HasKey(HCTRL)
         Return False
      TOOLINFO := ""
      This.SetToolInfo(TOOLINFO, HCTRL, &TipText)
      DllCall("SendMessage", "Ptr", This.HTIP, "Int", TTM_UPDATETIPTEXT, "Ptr", 0, "Ptr", &TOOLINFO)
      Return True
   }
   ; ===================================================================================================================
   ; PUBLIC METHOD         Suspend        -  Disable/enable the ToolTip control (don't show / show ToolTips)
   ; Parameters:           Mode           -  True/False (1/0)
   ;                                         Default: True/1
   ; Return values:        On success: True
   ;                       On failure: False
   ; Remarks:              ToolTips are enabled automatically on creation.
   ; ===================================================================================================================
   Suspend(Mode = True) {
      Static TTM_ACTIVATE := 0x0401
      If !(This.HTIP)
         Return False
      DllCall("SendMessage", "Ptr", This.HTIP, "Int", TTM_ACTIVATE, "Ptr", !Mode, "Ptr", 0)
      Return True
   }
   ; ===================================================================================================================
   ; PUBLIC METHOD         SetDelayTimes  -  Set the initial, pop-up, and reshow durations for a tooltip control.
   ; Parameters:           Init           -  Amount of time, in milliseconds, a pointer must remain stationary within
   ;                                         a tool's bounding rectangle before the tooltip window appears.
   ;                                         Default: -1 (system default time)
   ;                       PopUp          -  Amount of time, in milliseconds, a tooltip window remains visible if the
   ;                                         pointer is stationary within a tool's bounding rectangle.
   ;                                         Default: -1 (system default time)
   ;                       ReShow         -  Amount of time, in milliseconds, it takes for subsequent tooltip windows
   ;                                         to appear as the pointer moves from one tool to another.
   ;                                         Default: -1 (system default time)
   ; Return values:        On success: True
   ;                       On failure: False
   ; Remarks:              Times are set per ToolTip control and applied to all added tools.
   ; ===================================================================================================================
   SetDelayTimes(Init = -1, PopUp = -1, ReShow = -1) {
      Static TTM_SETDELAYTIME   := 0x0403
      Static TTDT_RESHOW   := 1
      Static TTDT_AUTOPOP  := 2
      Static TTDT_INITIAL  := 3
      DllCall("SendMessage", "Ptr", This.HTIP, "Int", TTM_SETDELAYTIME, "Ptr", TTDT_INITIAL, "Ptr", Init)
      DllCall("SendMessage", "Ptr", This.HTIP, "Int", TTM_SETDELAYTIME, "Ptr", TTDT_AUTOPOP, "Ptr", PopUp)
      DllCall("SendMessage", "Ptr", This.HTIP, "Int", TTM_SETDELAYTIME, "Ptr", TTDT_RESHOW , "Ptr", ReShow)
   }
}
ozzii wrote: @Capn Odin
Can I sent to you a PM?
I have something with an GUI but I don't really want to spam this post with my personal needs.
Or you prefer here?
If it is about this lib then it is fine to talk about it here if it about something else then you can send a pm.
Please excuse my spelling I am dyslexic.
ozzii
Posts: 481
Joined: 30 Oct 2013, 06:04

Re: GridGUI v1.1.10 - Simplify Control Placement and Resizing

10 Oct 2021, 03:30

Thank you for the explanation for the tooltip and the example. I will look into this on Monday.
And yes, I think that a build-in could be really great.
But it's up to you if you have time for this.

For the second part, yes, it's about the lib.
I will post it also on Monday (on my work computer).

Regards and again thank you for this lib.
ozzii
Posts: 481
Joined: 30 Oct 2013, 06:04

Re: GridGUI v1.1.10 - Simplify Control Placement and Resizing

11 Oct 2021, 04:56

The example with the tooltip works. Thank you for the help and the explanation.

Sorry to ask the question again (because I didn't see an answer from you message from the 9th), but did you see my question about testing the 'id/name' of the button instead of his vVal :oops: :oops: :oops: :oops:

About my issue:
I have this

Code: Select all

args := {exW: 1, exH: 1, fillW: true, fillH: false}
myGui := new GridGUI("CTM", "resize")
myGui.GuiClose := GridGUI.ExitApp
myGui.Color("4389A5")
myGui.Font("bold s13")
myGui.Add("1-2", 1, "Text", "cWhite", "● Relance CTM ●", , , , , "C")
myGui.Font("normal s11")

bt1 := myGui.Add(1, 2, "Button", , "bt1 -> Y", args)
bt1.callback := Func("bt1")
bt1_sans := myGui.Add(2, 2, "Button", , "bt1 -> N", args)
bt1_sans.callback := Func("bt1_sans")
bt2 := myGui.Add(1, 3, "Button", , "bt2", args)
bt2.callback := Func("bt2")
bt3 := myGui.Add(2, 3, "Button", , "bt3", args)
bt3.callback := Func("bt3")
bt4 := myGui.Add(1, 4, "Button", , "bt4 -> Y", args)
bt4.callback := Func("bt4")
bt4_sans := myGui.Add(2, 4, "Button", , "bt4 -> N", args)
bt4_sans.callback := Func("bt4_sans")
Demat := myGui.Add("1-2", 5, "Button", , "Démat factures", args)
Demat.callback := Func("Demat")
Fichier := myGui.Add(1, 6, "Button", , "Fichiers 1C/1V...", args)
Fichier.callback := Func("Fichier")
HR := myGui.Add(2, 6, "Button", , "Demandes DSN/HR", args)
HR.callback := Func("HR")

myGui.Add("1-2", 11, "Text", "cWhite", "", , , , , "C")
btq := myGui.Add("1-2", 12, "Button", "Default", "Quitter", args)
btq.callback := Func("Sortie")

global SERVEUR, FOLDER, VARIABLE, DTE

myGui.AutoSize()
myGui.MinSize()
myGui.Show()
Return
The win is cropped on the right
Image
But when I change Demandes DSN/HR with Demandes DSN it's OK.
Am I doing something wrong ?

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: Google [Bot] and 171 guests