IvanCodin Posted February 7, 2008 Share Posted February 7, 2008 (edited) /edit Bump <-- I got some feedback but none of the suggestions worked --> Bump I used a UDF provided in the forum to do a database lookup. I can not find out how to make the OK button automatically close the GUI window and continue the script. I left my attempts to accomplish in the code but comment them out. Does anyone have ideas as to how I can do this? My earlier posts have not got may responses. Is my request meeting the forum requirements for information needed? If not what else do I need to provide? Remember I am not a programmer and my not be doing this in the most efficient manor. BTW All of the MsgBox's with "ts" in the title are steps I put in the script to trouble shoot and see where I was getting information returned from. Here is the script; CODE#include <GUIConstants.au3> #include "_DBlistView.au3" #include <array.au3> Opt("GUIOnEventMode", 1); OnEvent mode Dim $title="Access db Viewer";gui title Dim $gui = GUICreate($title, 600, 600) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") ; did not resolve ok pressed then close gui window ; $ok1 = GUICtrlCreateButton ("OK", 5, 25, 45) ; GUICtrlSetOnEvent(-1, "OKPressed") ; GUISetState(@SW_SHOW) ; While 1 ; Sleep(10) ; Wend $DB = @ScriptDir & "\test.mdb" $Query= "SELECT CompanyName,CompanyAddress1,CompanyCity,CompanyState FROM CompanyName ORDER BY CompanyName Asc" $Number_of_Records_to_Display = 20 $Listview_Left = 100 $Listview_Top = 50 $Listview_Width = 600 $Listview_Height = 400 $Listview_style = $GUI_SS_DEFAULT_LISTVIEW;default is -1 $Listview_exStyle = $LVS_EX_FULLROWSELECT + $LVS_EX_GRIDLINES;default is -1 $dblv = _createDBlistView($DB,$Query,$Number_of_Records_to_Display,$Listview_Left,$Listview_Top,$Listview_Width,$Listview_Height,$Listview_style,$Listview_exStyle) $ed1 = GUICtrlCreateEdit('',$Listview_Left,$Listview_Top + $Listview_Height,$Listview_Width,100) GUISetState () $selected = -1 $lastselected = -1 GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events") While 1 Sleep(100); Idle around WEnd Local $text ,$ItText $text = GUICtrlRead($ed1);read the text in the edit $ItText = _GUICtrlListView_GetItemTextString($dblv,-1);read the items in the row double clicked ;Item text could be spilt into its parts using stringsplit $text &= $ItText;add the items string to the text GUICtrlSetData($ed1,$text & @CRLF);write the text into the edit; ;EndFunc ;==>Button_Click Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam Local $tagNMHDR, $event $tagNMHDR = DllStructCreate("int;int;int", $lParam);NMHDR (hwndFrom, idFrom, code) If @error Then Return $event = DllStructGetData($tagNMHDR, 3) Select Case $wParam = $dblv Select Case $event = $NM_CLICK ;ListView_Click();func could be written to handle this Case $event = $NM_DBLCLK ListView_DoubleClick() EndSelect EndSelect $tagNMHDR = 0 $event = 0 $lParam = 0 EndFunc Func OKPressed() MsgBox(0, "OK Pressed", "OK Pressed", 4) EndFunc Func CLOSEClicked() Exit EndFunc ;While 1 ; $msg = GUIGetMsg() ; Select ; Case $msg = $ok_button ; MsgBox(0, "GUI in UDF event", "You pressed OK!") ; Case $msg = $GUI_EVENT_CLOSE ; MsgBox(0, "GUI Event in UDF", "You clicked close!! Exiting...") ; ExitLoop ; EndSelect ; WEnd MsgBox(4096, "GUI Exited", "GUI window was exited by pessing OK button", 4) Exit Here is the UDF with my modified code. I made various attempts and left them in the code but commented out. CODE#Include <GuiListView.au3> #Include <array.au3> Dim $conn,$DB,$Query,$rs,$tableField_Names,$data Dim $dblistview,$Listview_Left,$Listview_Top,$Listview_Width,$Listview_Height Dim $ok_button,$prev_Button,$next_Button,$pageing_label,$i_StartingRecord=0,$i_OffsetRecord=0,$iStop,$iRows Dim $table Func Build_ListViewItems() ; MsgBox(0, "ts", "Build_ListViewItems Line 9", 3) ; If $dblistview Then _GUICtrlListView_DeleteAllItems ($dblistview) If $dblistview Then DeleteAllItems ($dblistview) $iRows = UBound($data, 1)-1 $iCols = UBound($data, 2)-1 If $iRows > ($i_OffsetRecord + $i_StartingRecord) Then $iStop = $i_OffsetRecord + $i_StartingRecord - 1 Else $iStop = $iRows EndIf For $iRowLoop = $i_StartingRecord to $iStop $builcols="" For $iColLoop = 0 to $iCols $builcols&=$data[$iRowLoop][$iColLoop] & "|" Next GUICtrlCreateListViewItem($builcols, $dblistview) GUICtrlSetOnEvent(-1, "") ; MsgBox(0, "ts", "guictrlsetonevent line 27", 4) ;add your on-click function here Next GUICtrlSetData($pageing_label," Viewing " & $i_OffsetRecord & " records starting at record " & $i_StartingRecord) EndFunc Func ListView_DoubleClick() ; MsgBox(0, "ts", "Begin Dblclick", 0) ;ConsoleWrite("Button_DblClick" & @LF) ;Local $itemIndex = _GUICtrlListView_GetNextItem ($dblv) Local $text ,$ItText $text = GUICtrlRead($ed1);read the text in the edit $ItText = _GUICtrlListView_GetItemTextString($dblv,-1);read the items in the row double clicked ;Item text could be spilt into its parts using stringsplit ; MsgBox(0, "ts", "text to itext line 42", 4) $text &= $ItText ;add the items string to the text ; MsgBox(0, "ts", "ed1 to text line 44", 4) GUICtrlSetData($ed1,$text & @CRLF) ;write the text into the edit; ; MsgBox(0, "ts", "array from stringsplit", 4) $ArrayinArray = StringSplit($text,'|') ; _ArrayDisplay ( $text ) $CompanyName = $ArrayInArray[1] $CompanyAddress1 = $ArrayInArray[2] $CompanyCity = $ArrayInArray[3] $CompanyState = $ArrayInArray[4] ; MsgBox( 0,"My Info", "I now have (line52) " & $CompanyName & " " & $CompanyAddress1 & @CR & @LF & $CompanyCity & " " & $CompanyState & " to set as variables", 8) EndFunc ;==>Button_Click Func next_button_clicked() ; MsgBox(0, "ts", "next clicked" , 4) if $iStop < $iRows then $i_StartingRecord=$i_StartingRecord + $i_OffsetRecord Build_ListViewItems() EndIf EndFunc Func prev_button_clicked() ; MsgBox(0, "ts", "previous btn clicked", 4) if $i_StartingRecord > 0 then $i_StartingRecord=$i_StartingRecord - $i_OffsetRecord Build_ListViewItems() EndIf EndFunc Func ok_button_clicked() ; GUISetState(@SW_HIDE) ; closes the guiwindow but script pauses and does not Continue ; MsgBox(0, "OK", "OK clicked", 4) ; msgbox runs scuuessfully when ok is clicked in main gui page ; $GUI_EVENT_CLOSE ; error cannot assign variables to constants ; $continue = "Yes" ; try to use a variable to exit gui window ; MsgBox(0, "Info", "OK was clicked and was set to " & $continue , 4) ; show feedback to user and where it was being sent from ; GUIDelete(); close gui but olny pauses script and does not continue ; GUISetState($gui, @SW_HIDE) ; does nt appear to do anything EndFunc Func cancel_buton_clicked() ; MsgBox(0, "Cancel", "You canceled the scrtip .... Goodbye!", 4) Exit EndFunc Func _createDBlistView($DB,$Query,$Records_to_Display,$Listview_Left,$Listview_Top,$Listview_Width,$Listview_Height,$Listview_style,$Listview_exStyle) ; MsgBox(0, "ts", "prequery line 69 ", 4) $data=dbselect($Query) $headers=$tableField_Names $i_OffsetRecord = $Records_to_Display If $prev_Button Then GUICtrlDelete($prev_Button) GUICtrlDelete($next_Button) GUICtrlDelete($ok_Button) EndIf GUICtrlCreateButton("OK",$Listview_Left,$Listview_Top-30,50,25) GUICtrlSetOnEvent(-1, "ok_button_clicked") GUICtrlCreateButton("<<Prev",$Listview_Left + 50,$Listview_Top-30,50,25) GUICtrlSetOnEvent(-1, "prev_button_clicked") GUICtrlCreateButton("Next>>",$Listview_Left + 101,$Listview_Top-30,50,25) GUICtrlSetOnEvent(-1, "next_button_clicked") $pageing_label=GUICtrlCreateLabel("label",$Listview_Left+155,$Listview_Top-25,300,25) If $dblistview Then DeleteAllItems($dblistview) ;_GUICtrlListView_DeleteAllItems ($dblistview) GUICtrlDelete($dblistview) EndIf $dblistview = GUICtrlCreateListView ($headers, $Listview_Left,$Listview_Top,$Listview_Width,$Listview_Height,$Listview_style,$Listview_exStyle) Build_ListViewItems() return $dblistview ; This is what you have determine was needed $GUI_EVENT_CLOSE ; MsgBox(0, "GUI Event", "line 85 CLOSE! Exiting...") EndFunc Func DeleteAllItems($dblistview) ; MsgBox(0, "ts", "deleteallitems line 93", 4) Local $ctrlID For $index = _GUICtrlListView_GetItemCount($dblistview) - 1 To 0 Step -1 $ctrlID = _GUICtrlListView_GetItemParam($dblistview, $index) If $ctrlID Then GUICtrlDelete($ctrlID) Next EndFunc Func DB_Open() ; MsgBox(0, "ts", "dbopen line 101", 4) $conn=ObjCreate("ADODB.Connection") $conn.Provider="Microsoft.Jet.OLEDB.4.0" $conn.Open($DB) $conn.CursorLocation = 3 Return $conn EndFunc Func dbselect($query) ; MsgBox(0, "ts", "dbselect line 109", 4) DB_Open() $rs = ObjCreate("ADODB.recordset") $rs.Open ($query, $conn) $tableField_Names="" For $tablefield in $rs.fields $tableField_Names &= $tablefield.name & "|" next $getRows_Data=$rs.GetRows() ; attempt to capture no records found based on query ; if @error 'Or Not IsArray($getRows_data)' then ; Msgbox(0,"Error", "No records exist with this string.", 8) ; exit ;endif $rs.close DB_Close() return $getRows_Data ;=>_createDBlistView() EndFunc Func DB_Close() ; MsgBox(0, "ts", "dbclose line 123", 4) $conn.close() EndFunc As always thaks for the assist. CC Edited February 10, 2008 by IvanCodin Link to comment Share on other sites More sharing options...
Ealric Posted February 7, 2008 Share Posted February 7, 2008 (edited) I don't have your UDF so I can't test it. Try the following code below and let me know what happens. expandcollapse popup#include <GUIConstants.au3> #include "_DBlistView.au3" #include <array.au3> Opt("GUIOnEventMode", 1); OnEvent mode Dim $title = "Access db Viewer";gui title Global $gui = GUICreate($title, 600, 600) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") ; did not resolve ok pressed then close gui window $ok1 = GUICtrlCreateButton ("OK", 5, 25, 45) GUICtrlSetOnEvent($ok1, "OKPressed") $DB = @ScriptDir & "\test.mdb" $Query = "SELECT CompanyName,CompanyAddress1,CompanyCity,CompanyState FROM CompanyName ORDER BY CompanyName Asc" $Number_of_Records_to_Display = 20 $Listview_Left = 100 $Listview_Top = 50 $Listview_Width = 600 $Listview_Height = 400 $Listview_style = $GUI_SS_DEFAULT_LISTVIEW;default is -1 $Listview_exStyle = $LVS_EX_FULLROWSELECT + $LVS_EX_GRIDLINES;default is -1 $dblv = _createDBlistView($DB, $Query, $Number_of_Records_to_Display, $Listview_Left, $Listview_Top, $Listview_Width, $Listview_Height, $Listview_style, $Listview_exStyle) $ed1 = GUICtrlCreateEdit('', $Listview_Left, $Listview_Top + $Listview_Height, $Listview_Width, 100) $selected = -1 $lastselected = -1 GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events") Local $text, $ItText $text = GUICtrlRead($ed1);read the text in the edit $ItText = _GUICtrlListView_GetItemTextString($dblv, -1);read the items in the row double clicked ;Item text could be spilt into its parts using stringsplit $text &= $ItText;add the items string to the text GUICtrlSetData($ed1, $text & @CRLF);write the text into the edit; ;EndFunc ;==>Button_Click GUISetState() While 1 Select Case $msg = $ok1 OKPressed() Case $msg = $GUI_EVENT_CLOSE MsgBox(0, "GUI Event in UDF", "You clicked close!! Exiting...") ExitLoop EndSelect WEnd GUIDelete() ; FUNCTIONS BELOW Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam Local $tagNMHDR, $event $tagNMHDR = DllStructCreate("int;int;int", $lParam);NMHDR (hwndFrom, idFrom, code) If @error Then Return $event = DllStructGetData($tagNMHDR, 3) Select Case $wParam = $dblv Select Case $event = $NM_CLICK ;ListView_Click();func could be written to handle this Case $event = $NM_DBLCLK ListView_DoubleClick() EndSelect EndSelect $tagNMHDR = 0 $event = 0 $lParam = 0 EndFunc ;==>WM_Notify_Events Func OKPressed() MsgBox(0, "OK Pressed", "OK Is Pressed.", 4) EndFunc ;==>OKPressed Func CLOSEClicked() Exit EndFunc ;==>CLOSEClicked Edited February 7, 2008 by Ealric My Projects: [topic="89413"]GoogleHack Search[/topic], [topic="67095"]Swiss File Knife GUI[/topic], [topic="69072"]Mouse Location Pointer[/topic], [topic="86040"]Standard Deviation Calculator[/topic] Link to comment Share on other sites More sharing options...
Valuater Posted February 7, 2008 Share Posted February 7, 2008 (edited) Ealric, did you even look at that code before you posted yours????? GUIGetMsg() does not work with OnEventMode 8) Edited February 7, 2008 by Valuater Link to comment Share on other sites More sharing options...
Ealric Posted February 7, 2008 Share Posted February 7, 2008 (edited) I see you supplied the UDF. Unfortunately I don't have the .mdb to test with so here's the modified part if you include your UDF. Understand I did not go through any advanced checking but you can try this one without the UDF (since it's built-in) or the one before this post with the UDF as an include. expandcollapse popup#include <GUIConstants.au3> #include <array.au3> Dim $conn, $DB, $Query, $rs, $tableField_Names, $data Dim $dblistview, $Listview_Left, $Listview_Top, $Listview_Width, $Listview_Height Dim $ok_button, $prev_Button, $next_Button, $pageing_label, $i_StartingRecord = 0, $i_OffsetRecord = 0, $iStop, $iRows Dim $table Opt("GUIOnEventMode", 1); OnEvent mode Dim $title = "Access db Viewer";gui title Global $gui = GUICreate($title, 600, 600) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") ; did not resolve ok pressed then close gui window $ok1 = GUICtrlCreateButton("OK", 5, 25, 45) GUICtrlSetOnEvent($ok1, "OKPressed") $DB = @ScriptDir & "\test.mdb" $Query = "SELECT CompanyName,CompanyAddress1,CompanyCity,CompanyState FROM CompanyName ORDER BY CompanyName Asc" $Number_of_Records_to_Display = 20 $Listview_Left = 100 $Listview_Top = 50 $Listview_Width = 600 $Listview_Height = 400 $Listview_style = $GUI_SS_DEFAULT_LISTVIEW;default is -1 $Listview_exStyle = $LVS_EX_FULLROWSELECT + $LVS_EX_GRIDLINES;default is -1 $dblv = _createDBlistView($DB, $Query, $Number_of_Records_to_Display, $Listview_Left, $Listview_Top, $Listview_Width, $Listview_Height, $Listview_style, $Listview_exStyle) $ed1 = GUICtrlCreateEdit('', $Listview_Left, $Listview_Top + $Listview_Height, $Listview_Width, 100) $selected = -1 $lastselected = -1 GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events") Local $text, $ItText $text = GUICtrlRead($ed1);read the text in the edit $ItText = _GUICtrlListView_GetItemTextString($dblv, -1);read the items in the row double clicked ;Item text could be spilt into its parts using stringsplit $text &= $ItText;add the items string to the text GUICtrlSetData($ed1, $text & @CRLF);write the text into the edit; ;EndFunc ;==>Button_Click GUISetState() While 1 Select Case $msg = $ok1 OKPressed() Case $msg = $GUI_EVENT_CLOSE MsgBox(0, "GUI Event in UDF", "You clicked close!! Exiting...") ExitLoop EndSelect WEnd GUIDelete() ; FUNCTIONS BELOW Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam Local $tagNMHDR, $event $tagNMHDR = DllStructCreate("int;int;int", $lParam);NMHDR (hwndFrom, idFrom, code) If @error Then Return $event = DllStructGetData($tagNMHDR, 3) Select Case $wParam = $dblv Select Case $event = $NM_CLICK ;ListView_Click();func could be written to handle this Case $event = $NM_DBLCLK ListView_DoubleClick() EndSelect EndSelect $tagNMHDR = 0 $event = 0 $lParam = 0 EndFunc ;==>WM_Notify_Events Func OKPressed() MsgBox(0, "OK Pressed", "OK Is Pressed.", 4) GUIDelete($gui) EndFunc ;==>OKPressed Func CLOSEClicked() Exit EndFunc ;==>CLOSEClicked Func Build_ListViewItems() ; MsgBox(0, "ts", "Build_ListViewItems Line 9", 3) ; If $dblistview Then _GUICtrlListView_DeleteAllItems ($dblistview) If $dblistview Then DeleteAllItems($dblistview) $iRows = UBound($data, 1) - 1 $iCols = UBound($data, 2) - 1 If $iRows > ($i_OffsetRecord + $i_StartingRecord) Then $iStop = $i_OffsetRecord + $i_StartingRecord - 1 Else $iStop = $iRows EndIf For $iRowLoop = $i_StartingRecord To $iStop $builcols = "" For $iColLoop = 0 To $iCols $builcols &= $data[$iRowLoop][$iColLoop] & "|" Next GUICtrlCreateListViewItem($builcols, $dblistview) GUICtrlSetOnEvent(-1, "") ; MsgBox(0, "ts", "guictrlsetonevent line 27", 4) ;add your on-click function here Next GUICtrlSetData($pageing_label, " Viewing " & $i_OffsetRecord & " records starting at record " & $i_StartingRecord) EndFunc ;==>Build_ListViewItems Func ListView_DoubleClick() ; MsgBox(0, "ts", "Begin Dblclick", 0) ;ConsoleWrite("Button_DblClick" & @LF) ;Local $itemIndex = _GUICtrlListView_GetNextItem ($dblv) Local $text, $ItText $text = GUICtrlRead($ed1);read the text in the edit $ItText = _GUICtrlListView_GetItemTextString($dblv, -1);read the items in the row double clicked ;Item text could be spilt into its parts using stringsplit ; MsgBox(0, "ts", "text to itext line 42", 4) $text &= $ItText ;add the items string to the text ; MsgBox(0, "ts", "ed1 to text line 44", 4) GUICtrlSetData($ed1, $text & @CRLF) ;write the text into the edit; ; MsgBox(0, "ts", "array from stringsplit", 4) $ArrayinArray = StringSplit($text, '|') ; _ArrayDisplay ( $text ) $CompanyName = $ArrayinArray[1] $CompanyAddress1 = $ArrayinArray[2] $CompanyCity = $ArrayinArray[3] $CompanyState = $ArrayinArray[4] ; MsgBox( 0,"My Info", "I now have (line52) " & $CompanyName & " " & $CompanyAddress1 & @CR & @LF & $CompanyCity & " " & $CompanyState & " to set as variables", 8) EndFunc ;==>ListView_DoubleClick Func next_button_clicked() ; MsgBox(0, "ts", "next clicked" , 4) If $iStop < $iRows Then $i_StartingRecord = $i_StartingRecord + $i_OffsetRecord Build_ListViewItems() EndIf EndFunc ;==>next_button_clicked Func prev_button_clicked() ; MsgBox(0, "ts", "previous btn clicked", 4) If $i_StartingRecord > 0 Then $i_StartingRecord = $i_StartingRecord - $i_OffsetRecord Build_ListViewItems() EndIf EndFunc ;==>prev_button_clicked Func cancel_buton_clicked() ; MsgBox(0, "Cancel", "You canceled the scrtip .... Goodbye!", 4) Exit EndFunc ;==>cancel_buton_clicked Func _createDBlistView($DB, $Query, $Records_to_Display, $Listview_Left, $Listview_Top, $Listview_Width, $Listview_Height, $Listview_style, $Listview_exStyle) ; MsgBox(0, "ts", "prequery line 69 ", 4) $data = dbselect($Query) $headers = $tableField_Names $i_OffsetRecord = $Records_to_Display If $prev_Button Then GUICtrlDelete($prev_Button) GUICtrlDelete($next_Button) GUICtrlDelete($ok_button) EndIf GUICtrlCreateButton("OK", $Listview_Left, $Listview_Top - 30, 50, 25) GUICtrlSetOnEvent(-1, "ok_button_clicked") GUICtrlCreateButton("<<Prev", $Listview_Left + 50, $Listview_Top - 30, 50, 25) GUICtrlSetOnEvent(-1, "prev_button_clicked") GUICtrlCreateButton("Next>>", $Listview_Left + 101, $Listview_Top - 30, 50, 25) GUICtrlSetOnEvent(-1, "next_button_clicked") $pageing_label = GUICtrlCreateLabel("label", $Listview_Left + 155, $Listview_Top - 25, 300, 25) If $dblistview Then DeleteAllItems($dblistview) ;_GUICtrlListView_DeleteAllItems ($dblistview) GUICtrlDelete($dblistview) EndIf $dblistview = GUICtrlCreateListView($headers, $Listview_Left, $Listview_Top, $Listview_Width, $Listview_Height, $Listview_style, $Listview_exStyle) Build_ListViewItems() Return $dblistview ; This is what you have determine was needed $GUI_EVENT_CLOSE ; MsgBox(0, "GUI Event", "line 85 CLOSE! Exiting...") EndFunc ;==>_createDBlistView Func DeleteAllItems($dblistview) ; MsgBox(0, "ts", "deleteallitems line 93", 4) Local $ctrlID For $index = _GUICtrlListView_GetItemCount($dblistview) - 1 To 0 Step -1 $ctrlID = _GUICtrlListView_GetItemParam($dblistview, $index) If $ctrlID Then GUICtrlDelete($ctrlID) Next EndFunc ;==>DeleteAllItems Func DB_Open() ; MsgBox(0, "ts", "dbopen line 101", 4) $conn = ObjCreate("ADODB.Connection") $conn.Provider = "Microsoft.Jet.OLEDB.4.0" $conn.Open($DB) $conn.CursorLocation = 3 Return $conn EndFunc ;==>DB_Open Func dbselect($Query) ; MsgBox(0, "ts", "dbselect line 109", 4) DB_Open() $rs = ObjCreate("ADODB.recordset") $rs.Open($Query, $conn) $tableField_Names = "" For $tablefield In $rs.fields $tableField_Names &= $tablefield.name & "|" Next $getRows_Data = $rs.GetRows() ; attempt to capture no records found based on query ; if @error 'Or Not IsArray($getRows_data)' then ; Msgbox(0,"Error", "No records exist with this string.", 8) ; exit ;endif $rs.close DB_Close() Return $getRows_Data ;=>_createDBlistView() EndFunc ;==>dbselect Func DB_Close() ; MsgBox(0, "ts", "dbclose line 123", 4) $conn.close() EndFunc ;==>DB_Close Edited February 7, 2008 by Ealric My Projects: [topic="89413"]GoogleHack Search[/topic], [topic="67095"]Swiss File Knife GUI[/topic], [topic="69072"]Mouse Location Pointer[/topic], [topic="86040"]Standard Deviation Calculator[/topic] Link to comment Share on other sites More sharing options...
Ealric Posted February 7, 2008 Share Posted February 7, 2008 (edited) Ealric, did you even look at that code before you posted yours?????GUIGetMsg() does not work with OnEventMode8)Ah I didn't see that. And, I can't test with it because I don't have an .mdb to test with. If he supplied me with one, I'd work it out for him. Ignore the GUIGetMsg() part. My apologies mate. This is what happens when you SKIM READ something quickly. Edited February 7, 2008 by Ealric My Projects: [topic="89413"]GoogleHack Search[/topic], [topic="67095"]Swiss File Knife GUI[/topic], [topic="69072"]Mouse Location Pointer[/topic], [topic="86040"]Standard Deviation Calculator[/topic] Link to comment Share on other sites More sharing options...
Valuater Posted February 7, 2008 Share Posted February 7, 2008 This works I have trimmed out you UDF expandcollapse popup#include <GUIConstants.au3> ;#include "_DBlistView.au3" #include <array.au3> Opt("GUIOnEventMode", 1); OnEvent mode Dim $title = "Access db Viewer" ;gui title Dim $gui = GUICreate($title, 600, 600) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") ; did not resolve ok pressed then close gui window $ok1 = GUICtrlCreateButton ("OK", 5, 25, 45) GUICtrlSetOnEvent(-1, "OKPressed") ; GUISetState(@SW_SHOW) ; While 1 ; Sleep(10) ; Wend $DB = @ScriptDir & "\test.mdb" $Query = "SELECT CompanyName,CompanyAddress1,CompanyCity,CompanyState FROM CompanyName ORDER BY CompanyName Asc" $Number_of_Records_to_Display = 20 $Listview_Left = 100 $Listview_Top = 50 $Listview_Width = 600 $Listview_Height = 400 $Listview_style = $GUI_SS_DEFAULT_LISTVIEW;default is -1 $Listview_exStyle = $LVS_EX_FULLROWSELECT + $LVS_EX_GRIDLINES;default is -1 $dblv = "123" ;_createDBlistView ($DB, $Query, $Number_of_Records_to_Display, $Listview_Left, $Listview_Top, $Listview_Width, $Listview_Height, $Listview_style, $Listview_exStyle) $ed1 = GUICtrlCreateEdit('', $Listview_Left, $Listview_Top + $Listview_Height, $Listview_Width, 100) GUISetState() $selected = -1 $lastselected = -1 GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events") While 1 Sleep(100); Idle around WEnd Local $text, $ItText $text = GUICtrlRead($ed1);read the text in the edit ;$ItText = _GUICtrlListView_GetItemTextString ($dblv, -1);read the items in the row double clicked ;Item text could be spilt into its parts using stringsplit $text &= $ItText;add the items string to the text GUICtrlSetData($ed1, $text & @CRLF);write the text into the edit; ;EndFunc ;==>Button_Click Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam Local $tagNMHDR, $event $tagNMHDR = DllStructCreate("int;int;int", $lParam);NMHDR (hwndFrom, idFrom, code) If @error Then Return $event = DllStructGetData($tagNMHDR, 3) Select Case $wParam = $dblv Select Case $event = $NM_CLICK ;ListView_Click();func could be written to handle this Case $event = $NM_DBLCLK ;ListView_DoubleClick () EndSelect EndSelect $tagNMHDR = 0 $event = 0 $lParam = 0 EndFunc ;==>WM_Notify_Events Func OKPressed() MsgBox(0, "OK Pressed", "OK Pressed", 4) EndFunc ;==>OKPressed Func CLOSEClicked() Exit EndFunc ;==>CLOSEClicked ;While 1 ; $msg = GUIGetMsg() ; Select ; Case $msg = $ok_button ; MsgBox(0, "GUI in UDF event", "You pressed OK!") ; Case $msg = $GUI_EVENT_CLOSE ; MsgBox(0, "GUI Event in UDF", "You clicked close!! Exiting...") ; ExitLoop ; EndSelect ; WEnd MsgBox(4096, "GUI Exited", "GUI window was exited by pessing OK button", 4) Exit 8) Link to comment Share on other sites More sharing options...
IvanCodin Posted February 7, 2008 Author Share Posted February 7, 2008 Here is a copy of the database. Rename it to test.mdb. I could not uload a mdb file directly. Valuater, Thanks for the feedback. When I run your modified all I see is the gui window. If I click OK I doesn't close the window and continue. I uncommented the dblistview and ran it that way also. Still not luck. What I am trying to do is kinda like this: CODE#include <GUIConstants.au3> Msgbox(0, "Info", "this is the program begining", 4) GUICreate("Hello World", 200, 100) GUICtrlCreateLabel("Hello world! How are you?", 30, 10) $okbutton = GUICtrlCreateButton("OK", 70, 50, 60) $doitbutton = GUICtrlCreateButton("SSH", 100, 140,160) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $okbutton MsgBox(0, "GUI Event", "You pressed OK!") ExitLoop Case $msg = $GUI_EVENT_CLOSE MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...") ExitLoop Case $msg = $doitbutton ssh() EndSelect WEnd Msgbox(0, "Info", "this is the program continuning", 4) $value = InputBox("Testing", "Enter the 1 or 2 character code.", "", " M2") MsgBox(0, "info", "You typed " & $value, 4) Func ssh() MsgBox(0, "ssh", " This is a button function", 5) EndFunc Hope this make it clear. Thanks CC Link to comment Share on other sites More sharing options...
IvanCodin Posted February 8, 2008 Author Share Posted February 8, 2008 Bump ... CC Link to comment Share on other sites More sharing options...
IvanCodin Posted February 10, 2008 Author Share Posted February 10, 2008 Bump ... Anyone?? CC Link to comment Share on other sites More sharing options...
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