Permalink
Browse files

use explicit type checking

v2 now throws exceptions as of v2-a95

from:
https://autohotkey.com/boards/viewtopic.php?f=37&t=48965
  • Loading branch information...
mmikeww committed May 16, 2018
1 parent ddfebba commit 7575c88d70ea6a3b444119ee4afe730e91c64b84
Showing with 12 additions and 6 deletions.
  1. +9 −3 Gdip_All.ahk
  2. +3 −3 README.md
View
@@ -346,7 +346,7 @@ Gdip_BitmapFromScreen(Screen:=0, Raster:="")
_x := _y := 0
hhdc := GetDCEx(Screen, 3)
}
else if (Screen&1 != "")
else if IsInteger(Screen)
{
M := GetMonitorInfo(Screen)
_x := M.Left, _y := M.Top, _w := M.Right-M.Left, _h := M.Bottom-M.Top
@@ -1206,7 +1206,7 @@ Gdip_DrawImagePointsRect(pGraphics, pBitmap, Points, sx:="", sy:="", sw:="", sh:
NumPut(Coord[1], PointF, 8*(A_Index-1), "float"), NumPut(Coord[2], PointF, (8*(A_Index-1))+4, "float")
}
if (Matrix&1 = "")
if !IsNumber(Matrix)
ImageAttr := Gdip_SetImageAttributesColorMatrix(Matrix)
else if (Matrix != 1)
ImageAttr := Gdip_SetImageAttributesColorMatrix("1|0|0|0|0|0|1|0|0|0|0|0|1|0|0|0|0|0|" Matrix "|0|0|0|0|0|1")
@@ -1277,7 +1277,7 @@ Gdip_DrawImage(pGraphics, pBitmap, dx:="", dy:="", dw:="", dh:="", sx:="", sy:="
{
Ptr := A_PtrSize ? "UPtr" : "UInt"
if (Matrix&1 = "")
if !IsNumber(Matrix)
ImageAttr := Gdip_SetImageAttributesColorMatrix(Matrix)
else if (Matrix != 1)
ImageAttr := Gdip_SetImageAttributesColorMatrix("1|0|0|0|0|0|1|0|0|0|0|0|1|0|0|0|0|0|" Matrix "|0|0|0|0|0|1")
@@ -2781,6 +2781,12 @@ IsInteger(Var) {
Return False
}
IsNumber(Var) {
Static number := "number"
If Var Is number
Return True
Return False
}
View
@@ -1,7 +1,7 @@
# AHKv2-Gdip
This repository contains the GDI+ library (Gdip_All.ahk) compatible with [AHK v2-a094](https://autohotkey.com/v2/) and also backwards compatible with AHK v1.1.28.02
This repository contains the GDI+ library (Gdip_All.ahk) compatible with [AHK v2-a096](https://autohotkey.com/v2/) and also backwards compatible with AHK v1.1.28.02
AHK v2 made many changes to the syntax, which is why changes were needed. We have attempted to keep it backwards compatible with AHK v1.1. If you find any errors please report them in the Issues.
AHK v2 made many changes to the syntax, which is why updates were needed. We have attempted to keep it backwards compatible with AHK v1.1. If you find any errors please report them in the Issues.
Support for AHK v1.0 is dropped (find the original `Gdip_All.ahk` library if you need that).
@@ -10,7 +10,7 @@ See the [commit history](https://github.com/mmikeww/AHKv2-Gdip/commits/master) t
# Examples
All of the tutorial files in the `/Examples/` subfolder work successfully on AHK v2.
If you try to run these example files on AHK v1, they will fail. However, the v1 code is still in the files, and simply commented out. Search the example files for "AHK v1" and swap the commented lines to get them working.
If you try to run these example files on AHK v1, they will fail. However, the v1 code is still in the files, just simply commented out. Search the example files for "AHK v1" and swap the commented lines to get them working.
# Usage
All of the Gdip_*() functions use the same syntax as before, so no changes should be required, with one exception:

0 comments on commit 7575c88

Please sign in to comment.