Page 1 of 1

when to initial a call of Gdip_Startup()

Posted: 21 Dec 2019, 17:22
by takayo97
when using gdip ahk lib, Gdip_Startup() must to initial first before access to all gdip's function

My script has different function to use gdip's function.
Should i call Gdip_Startup() when ahk script loaded, or
calling this function inside of each of custom fucntion where to use gdip's function ?
Some of custom function will be called by a timer as an interval.
For example, a timer of every one second to check bitmap changing on screen
For the preceding way, if there any overhead of calling and destroying the gdip token repeatedly

Code: Select all


gdipToken := Gdip_Startup()

SetTimer, functionC , 1000

OnExit, ExitSub  

functionA ()
{
  ; some gdip stuff 
}

functionB ()
{
  ; some gdip stuff 
}

functionC ()
{
  ; some gdip stuff 
}

ExitSub:
Gdip_Shutdown(gdipToken)
return

Code: Select all



SetTimer, functionC , 1000

functionA ()
{	gdipToken := Gdip_Startup()
  ; some gdip stuff 
  Gdip_Shutdown(gdipToken)
}

functionB ()
{
gdipToken := Gdip_Startup()
  ; some gdip stuff 
  Gdip_Shutdown(gdipToken)
}

functionC ()
{
gdipToken := Gdip_Startup()
  ; some gdip stuff 
  Gdip_Shutdown(gdipToken)
}


return

Re: when to initial a call of Gdip_Startup()

Posted: 21 Dec 2019, 18:23
by swagfag
if u shutdown the token, u destroy the gdip context along with any gdip primitives it might contain. so if ur functions rely on bitmaps from other contexts for example, u will invalidate them

Re: when to initial a call of Gdip_Startup()

Posted: 29 Oct 2020, 04:57
by Albireo
Thank you!
I found my problem. (it was not with gdip_all.ahk and Gdip_Startup())
It was that objects are not local in a function() -- Add one array to another array
I lost my initial values ​​when these were changed in the function().

Therefore, the function() worked the first time (page 1), but not the next (page 2)