Is possible to store a rect in a this.var of a class?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
fabricio234
Posts: 122
Joined: 06 Mar 2020, 21:48

Is possible to store a rect in a this.var of a class?

25 Jul 2021, 23:14

example

Code: Select all

Class Foo {  
   Something() {
      if (This.Rect = "") {
      VarSetCapacity(RECT, 16, 0)
      DllCall("GetClientRect", "Ptr", hWnd, "Ptr", &RECT)
      This.Rect := RECT 
      }
  }
}
Im trying to avoid calling the dllcall each time the function is called. When i try to use This.Rect in other places it looks like its empty
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Is possible to store a rect in a this.var of a class?

26 Jul 2021, 02:16

no. u must assign a pointer to XXXAlloc()ated memory(and dont forget to clean it up when ure done using it)

or use v2 where this is a solved issue
teadrinker
Posts: 4331
Joined: 29 Mar 2015, 09:41
Contact:

Re: Is possible to store a rect in a this.var of a class?

26 Jul 2021, 03:17

Perhaps, you need this:

Code: Select all

Class Foo {  
   Something() {
      if (this.Rect = "") {
         this.SetCapacity("Rect", 16)
         DllCall("GetClientRect", "Ptr", hWnd, "Ptr", this.GetAddress("Rect"))
      }
   }
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: jeves, mikeyww, septrinus and 299 guests