However, using winapi in a function with labels or hotkeys does not cause Duplicate function definition error
No error when running below script, Errors only when compiled
Code: Select all
ILID:=IML_LoadRes("RESICONLV")
Gui:=GuiCreate("-Minimizebox","Test")
GLV:=Gui.AddListview("x10 y+20 w300 h300 Icon")
GLV.SetImageList(ILID,0)
Loop 20
GLV.Add("icon" A_Index, A_Index)
Gui.OnEvent("Close",()=>ExitApp())
Gui.Show()
return
IML_LoadRes(Ord:="") ; by SKAN www.autohotkey.com/forum/viewtopic.php?t=72282
{
hRes := FindResource(0, Ord, 10)
hDat := LoadResource(0, hRes)
pDat := LockResource(hDat)
nSiz := SizeofResource(0, hRes)
if nSiz < 1
Return (ErrorLevel:=3) >> 64
hData := GlobalAlloc(2,nSiz)
pData := GlobalLock(hData)
RtlMoveMemory(pData,pDat,nSiz)
GlobalUnlock(hData)
DllCall("ole32\CreateStreamOnHGlobal","UInt",hData,"Int",1,"UIntP",pStream)
himl := ImageList_Read(pStream)
DllCall(NumGet(NumGet(1*pStream)+2*A_PtrSize),"UInt",pStream)
GlobalFree(hData)
Return himl
}
SomethingFunc()
{
FindResource(0, Ord, 10)
LoadResource(0, hRes)
LockResource(hDat)
SizeofResource(0, hRes)
}
If winpai is added to the label or hotkey, normal execution
label:
FindResource(0, Ord, 10)
LoadResource(0, hRes)
LockResource(hDat)
SizeofResource(0, hRes)
return
Code: Select all
ILID:=IML_LoadRes("RESICONLV")
Gui:=GuiCreate("-Minimizebox","Test")
GLV:=Gui.AddListview("x10 y+20 w300 h300 Icon")
GLV.SetImageList(ILID,0)
Loop 20
GLV.Add("icon" A_Index, A_Index)
Gui.OnEvent("Close",()=>ExitApp())
Gui.Show()
return
IML_LoadRes(Ord:="") ; by SKAN www.autohotkey.com/forum/viewtopic.php?t=72282
{
hRes := FindResource(0, Ord, 10)
hDat := LoadResource(0, hRes)
pDat := LockResource(hDat)
nSiz := SizeofResource(0, hRes)
if nSiz < 1
Return (ErrorLevel:=3) >> 64
hData := GlobalAlloc(2,nSiz)
pData := GlobalLock(hData)
RtlMoveMemory(pData,pDat,nSiz)
GlobalUnlock(hData)
DllCall("ole32\CreateStreamOnHGlobal","UInt",hData,"Int",1,"UIntP",pStream)
himl := ImageList_Read(pStream)
DllCall(NumGet(NumGet(1*pStream)+2*A_PtrSize),"UInt",pStream)
GlobalFree(hData)
Return himl
}
SomethingFunc()
{
FindResource(0, Ord, 10)
LoadResource(0, hRes)
LockResource(hDat)
SizeofResource(0, hRes)
}
label:
FindResource(0, Ord, 10)
LoadResource(0, hRes)
LockResource(hDat)
SizeofResource(0, hRes)
return