is8591 Posted October 15, 2007 Posted October 15, 2007 Running GUI in OnEvent and using Notify to catch ListView ItemChange event. There are times when contents of ListView point to INI sections which were deleted, so need to inform that section was deleted and Default will be used. Any suggestions are welcomed. Thank you.
Achilles Posted October 15, 2007 Posted October 15, 2007 Do you have code? I think that would us solve the problem. But anyways... maybe don't tell the user that they used the default until your done doing it. That way you should be out of the GuiRegisterMsg() part already. My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
is8591 Posted October 15, 2007 Author Posted October 15, 2007 Here is a small part of the code to illustrate it. When you click on items in ListView Msgbox will pop up. ClickOK to close the Msgbox and the cursor becomes Drag-and-Drop. I tested my full code for several days and that's the only problem I have noticed, everything else seems to work OK. I don't know if anything outside my code is going to mess up if I delay the GuiRegisterMsg(). But if cursor the only problem - how can I prevent cursor changing. As far as telling later: When user clicks on ListView he selects operational profile, I have to load profile parameters into separate GUIs. So normally I give user a chance to select a different profile instead of Default. My whole script is Event driven - any suggestions how I can be out of GuiRegisterMsg() and then show the warning. expandcollapse popup#include <GUIConstants.au3> #Include <GuiListView.au3> Global Const $WM_NOTIFY = 0x004E ;ListView Events Global Const $NM_FIRST = 0 Global Const $NM_LAST = (-99) Global Const $NM_OUTOFMEMORY = ($NM_FIRST - 1) Global Const $NM_CLICK = ($NM_FIRST - 2) Global Const $NM_DBLCLK = ($NM_FIRST - 3) Global Const $LVN_FIRST = -100; Global Const $LVN_ITEMCHANGED = ($LVN_FIRST-1) Opt("GUIOnEventMode", 1) $Accounts1 = GUICreate("GUI", 481, 294, 203, 126) GUISetOnEvent($GUI_EVENT_CLOSE, "Accounts1Close") $lv = GUICtrlCreateListView(" | ", 133, 94, 266, 58,BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL,$LVS_NOCOLUMNHEADER),BitOR($LVS_EX_FULLROWSELECT,$LVS_EX_FLATSB)) GUICtrlSetCursor(-1, 2) GUICtrlCreateListViewItem("abc|def", $lv) GUICtrlCreateListViewItem("ghi|klm", $lv) GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events") GUISetState(@SW_SHOW) While 1 Sleep(100) WEnd Func Accounts1Close() Exit EndFunc ; WM_NOTIFY event handler for listview Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam Local $nNotifyCode = _HiWord($wParam) Local $nID = _LoWord($wParam) Local $tagNMHDR, $event, $hwndFrom, $code $tagNMHDR = DllStructCreate("int;int;int;uint;uint;uint;int;int", $lParam) ; NMHDR hdr; iItem; iSubItem; uNewState; uOldState; uChanged; ptAction; If @error Then Return $event = DllStructGetData($tagNMHDR, 3) ;ConsoleWrite("Event:"&$nID & "::" & $nNotifyCode & "::" & $event & @CRLF) Select Case $wParam = $lv Select ;Case $event = $NM_CLICK ; ListView_Click () ;Case $event = $NM_DBLCLK ; ListView_DoubleClick () Case $event = $LVN_ITEMCHANGED If DllStructGetData($tagNMHDR, 6) = 3 And DllStructGetData($tagNMHDR, 7) = 0 And DllStructGetData($tagNMHDR, 8) = 8 Then lv_Change() EndSelect EndSelect $tagNMHDR = 0 $event = 0 $lParam = 0 Return $GUI_RUNDEFMSG EndFunc ;==>WM_Notify_Events Func _HiWord($x) Return BitShift($x, 16) EndFunc ;==>_HiWord Func _LoWord($x) Return BitAND($x, 0xFFFF) EndFunc ;==>_LoWord ;fill in listview header Func lv_Change() ; Local $a = _GUICtrlListViewGetItemText($lv_MrSch,-1,2) ; GUICtrlSetData($dt_MrSch, _GUICtrlListViewGetItemText($lv_MrSch,-1,0)) ; If StringInStr($av_StrSet[9], $a) =0 Then MsgBox(48,"test","") ; $a = "default" ; EndIf EndFunc
Siao Posted October 15, 2007 Posted October 15, 2007 (edited) Now I haven't really gotten into your code and your task that much, so won't say anything about different implementations, but here's a couple of quick ways to fix your problem... Run that message box as separate process, like this: Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(0, ''Hello World!'', ''Hi!'')"') Or add a LVN_BEGINDRAG handler to your WM_NOTIFY function, and return it if it's caused by your messagebox: ;start of the script: Global $fNoDrag = False ... ... ;part of your WM_NOTIFY: Case $event = $LVN_ITEMCHANGED If DllStructGetData($tagNMHDR, 6) = 3 And DllStructGetData($tagNMHDR, 7) = 0 And DllStructGetData($tagNMHDR, 8) = 8 Then lv_Change() EndIf Case $event = -109;$LVN_BEGINDRAG If $fNoDrag Then $fNoDrag = False Return 0 EndIf EndSelect ... ... ;when you have to show your messagebox: MsgBox(48,"test","") $fNoDrag = True Edited October 15, 2007 by Siao "be smart, drink your wine"
is8591 Posted October 15, 2007 Author Posted October 15, 2007 Now I haven't really gotten into your code and your task that much, so won't say anything about different implementations, but here's a couple of quick ways to fix your problem... Run that message box as separate process, like this: Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(0, ''Hello World!'', ''Hi!'')"') Or add a LVN_BEGINDRAG handler to your WM_NOTIFY function, and return it if it's caused by your messagebox: ;start of the script: Global $fNoDrag = False ... ... ;part of your WM_NOTIFY: Case $event = $LVN_ITEMCHANGED If DllStructGetData($tagNMHDR, 6) = 3 And DllStructGetData($tagNMHDR, 7) = 0 And DllStructGetData($tagNMHDR, 8) = 8 Then lv_Change() EndIf Case $event = -109;$LVN_BEGINDRAG If $fNoDrag Then $fNoDrag = False Return 0 EndIf EndSelect ... ... ;when you have to show your messagebox: MsgBox(48,"test","") $fNoDrag = True Thank you this takes care of the cursor.
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