Schreibweise Objektsyntax

Stelle Fragen zur Programmierung mit Autohotkey

Moderator: jNizM

User avatar
Frosti
Posts: 426
Joined: 27 Oct 2017, 14:30
Contact:

Schreibweise Objektsyntax

29 Nov 2018, 10:31

Ich benutze mittlerweile immer mal wieder einfache Objekte als Rückgabeparameter von Funktionen, doch immer noch habe ich Schwierigkeiten den richtigen Syntax für die weitere Verwendung im Skript zu finden. Folgend mein derzeitiges Problem:

ich will hier pBitmap und hBitmap zurück bekommen um diese an verschiedenen Stellen im Hauptteil zur Verfügung zu haben.

Code: Select all

LoadPicture(Path) {
  pBitmap := Gdip_CreateBitmapFromFile(picname)
  hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
return {"hBitmap": hBitmap, "pBitmap": pBitmap}
}

Gdip_RotateBitmap(pBitmap, Angle, Dispose=1) { 													;-- returns rotated bitmap. By Learning one.

  Gdip_GetImageDimensions(pBitmap, Width, Height)
  Gdip_GetRotatedDimensions(Width, Height, Angle, RWidth, RHeight)
  Gdip_GetRotatedTranslation(Width, Height, Angle, xTranslation, yTranslation)
  pBitmap2 := Gdip_CreateBitmap(RWidth, RHeight)
  G2 := Gdip_GraphicsFromImage(pBitmap2), Gdip_SetSmoothingMode(G2, 4), Gdip_SetInterpolationMode(G2, 7)
  Gdip_TranslateWorldTransform(G2, xTranslation, yTranslation)
  Gdip_RotateWorldTransform(G2, Angle)
  Gdip_DrawImage(G2, pBitmap, 0, 0, Width, Height)
  hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
  Gdip_ResetWorldTransform(G2)
  Gdip_DeleteGraphics(G2)
  if Dispose
	Gdip_DisposeImage(pBitmap)

return hBitmap
} ; http://www.autohotkey.com/community/viewtopic.php?p=477333#p477333

Code: Select all

BOPic:= Object()
picname:= % RamDiskPath . "\sppreview-" . SubStr("00000" . page, -6) . ".png"
BOPic:= LoadPicture(picname)
;-: Preview Picture
Gui, BOPV: Add, Picture, % "xm y" (LText2Y + LText2H + 5) " vLPic1 Section 0xE BackGroundTrans HWNDhLPic1", % "HBITMAP: " BOPic["hBitmap"]
...
...
BOPVPageTurn: 

	BOPic["hBitmap"]::= Gdip_RotateBitmap(BOPic["pBitmap"], 90, 1)
	GuiControl, BOPV: , LPic1, % "HBITMAP: " BOPic["hBitmap"]

return
schreibweisen wie,

Code: Select all

 ... , % "HBITMAP: " BOPic.hBitmap
oder

Code: Select all

 ... , % "HBITMAP: " BOPic[hBitmap]
funktionieren auch nicht.

Bisher war ich mit Trial und Error und Nachlesen irgendwann erfolgreich.
Dieses mal nicht.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Schreibweise Objektsyntax

29 Nov 2018, 12:10

Code: Select all

LoadPicture(Path) {
  pBitmap := Gdip_CreateBitmapFromFile(picname)
  hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap)
return {"hBitmap": hBitmap, "pBitmap": pBitmap}
}

Code: Select all

LoadPicture(Path) {

Code: Select all

pBitmap := Gdip_CreateBitmapFromFile(picname)
Path ==>> picname
??

Code: Select all

... , % "HBITMAP: " BOPic["hBitmap"] ; ok
... , % "HBITMAP: " BOPic.hBitmap ; ok
... , % "HBITMAP: " BOPic[hBitmap] ; not ok
User avatar
Frosti
Posts: 426
Joined: 27 Oct 2017, 14:30
Contact:

Re: Schreibweise Objektsyntax

29 Nov 2018, 13:20

Danke swagfag. Ich weiß nicht ob Du Deutsch verstehst, deshalb:
If you are not looking in the right place, you will never find anything! Or as my grandmother used to say, even a blind chicken sometimes finds a grain.
But I answered: "I hope that it had not starved before". She turned around and said, "Do not ask me, I'm not an animal!"

Return to “Ich brauche Hilfe”

Who is online

Users browsing this forum: No registered users and 61 guests