Hi philho,
Torteths thread caught my attention too since i am developing and frontend for H.264 encoding and would like to have updown controls which output floats since some of the commandline params the frontend passes to x264.exe are floats.
I apreciate your work on this but still think that this is a bunch of code and i think i might have and solution which would be easier to maintain.
Problem is that it demands to work with structures.
Now youre one of ahk's bitjugglers

and might tell me whats wrong with following code
Edit:
Found the error and reworked the script. Here you go.
Code:
#SingleInstance force
;"(ClassNN of the editcontrol which should have floats in it, found via windowspy)|(minvalue)|(maxvalue)|(steps)(`n)(NextEditsClassNN...)"
udEditList:="Edit1|10|50|0.25`nEdit2|-10|10|0.5"
;add the controls as usuall
Gui Add, Edit, w100 h20 vudedit,
Gui Add, UpDown, w30 h24 vud , 23
Gui Add, Edit, w100 h20 vudedit2,
Gui Add, UpDown, w30 h24 vud2 , 5
Gui, Show
;look for the WM_NOTIFY message
OnMessage(0x4E, "WM_NOTIFY")
return
WM_NOTIFY(wParam, lParam)
{
if (ExtractIntegerP(lParam,8,1) = -722) ; if this is true a updowncontrol has send an UDN_DELTAPOS message
{
udHwnd:=ExtractIntegerP(lparam,0,0)
iPos:=ExtractIntegerP(lparam,12,1)
iDelta:=ExtractIntegerP(lparam,16,1)
SendMessage, 0x46A,,,, ahk_id %udHwnd% ;gets the buddy of the updowncontrol that send the UDN_DELTAPOS message
if (errorlevel)
{
udEditHwnd:=errorlevel
udData:=GetudData(udEditHwnd,iDelta) ;parse the udEditList and return the new value
if udData = FAIL
Return False ;the item was not found in the udEditList
ControlSetText,, % udData , ahk_id %udEditHwnd% ;set the new value in the editcontrol
return True ; indicates that the proposed change from the updowncontrol should be discarded
}
else
return False ; don't discard the proposed change by the updowncontrol
}
}
GetudData(_udEditHwnd,_delta)
{
local udEditListItem, udEdithwnd, udEdit
Loop, Parse, udEditList, `n, `n
{
StringSplit, udEditListItem, A_LoopField,|
ControlGet, udEdithwnd, Hwnd,, %udEditListItem1%, A
if (udEdithwnd = _udEdithwnd)
{
ControlGetText, udEdit,, ahk_id %udEditHwnd%
udEdit+=udEditListItem4*_Delta
if (udEdit < udEditListItem2)
return udEditListItem2
else if (udEdit > udEditListItem3)
return udEditListItem3
else
return udEdit
}
else
continue
}
Return "FAIL"
}
GuiClose:
ExitApp
ExtractIntegerP(ByRef pSource, pOffset = 0, pIsSigned = false, pSize = 4)
{
Loop %pSize%
result += *(pSource + pOffset + A_Index-1) << 8*(A_Index-1)
if (!pIsSigned OR pSize > 4 OR result < 0x80000000)
return result
return -(0xFFFFFFFF - result + 1)
}
@Chris
If you read this, notice this is again an opurtunity for a Hwnd() function like discussed
here because one could simply use the associated vVarNames instead of having to look up the ClassNN with WindowSpy.