Page 4 of 23

Re: GDI+ standard library 1.45 by tic

Posted: 23 Apr 2015, 13:03
by Coco
guest3456 wrote:actually, you can thank AHK syntax choices for confusing you about this.
I think GeekDude is implying (in response to tic's statement that b := new A() ; where 'A' is an instance still works) that the fact that an object deriving from another object can become a prototype itself should be attributed to prototype-based OOP - which I think is correct since that is how prototyping works. If so, it has nothing to do with syntax in this context since a := {}, b := new a, c := new b, d := new c kind of sums up prototype-based OOP and is a generally normal syntax of stating that a new object is being created and that it is deriving from another object. Unless you're talking about the choice to store class objects in a normal variable as the "confusing" part... Well a class declaration in AHK is simply: var myClass = { "myMethod": function() { . . . } } in Javascript.
guest3456 wrote:but if a user somehow does MyClass := "" will this class be released and no mechanism to start it back up?
If MyClass contains the only reference to an object, then there's no way to retrieve it. If one removes the "__Class" key you can see it being released via __Delete defined in a base object:

Code: Select all

A := "" ; release
return

class A extends B {
	static ClassName := ObjDelete(A, "__Class") ; remove '__Class' key to allow trigger of __Delete
}

class B {
	__Delete() {
		MsgBox RELEASED
	}
}

Re: GDI+ standard library 1.45 by tic

Posted: 23 Apr 2015, 13:10
by geek
As usually Coco, your example perplexes me. I am not really sure what's going on there

Re: GDI+ standard library 1.45 by tic

Posted: 23 Apr 2015, 14:36
by guest3456
Coco wrote:Unless you're talking about the choice to store class objects in a normal variable as the "confusing" part...
you'll have to ask tic why he got confused. my guess is that he didn't already know that by writing class Gdip he already had created an object that was stored in a super global variable named Gdip. that is what both you and GeekDude tried to enlighten him on.

the confusing part is using "class" syntax keywords at all in a prototype based language, leading to tic's, and probably many other's, confusion. its normal to think that no instances exist prior to using new, but thats not exactly the case. the only reason i'm aware of that is because i read the discussion years ago on the other forum when Lexikos was determining whether or not he should introduce "class" syntax and how it may be translated. as well as learning about prototype based OOP at that same time
GeekDude wrote:As usually Coco, your example perplexes me. I am not really sure what's going on there
one special difference of objects defined with the "class" keyword is that a hidden key named "__Class" is present, with its value being the string of the name of the class. apparently one of the voodoo items is that deleting that key allows the object to be fully released somehow

Re: GDI+ standard library 1.45 by tic

Posted: 23 Apr 2015, 14:41
by geek
We're getting quite a bit off track here, I think. @tic: Do you have a beta version of the class based gdip library? I'd like to give it a try.

Re: GDI+ standard library 1.45 by tic

Posted: 23 Apr 2015, 16:57
by tic
GeekDude wrote:We're getting quite a bit off track here, I think. @tic: Do you have a beta version of the class based gdip library? I'd like to give it a try.

Yep! Very early on and still lots to change and add.
Most of the content of this test will have to be refactored, but nonetheless you can test it if you like.
Download the library and the test:

https://github.com/tariqporter/Gdip/tree/GdipDOM

Excerpt from test:

Code: Select all

#Persistent
#SingleInstance Force

#include Gdip2.ahk

gdip := new Gdip()
win1 := new gdip.Window({ "width":400, "height":400 })
css := { "width":200, "height": 200, "background-color":{A:100, R:20, G:40, B:200}, "border-radius":0, "border-width":20, "border-color":{A:200, R:50, G:150, B:130} }
win1.shapeInsert("#square1.square-class", new gdip.Shape(css))
css.x := 200
win1.shapeInsert("#square2.square-class", new gdip.Shape(css))
win1.Update({ x: (A_ScreenWidth - win1.width) / 2, y: (A_ScreenHeight - win1.height) / 2 })
win1.MainLoop("Update", 10, { tick: A_TickCount, time: 500 })
return

;#####################################################################################

Update(win, p)
{
	if (A_TickCount - p.tick > p.time)
	{
		p.tick := A_TickCount, p.on := !p.on
		css := { "border-color":{A:200, R:200, G:150, B:30}, "border-width":50 }
		win.shapeMatch(p.on ? "#square1" : "#square2").css(css)
		css := { "border-color":{A:200, R:50, G:150, B:130}, "border-width":20 }
		win.shapeMatch(p.on ? "#square2" : "#square1").css(css)
		win.shapeMatch(".square-class").css(p.on ? { "border-radius": 10 } : { "border-radius": 0 })
	}
}

;#####################################################################################

Esc::
ExitApp
return

Re: GDI+ standard library 1.45 by tic

Posted: 26 Apr 2015, 11:57
by Guest
I'm curious, why doesn't the functionality of GDI+ just get coded standard commands in AHK that everyone can easily use?

Re: GDI+ standard library 1.45 by tic

Posted: 27 Apr 2015, 18:53
by tic
Guest wrote:I'm curious, why doesn't the functionality of GDI+ just get coded standard commands in AHK that everyone can easily use?
In the old ahk, I think it would have been difficult to have any code be easy to understand and implement without the use of objects. In current ahk, the old Gdip library could be implemented fairly easily, but I'm implementing a large overhaul of the library currently.

Re: GDI+ standard library 1.45 by tic

Posted: 27 Apr 2015, 18:54
by tic
Hi

Please could I get feedback of the current state of the Gdip2 library.
Run test 1 and 2:

https://github.com/tariqporter/Gdip/tree/GdipDOM

There is still a lot more to do, but it would be useful to have feedback before progressing

Thanks

Re: GDI+ standard library 1.45 by tic

Posted: 27 Apr 2015, 18:56
by geek
Any reason you don't ever join the live chat? It'd make for quick feedback

Edit: The scripts open, I see some squares, then the script immediately crashes with an "AutoHotkey is not responding" window. AHK 1.1.21.03 unicode 32 bit

Re: GDI+ standard library 1.45 by tic

Posted: 27 Apr 2015, 23:16
by tic
GeekDude wrote:Any reason you don't ever join the live chat? It'd make for quick feedback

Edit: The scripts open, I see some squares, then the script immediately crashes with an "AutoHotkey is not responding" window. AHK 1.1.21.03 unicode 32 bit
No, you're right, I should. I usually need to concentrate on one thing and can work a long time if I have no distractions.

Strange. I had been having that error, and was to do with Gdip.Timer class. I believe it was because the callback was disposed after it had been called, so had an invalid reference. I thought I had fixed this however, and have it working on 3 different machines. They were running 64-bit 1.1.19.3, but I changed to 32-bit 1.1.21.03 and they are still functioning. Try commenting out line 2016 and 2026

Code: Select all

timers.Remove(v.reference)
DllCall("GlobalFree", "ptr", timer.callBack)
And see if it functions. You can press Esc to escape as the memory should keep growing (Very slowly)

Re: GDI+ standard library 1.45 by tic

Posted: 28 Apr 2015, 13:10
by geek
Still crashes immediately

Re: GDI+ standard library 1.45 by tic

Posted: 28 Apr 2015, 14:59
by tic
GeekDude wrote:Still crashes immediately
All working now. Thanks for testing GeekDude
If others could please test, it would be appreciated

Re: GDI+ standard library 1.45 by tic

Posted: 28 Apr 2015, 15:22
by kon
All three seem to work. (U32 1.1.21.03)

Re: GDI+ standard library 1.45 by tic

Posted: 28 Apr 2015, 15:27
by kon
Just tried it with A32 1.1.21.03, I'm not seeing the text in the third test.

Re: GDI+ standard library 1.45 by tic

Posted: 28 Apr 2015, 15:29
by tic
kon wrote:Just tried it with A32 1.1.21.03, I'm not seeing the text in the third test.
Thank you for testing kon. I am however dropping ANSI support. It greatly simplifies things to have unicode only going forward

Re: GDI+ standard library 1.45 by tic

Posted: 28 Apr 2015, 15:35
by kon
lol, ok I guess I missed that. Thanks.

Re: GDI+ standard library 1.45 by tic

Posted: 25 Jun 2015, 09:10
by bichlepa
Hi tic.
I'm using GDI+ for AutoHotFlow.

It works fine, but there is one little issue. The picture is flickering when it is often rendered. The effect is most frequent if the computer is slow. The flickering happens when calling the SetImage() function. Is it possible to avoid flickering?
You may take a look at my script where I use GDI+.

Re: GDI+ standard library 1.45 by tic

Posted: 25 Jun 2015, 09:27
by jNizM
Hey bichlepa.
Can you test the function directly without the lib?

Code: Select all

; Msg => STM_SETIMAGE := 0x0172    |    wParam => IMAGE_BITMAP := 0    |    lParam => hBitmap
hObject := DllCall("user32.dll\SendMessage", "Ptr", hWnd, "UInt", 0x0172, "Ptr", 0, "Ptr", hBitmap, "Ptr")
DllCall("gdi32.dll\DeleteObject", "UPtr", hObject)


/*
SetImage(hwnd, hBitmap)
{
    SendMessage, 0x172, 0x0, hBitmap,, ahk_id %hwnd%
    E := ErrorLevel
    DeleteObject(E)
    return E
}
*/
ps: Ich bin ehrlich gesagt kein Fan von solchen "Riesen" Lib's. Wenn ich was in gdip brauche schreibe ich mir die DllCall's direkt ins Programm und lade mir keine lib mit gefühlten 1000 Funktionen von denen ich 90% nicht mal brauche.

Re: GDI+ standard library 1.45 by tic

Posted: 25 Jun 2015, 10:17
by tic
bichlepa

That is happening because SetImage is not really meant for rendering a state machine. it is meant for rendering a persistent image.
You will need to call BitBlt with an image created in the way it is created for the gui examples, and BitBlt it in a timer. i can show you an example if you have problems. I demonstrated it in an asteroids example on the old forum.

jNizM

The problem is with WM_PAINT still being called. This won't help. It is not a problem with the library

Re: GDI+ standard library 1.45 by tic

Posted: 25 Jun 2015, 12:21
by bichlepa
@ tic
Many thanks! I found your asteroids example and copied all the needed code. Now there is no flickering anymore and the performance is highly increased! :thumbup:

@ jNizM
Also, ich bin ein großer Fan von solchen Libs. Auch wenn man fast nie alles braucht, so wäre es doch für mich erheblich mehr Aufwand, die benutzen Funktionen zu implementieren. Ich habe dank dieser Lib erst erfahren, dass es sowas wie GDI gibt.