Duplicate function definition error in Compiled script

Post AHK_H specific scripts & libraries and discuss the usage and development of HotKeyIt's fork/branch
rodemp
Posts: 44
Joined: 15 Nov 2016, 00:28

Duplicate function definition error in Compiled script

01 Aug 2019, 00:36

Duplicate function definition error occurs When winapi used in one function is used in another function when using winapi directly, not dllcall()

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

Return to “AutoHotkey_H”

Who is online

Users browsing this forum: No registered users and 9 guests