phew Posted March 17, 2008 Posted March 17, 2008 hellow thar!i got some problems playing with the guictrl-functions. i created an ListView with 2 columns - but is there any possibility to add ie. 'www.autoitscript.com' to the first column in the first line by using right-mouse on the ListView and there popps up an mouse-menu with the option "insert"?just like this:greetings
phew Posted March 17, 2008 Author Posted March 17, 2008 no one who can give me just a point into the right direction?
rasim Posted March 18, 2008 Posted March 18, 2008 Hi! Try this: expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <GuiMenu.au3> Global $idMenuInsert = 1000 $Gui = GUICreate("Test", 320, 200) $hListView = _GUICtrlListView_Create($GUI, "Links(0)", 10, 10, 300, 180, -1, $WS_EX_CLIENTEDGE) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) _GUICtrlListView_SetColumnWidth($hListView, 0, 295) $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Insert link", $idMenuInsert) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iCode, $tNMHDR, $hWndListView, $iItemCount $hWndListView = $hListView If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_RCLICK If _GUICtrlMenu_TrackPopupMenu($hMenu, $hListView, -1, -1, 1, 1, 2) = $idMenuInsert Then _GUICtrlListView_InsertItem($hListView, "www.autoitscript.com") $iItemCount = _GUICtrlListView_GetItemCount($hListView) _GuiCtrlListView_SetColumn($hListView, 0, "Links(" & $iItemCount & ")") EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc
phew Posted March 18, 2008 Author Posted March 18, 2008 Hi! Try this: expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <GuiMenu.au3> Global $idMenuInsert = 1000 $Gui = GUICreate("Test", 320, 200) $hListView = _GUICtrlListView_Create($GUI, "Links(0)", 10, 10, 300, 180, -1, $WS_EX_CLIENTEDGE) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) _GUICtrlListView_SetColumnWidth($hListView, 0, 295) $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Insert link", $idMenuInsert) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iCode, $tNMHDR, $hWndListView, $iItemCount $hWndListView = $hListView If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_RCLICK If _GUICtrlMenu_TrackPopupMenu($hMenu, $hListView, -1, -1, 1, 1, 2) = $idMenuInsert Then _GUICtrlListView_InsertItem($hListView, "www.autoitscript.com") $iItemCount = _GUICtrlListView_GetItemCount($hListView) _GuiCtrlListView_SetColumn($hListView, 0, "Links(" & $iItemCount & ")") EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc thanks a lot, that was exactly what i was looking for!
phew Posted March 19, 2008 Author Posted March 19, 2008 mhh thanks, that helped a lot, but could you please explain where the WM_NOTIFY function is called? i can't find the place that calls the function and sends the parameters to it, so i don't really understand what the parameters have to look like greetings
rasim Posted March 19, 2008 Posted March 19, 2008 @phewi can't find the place that calls the function and sends the parameters to itHere we registered a function:GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
phew Posted March 21, 2008 Author Posted March 21, 2008 okay had to read a lot about this - i did not really work too much with GUI stuff yet - but i think now its all clear to me, thank you
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now