I would like to have dynamic profiles in runtime - changeable by the user in runtime. For this the ETM profile is great.
But the problem is that the profile only seems to be selectable from the combobox. I would like to be able to select one of these profiles from VBA.
The following code can select a profile in the combobox
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Sub Profile_Select()
Dim zPIC As DynPicture
Dim ret As Long
Dim hwnd As Long
Set zPIC = zenOn.Projects.Item("DEP02").DynPictures.Item("pic_LOCALTREND")
hwnd = zPIC.Elements.Item("Control element_1").hwnd
ret = SendMessage(hwnd, &H14F, 1, 0) ' CB_SHOWDROPDOWN, 1 to show
ret = SendMessage(hwnd, &H14E, 3, 0) ' CB_SETCURSEL, 3 is wanted index
ret = SendMessage(hwnd, &H201, 0, -1) ' WM_LBUTTONDOWN
ret = SendMessage(hwnd, &H202, 0, -1) ' WM_LBUTTONUP
ret = SendMessage(hwnd, &H14F, 0, 0) ' CB_SHOWDROPDOWN, 0 to hide
End Sub
But unfortunately it does not activate the profile.
Besides the above a also tried something similar to this: http://www.codenewsgroups.net/group/...opic15499.aspx
But that doesn't seem to work either
I got the following code:
Public Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Public Const WM_COMMAND = &H111
Const CBN_SELCHANGE = &H1
Public Const GW_HWNDNEXT = 2
Public Const GW_CHILD = 5
Public Const GWL_ID = (-12)
Public Const CB_SELECTSTRING As Long = &H14D
Sub Profile_Select2()
Dim DRHwnd As Long
Dim PosID As Long
Dim zPIC As DynPicture
Dim ret As Long
Dim hwnd As Long
Set zPIC = zenOn.Projects.Item("DEP02").DynPictures.Item("pic_LOCALTREND")
hwnd = zPIC.Elements.Item("Control element_1").hwnd
' Get the parent of the combobox, this path is found using Winspector Spy
DRHwnd = Application.hwnd
DRHwnd = GetWindow(DRHwnd, GW_CHILD)
DRHwnd = GetWindow(DRHwnd, GW_CHILD)
DRHwnd = GetWindow(DRHwnd, GW_HWNDNEXT)
DRHwnd = GetWindow(DRHwnd, GW_HWNDNEXT)
DRHwnd = GetWindow(DRHwnd, GW_HWNDNEXT)
DRHwnd = GetWindow(DRHwnd, GW_CHILD)
SendMessage hwnd, CB_SELECTSTRING, -1, ByVal "Temp" ' "Temp" is a profile name - this works
PosID = GetWindowLong(hwnd, GWL_ID) ' this gives the same id as Winspector Spy
ret = SendMessage(DRHwnd, WM_COMMAND, CBN_SELCHANGE * &H10000 Or PosID, hwnd) ' this does nothing... according to Winspector Spy the message is received by the parent
End Sub
Any suggestions?