-
Recently Browsing 0 members
No registered users viewing this page.
-
Similar Content
-
By benners
I have a GUI that contains a treeview and what I am trying to do is to get the context menu to only show when an item is right clicked. Currently, as it's assigned to the treeview, the context menu activates whenever the treeview is clicked. Rather than keep enabling\disabling the menu items I am in need of a way limit the menus popup.
One of the options on the menu will open another GUI and disable the parent, for this reason, I cannot do much in the WM_NOTIFY portion as it hangs the program and I don't want to hang around blocking the messages.
The other option is to create a menu for each treeview item when the are added to the list. This will fix the issue but there maybe 100+ items and I don't want to have that many menus all of which have the same 2/3 options.
I am currently looking at using an Adlib function as mentioned here by Melba. I could create and destroy the menu each time and unregister the adlib when the function closes.
Anyway, a producer code is below if there are any other ideas, or I've missed the obvious. Cheers
#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <TreeViewConstants.au3> #include <GuiTreeView.au3> #include <ButtonConstants.au3> #include <GUIListBox.au3> Opt('MustDeclareVars', 1) _Main() Func _Main() Local $hGUI = GUICreate("TreeView", 400, 300) Global $cTreeView = GUICtrlCreateTreeView(10, 10, 380, 280) Local $cParent = GUICtrlCreateTreeViewItem('List', $cTreeView) For $i = 1 To 5 GUICtrlCreateTreeViewItem('Item ' & $i, $cParent) Next Local $cCMenu = GUICtrlCreateContextMenu($cTreeView) Global $cCMenuEdit = GUICtrlCreateMenuItem("Edit", $cCMenu) GUICtrlSetState(-1, $GUI_DISABLE) _GUICtrlTreeView_Expand($cTreeView) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW) Local $nMsg While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $cCMenuEdit EndSwitch WEnd EndFunc ;==>_Main Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Local $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom") Local $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") Local $iCode = DllStructGetData($tNMHDR, "Code") Switch $iIDFrom Case $cTreeView Switch $iCode Case $NM_RCLICK Local $tPoint = _WinAPI_GetMousePos(True, $hWndFrom) Local $tHitTest = _GUICtrlTreeView_HitTestEx($hWndFrom, DllStructGetData($tPoint, 1), DllStructGetData($tPoint, 2)) If BitAND(DllStructGetData($tHitTest, "Flags"), $TVHT_ONITEM) Then If _GUICtrlTreeView_Level($cTreeView, DllStructGetData($tHitTest, 'Item')) > 0 Then GUICtrlSetState($cCMenuEdit, $GUI_ENABLE) Else GUICtrlSetState($cCMenuEdit, $GUI_DISABLE) EndIf _GUICtrlTreeView_SelectItem($hWndFrom, DllStructGetData($tHitTest, 'Item')) Else GUICtrlSetState($cCMenuEdit, $GUI_DISABLE) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY
-
By edubensa
Hi! Can someone help me with this? I upgraded from SciTe Edit Lite to full version. Now every time I edit a script it opens on a new SciTe tab, but I want it opens on a new window like before the upgrade. Can someone help me with that? Thanks!!
-
By Vipan
Hi,
I have developed Java maven based framework and integrated AutoIt in it. I am automated a desktop application. During automation, I am facing below issue. Can someone please guide me?
1. I am unable to select a menu option from a nested tree view:
Example-
TreeTitle1
TreeTitle1.1
TreeOption ToSelect
In above case, TreeTitle1 is a folder in which TreeTitle2 is another folder and the TreeOptionToSelect is the one i want to select.
I tried below command:
AutoItX autoIt = new AutoItX();
autoIt.controlTreeViewExpand(pagetitle,"",treecontrolname,"#0|#0");
autoIt.controlTreeViewSelect(pagetitle,"",treecontrolname,"#0|#0|#0");
But it didn't work... kindly help
-
By AntS
Help! The mouse clicks I'm sending to a control on a dialog box produce no response.
The dialog box in question handles advanced display properties. The tab page my script interacts with is created by Trident Microsystems. It allows the user to enhance or attenuate the screen's RGB values. (See image.) My script automates the process of changing these in order to adjust the screen's hue or, when the red, green and blue values are all the same, the brightness.
Producing a script to change the brightness has been quite straightforward. I use ControlClick() to send a mouse click to one of the trackbars on the right of the tab page. By default, they're linked and so move as one. The difficulty I'm having however is in automating the process when the desired red, green and blue values aren't the same as each other.
Ordinarily, there are three ways of doing this:
(1) clear the Link check box to unlink the three trackbars then either click on each trackbar or drag their sliders,
(2) clear the Link tick-box then for each colour, click on the corresponding trackbar slider (to select it) then click on a point on the graph, and
(3) click on the Load button to open an Open dialog box and load a preset (stored as a .gam file).
However, when ControlClick() is used to clear the Link check box or to push the Load button, nothing happens. Making the dialog box the active window makes no difference.
The AutoIt Window Info tool indicates that the Reload a Bitmap, Save, Load and Reset buttons, the Link check box and the graph are all the same control. (See other images.) In fact, it there are only four controls on the page: the tab page, which is an instance of a SysTabControl32 class, and the three trackbars, each of which is an instance of the TridentTrackBar class. (Am unsure whether the SysTabControl32 class is a Windows or third-party control.)
What's the solution?
Note that the MouseClick() function—as opposed to ControlClick()—does work, but having AutoIt commandeer the screen pointer isn't an acceptable solution.
For the sake of completeness, here's the relevant code fragment for the Link check box.
;unlink trackbars WinActivate("(Multiple Monitors)") ControlClick("(Multiple Monitors)", "", 12320, "left", 1, 211, 252)
-
By jcpetu
Hi people, I'm trying to dynamically populate a TreeView based on a script from Water that I modified for my needs. but I can't figured it out how to make it work.
Here what I have in case anyone can help me, thanks in advance:
#include <array.au3> #include <GUIConstantsEx.au3> #include <GuiTreeView.au3> Local $aTV1[14][3] = [ _ ['1', 'Text 1', -1], _ ;-1 idicates it's an index item ['2', 'Text 2',-1], _ ['3', 'Text 3',-1], _ ['1-1', 'Text 1-1',0], _ ['1-2', 'Text 1-2',0], _ ['2-1', 'Text 2-1',0], _ ['2-2', 'Text 2-2',0], _ ['2-1-1', 'Text 2-1-1',0], _ ['2-1-2', 'Text 2-1-2',0], _ ['2-1-2-1', 'Text 2-1-2-1',0], _ ['2-1-2-1-1', 'Text 2-1-2-1-1',0], _ ['3-1', 'Text 3-1',0], _ ['3-1-1', 'Text 3-1-1',0], _ ['3-1-1-1', 'Text 3-1-1-1',0]] ;_ArrayDisplay($aTV1) Local $Gui = GUICreate('TreeView Example', 500, 600) Local $tv = GUICtrlCreateTreeView(10, 30, 450, 550) GUISetState() _pop_treeview($tv, $aTV1) While 1 Switch GUIGetMsg() Case $gui_event_close Exit EndSwitch WEnd Func _pop_treeview($hTV, $array) Local $TimeInitial = TimerInit(), $Hours, $Mins, $Secs, $item _ArraySort($array, 0, 0, 0, 0) ;------------------------- sort Ascending on column 0 ;_ArrayDisplay($array) $idxroot = _GUICtrlTreeView_Add($hTV, 0, "index") For $i = 0 To UBound($array) - 1 ConsoleWrite("$array[" & $i & "][" & 0 & "] = " & $array[$i][0] & @CRLF) If $array[$i][0] = '' Then ExitLoop ;--------------- Exit at first empty element $item = '' If $array[$i][2] = -1 Then ;------------------------ Add root element _GUICtrlTreeView_AddChild($hTV, $idxroot, $array[$i][1]) Else $item = StringLeft($array[$i][0], StringInStr($array[$i][0], "-", 1, -1) - 1) ConsoleWrite("$item = " & $item & @CRLF) $Found = _ArrayBinarySearch($array, $item, 0, 0, 0) ;search on column 0 Switch $Found Case 0 ;----------------------------------- Value wasn't found in array ConsoleWrite("Item NOT found @error= " & @error & @CRLF) Case Else ConsoleWrite("Item found " & @CRLF) _GUICtrlTreeView_AddChild($hTV, $Found, $array[$i][1]) EndSwitch EndIf Next _GUICtrlTreeView_Expand($hTV) EndFunc ;==>_pop_treeview
-