Ich habe versucht in mein Programm IntelliSense von BugFix einzufügen.
Meine Probleme:
Die Listbox erscheint zwar, aber 1. an einer völlig falschen Stelle. 2. Kann ich die gefundenen Länder nicht anwählen 3. geht die Listbox nicht mehr weg wenn sie einmal offen ist.
Im Grunde ist es nur dieser Teil der Probleme macht:
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
_ChooseBox()
Case Guigetmsg() = $Gui_Event_Close
Case $GUI_EVENT_CLOSE
Exit
Danke für eure Hilfe
Spoiler anzeigen
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include<GUIConstantsEx.au3>
#include<ListBoxConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListBox.au3>
#Include <WinAPI.au3>
#include <Misc.au3>
Opt("GUICloseOnESC", 0)
#Region ### START Koda GUI section ### Form=
[/autoit] [autoit][/autoit] [autoit];$guiBox = GUICreate('', 8, 40, 201, 21, BitOR($WS_SIZEBOX, $WS_POPUP), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
;######################################################
; NEU!
Global $show = False
Global $indexB = -1
Global $SenseGui, $SenseCtrl, $guiBox, $box
Global $POSSenseGui[2]
Global $aData[34] = ["Österreich","Australien","Belgien","Bosnien","Brasilien","Kanada","Schweiz","Tschechien","Deutschland","Dänemark","Spanien","Frankreich","Großbritannien","Griechenland","Ungarn","Kroatien","Italien","Irland","Mexico","Malta","Malaysia","Norwegen","Nigeria","Niederlande","Polen","Russland","Schweden","Slowakei","Slowenien","Türkei","England","Amerika","Venezuela","Südafrika"]
$guiBox = GUICreate('', 180, 100, 300, 100, BitOR($WS_SIZEBOX, $WS_POPUP), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
$box = _GUICtrlListBox_Create($guiBox, '', 0, 0, 150, 86, BitOR($LBS_SORT, 0x00B00002))
; ListBox muß 1 Pixel höher als GUI sein - sonst fehlerhafte Darstellung
For $i = 0 To UBound($aData) -1 ; falls Daten mit _FileReadToArray gelesen werden: StartIndex=1
_GUICtrlListBox_AddString($box, $aData[$i])
Next
#EndRegion Box
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
GUIRegisterMsg($WM_MOVE, "_WM_MOVE")
GUIRegisterMsg(0x231, "_WM_ENTERSIZEMOVE")
#EndRegion - Deklarationen Sense
#Region Main
$Form1 = GUICreate("Tarifsuchmaschine", 506, 125, 2608, 362)
$SenseGui = $Form1 ; <== Für Allgemeingültigkeit Zuweisung an $SenseGui
$name = GUICtrlCreateInput("Bitte Land eingeben...", 8, 40, 201, 21)
$button1 = GUICtrlCreateButton("Such!", 8, 64, 201, 33)
$label1 = GUICtrlCreateLabel("Bitte Land eingeben", 8, 16, 204, 17)
$label2 = GUICtrlCreateLabel("", 232, 32, 164, 89)
$Pic1 = GUICtrlCreatePic("", 400, 8, 73, 57)
$us = GUICtrlCreateLabel("Deine Suche: ", 232, 8, 164, 17)
$SenseCtrl = $name ; <== Für Allgemeingültigkeit Zuweisung an $SenseCtrl
$hInput = GUICtrlGetHandle($name)
$box = _GUICtrlListBox_Create($guiBox, '', 0, 0, 150, 86, BitOR($LBS_SORT, 0x00B00002))
; ListBox muß 1 Pixel höher als GUI sein - sonst fehlerhafte Darstellung
For $i = 0 To UBound($aData) -1 ; falls Daten mit _FileReadToArray gelesen werden: StartIndex=1
_GUICtrlListBox_AddString($box, $aData[$i])
Next
GUISetState()
#EndRegion Main
#region - SenseFuncs
Func _ChooseBox()
If Not $show Or ControlGetText($SenseGui, '', $SenseCtrl) = "" Then
GUISetState(@SW_HIDE, $guiBox)
$show = False
Return
EndIf
If _IsPressed('0D') Then ; ENTER
If _GUICtrlListBox_GetText($box, $indexB) <> 0 Then
ControlSetText($SenseGui, '', $SenseCtrl, _GUICtrlListBox_GetText($box, $indexB))
EndIf
GUISetState(@SW_HIDE, $guiBox)
$show = False
ElseIf _IsPressed('1B') Then ; ESC
GUISetState(@SW_HIDE, $guiBox)
$show = False
ElseIf _IsPressed('26') Then ; UP
If $indexB > 0 Then
$indexB -= 1
_GUICtrlListBox_SetCurSel($box, $indexB)
Sleep(90)
EndIf
ElseIf _IsPressed('28') Then ; DOWN
If $indexB < _GUICtrlListBox_GetCount($box)-1 Then
$indexB += 1
_GUICtrlListBox_SetCurSel($box, $indexB)
Sleep(90)
EndIf
EndIf
EndFunc
Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
Local $nNotifyCode = BitShift($wParam, 16)
Local $hCtrl = $lParam
Local $hSenseCtrl = $SenseCtrl
If Not IsHWnd($hSenseCtrl) Then $hSenseCtrl = GUICtrlGetHandle($hSenseCtrl)
If ($nNotifyCode = 1024 Or $nNotifyCode = 6) And $hCtrl = $hSenseCtrl Then
Local $str = ControlGetText($SenseGui, '', $SenseCtrl)
$indexB = _GUICtrlListBox_FindString($box, $str)
_GUICtrlListBox_SetCurSel($box, $indexB)
$caret = _CaretPos()
If Not @error And Not $show Then
If $caret[3] + $caret[4] - 95 < 0 Then ; Platz für Liste über dem Ctrl ausreichend?
WinMove($guiBox, '', $caret[0], $caret[1] +25) ; Versatz 25 (Ctrlhöhe+5) unter y vom Ctrl
Else
WinMove($guiBox, '', $caret[0], $caret[1] -95) ; Versatz 95 (Boxhöhe+10) über y vom Ctrl
EndIf
GUISetState(@SW_SHOWNOACTIVATE, $guiBox)
$show = True
EndIf
ElseIf $hCtrl = $box And $nNotifyCode = 1 Then
$indexB = _GUICtrlListBox_GetCurSel($box)
ControlSetText($SenseGui, '', $SenseCtrl, _GUICtrlListBox_GetText($box, $indexB))
GUISetState(@SW_HIDE, $guiBox)
$show = False
ElseIf $show And $nNotifyCode = 512 And $hCtrl = $lParam And Not $hCtrl = $box Then
GUISetState(@SW_HIDE,$guiBox)
$show = False
EndIf
Return $GUI_RUNDEFMSG
EndFunc
Func _WM_ENTERSIZEMOVE($hWnd)
If $hWnd = $SenseGui Then $POSSenseGui = WinGetPos($SenseGui)
EndFunc
Func _WM_MOVE($hWnd)
If $hWnd = $SenseGui Then
Local $pos = WinGetPos($guiBox)
Local $postemp = WinGetPos($SenseGui)
WinMove($guiBox,"",$pos[0]-($POSSenseGui[0]-$postemp[0]),$pos[1]-($POSSenseGui[1]-$postemp[1]))
$POSSenseGui = WinGetPos($SenseGui)
EndIf
EndFunc
Func _CaretPos()
Local $old = Opt("CaretCoordMode", 0) ;relative mode
Local $c = WinGetCaretPos() ;relative caret coords
Local $w = WinGetPos("") ;window's coords
Local $f = ControlGetFocus("","") ;text region "handle"
Local $e = ControlGetPos("", "", $f) ;text region coords
Local $h = ControlGetHandle("", "", $f) ;Ctrl-Handle
Local $t[5]
If IsArray($c) and IsArray($w) and IsArray($e) Then
If _WinAPI_IsClassName($SenseCtrl, 'Edit') Then ; Input wird als Edit-Class erkannt
$t[0] = $c[0] + $w[0] + $e[0]
ElseIf _WinAPI_IsClassName($SenseCtrl, 'ComboBox') Then
$t[0] = $w[0] + $e[0]
EndIf
$t[1] = $c[1] + $w[1] + $e[1]
$t[2] = $h
$t[3] = $w[1]
$t[4] = $e[1]
Opt("CaretCoordMode", $old)
Return $t ;absolute screen coords of caret cursor
Else
Opt("CaretCoordMode", $old)
SetError(1)
EndIf
EndFunc
#endregion - SenseFuncs
;######################################################
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$var1="0"
$Internet="0"
$aufbau="0"
$an="0"
$ab="0"
$inet="0"
$sms = "0"
$zahl = "0"
$land= "0"
;While True
;$nMsg = GUIGetMsg()
; Switch $nMsg
; Case $GUI_EVENT_CLOSE
; _ChooseBox()
;If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
_ChooseBox()
Case Guigetmsg() = $Gui_Event_Close
Case $GUI_EVENT_CLOSE
Exit
;While True
;_ChooseBox()
;If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
;WEnd
;While 1
; $nMsg = GUIGetMsg()
; Switch $nMsg
; Case $GUI_EVENT_CLOSE
;Exit
Case $button1
consolewrite($name)
_lauf()
_bilder()
EndSwitch
WEnd
Func _lauf()
_abkurz()
If $zahl = "0" Then
$zahl = IniRead("list.ini", "liste", GUICtrlRead($name),"false")
$land = GuiCtrlRead($name)
_suchen()
_suchen2()
If IniRead("list.ini", "internet", GUICtrlRead($name),"false") = "False" Then
consolewrite(" Failed!")
_ausgabe2()
Elseif 1 then
_ausgabe()
Endif
Else
_suchen3()
_suchen4()
If IniRead("list.ini", "liste", $zahl,"false") = "False" Then
consolewrite(" Failed!")
_ausgabe2()
Elseif 1 then
_ausgabe()
Endif
EndIf
EndFunc
Func _suchen()
$aufbau = IniRead("list.ini","tarif"&$zahl,"aufbau","fehlt")
$an = IniRead("list.ini","tarif"&$zahl,"an","fehlt")
$ab = IniRead("list.ini","tarif"&$zahl,"ab","fehlt")
$sms = IniRead("list.ini","tarif"&$zahl,"sms","fehlt")
consolewrite("suchen1 tarif"&$zahl&" ")
EndFunc
Func _suchen2()
$zahl = IniRead("list.ini", "internet", GUICtrlRead($name),"false")
$inet = IniRead("list.ini","inettar"&$zahl,"kosten","fehlt")
consolewrite("suchen2 inettar"&$zahl&" ")
endfunc
Func _suchen3()
$tar2 = IniRead("list.ini","liste",$zahl,"fehlt")
$aufbau = IniRead("list.ini","tarif"&$tar2,"aufbau","fehlt")
$an = IniRead("list.ini","tarif"&$tar2,"an","fehlt")
$ab = IniRead("list.ini","tarif"&$tar2,"ab","fehlt")
$sms = IniRead("list.ini","tarif"&$tar2,"sms","fehlt")
consolewrite("suchen3 tarif"&$tar2&" ")
EndFunc
Func _suchen4()
$tar = IniRead("list.ini","internet",$zahl,"fehlt")
$land = $zahl
$inet = IniRead("list.ini","inettar"&$tar,"kosten","fehlt")
consolewrite("suchen4 inettar"&$tar&" ")
endfunc
func _bilder()
GUICtrlSetImage($pic1,"")
GUICtrlSetImage($pic1,@WorkingDir&"\"&$land&".gif")
EndFunc
Func _abkurz()
If IniRead("list.ini", "abkurz", GUICtrlRead($name),"false") <> "false" Then
$zahl = iniRead("list.ini","abkurz", GUICtrlRead($name),"false")
Else
$zahl = "0"
Endif
EndFunc
Func _ausgabe()
GuiCtrlSetData($label2,"Fixkosten:" & @TAB &$aufbau & "€" & @CRLF & "Ankommend:" &@TAB& $an & "€ / Minute" & @CRLF & "Abgehend:" &@TAB& $ab& "€ / Minute" & @CRLF& "SMS:" & @TAB &@TAB& $sms & "€"& @CRLF & "Daten:"&@TAB&@TAB& $inet & "€ /50kb")
GuiCtrlSetData($us,"Deine Suche: "&$land)
Consolewrite(" Deine Suche:"&$land)
endfunc
Func _ausgabe2()
GuiCtrlSetData($label2,"Land nicht gefunden!"& @CRLF & "Bitte Eingabe überprüfen")
EndFunc