Hi,
ich komme momentan nicht weiter! Ich möchte den Fokus nach einer Auswahl aus der Combo Box auf das Set Button setzen, da sonst die Farbe, die man in der Combo Box ausgewählt hat, durch den Fokus auf der Combo Box falsch dargestellt wird, z.B. das hell gelbe wird grün dargestellt, wenn der Fokus auf der Combo Box ist.
Spoiler anzeigen
#include <Array.au3>
#include <ComboConstants.au3>
#include <Constants.au3>
#include <EditConstants.au3>
#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <Misc.au3>
#include <SliderConstants.au3>
#include <StructureConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
Global $hGUI = GUICreate("")
GUISetState()
Global $load_auto = ""
Global $load_auto, $GUI_Bg_Color = 0xB9D1EA, $ping_to = 500
Global Const $ini_file = @ScriptDir & "\Check Online Status.ini"
Global $hComboColor, $hGUI_Settings, $hProc, $hHook
Settings()
Exit
[/autoit] [autoit][/autoit] [autoit]Func Settings()
GUISetState(@SW_DISABLE, $hGUI)
$hGUI_Settings = GUICreate("Settings", 612, 229, -1, -1, $GUI_SS_DEFAULT_GUI, Default, $hGUI)
Local Const $iAutoLoadFile = GUICtrlCreateInput($load_auto, 152, 16, 369, 22)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
Local Const $lLoadAuto = GUICtrlCreateLabel("Load List Automatically", 8, 18, 140, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
GUICtrlSetTip(-1, "Select a file which will be loaded to the program automatically")
Local Const $bBrowse = GUICtrlCreateButton("&Browse", 528, 14, 75, 25)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
Local Const $lBgColor = GUICtrlCreateLabel("Change GUI background color", 6, 58, 177, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
;~ Local Const $lBgColorAdd = GUICtrlCreateLabel("Add new color", 6, 97, 97, 20)
;~ GUICtrlSetFont(-1, 10, 400, 0, "Arial")
;~ Local Const $bAddColor = GUICtrlCreateButton("Add &Color", 105, 94, 75, 25)
;~ GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$hComboColor = _GUICtrlComboBoxEx_Create($hGUI_Settings, "", 192, 56, 329, 200, BitOR($CBS_DROPDOWNLIST, $CBS_DISABLENOSCROLL))
;~ $hComboColor = GUICtrlCreateCombo("", 192, 56, 329, 200, BitOR($CBS_DROPDOWNLIST, $CBS_DISABLENOSCROLL))
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hComboColor = ' & $hComboColor & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
GUICtrlSetData(-1, "item2|item3", "item3")
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
Local Const $bSet = GUICtrlCreateButton("&Set", 528, 55, 75, 64)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
Local Const $bApply = GUICtrlCreateButton("&Apply", 528, 180, 75, 40)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
Local Const $bExit_Setting = GUICtrlCreateButton("E&xit", 438, 180, 75, 40)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
Local Const $cSlider = GUICtrlCreateSlider(88, 138, 440, 30, BitOR($TBS_BOTH,$TBS_NOTICKS, $TBS_ENABLESELRANGE, $TBS_FIXEDLENGTH, $WS_TABSTOP))
GUICtrlSetLimit(-1, 5000, 100)
GUICtrlSetData(-1, 500)
GUICtrlSetCursor (-1, 0)
Local Const $lSlider = GUICtrlCreateLabel("Ping Timeout", 8, 141, 80, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
GUICtrlSetTip(-1, "Default is 500 ms")
Local Const $iPing = GUICtrlCreateInput($ping_to, 528, 140, 74, 21, BitOR($ES_CENTER, $ES_NUMBER))
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
GUISetState(@SW_SHOW, $hGUI_Settings)
ControlFocus($hGUI_Settings, "", $bExit_Setting)
GUISetIcon(@SystemDir & "\Shell32.dll", 14, $hGUI_Settings)
Local $nMsg, $i, $file, $cindex, $em, $p, $newcolor
Local $aColors[7] = [0xB9D1EA, 0xC0DCC0, 0xD7E4F2, 0xFFFFE1, 0xA6CAF0, 0xFFFBF0, 0xFECFF4]
[/autoit] [autoit][/autoit] [autoit]Local Const $hImage = _GUIImageList_Create(256, 56, 5, 3)
For $i = 0 To 6
_GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hComboColor, $aColors[$i], 256, 56))
Next
_GUICtrlComboBoxEx_SetImageList($hComboColor, $hImage)
_GUICtrlComboBoxEx_BeginUpdate($hComboColor)
For $i = 0 To 6
_GUICtrlComboBoxEx_AddString($hComboColor, "Color " & $i + 1, $i, $i)
Next
_GUICtrlComboBoxEx_EndUpdate($hComboColor)
$cindex = _ArraySearch($aColors, $GUI_Bg_Color)
If Not @error Then
_GUICtrlComboBoxEx_SetCurSel($hComboColor, $cindex)
Else
_GUICtrlComboBoxEx_SetCurSel($hComboColor, 0)
EndIf
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
[/autoit] [autoit][/autoit] [autoit]While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE, $bExit_Setting
GUISetState(@SW_ENABLE, $hGUI)
GUIDelete($hGUI_Settings)
Return 1
Case $cSlider
GUICtrlSetData($iPing, GUICtrlRead($cSlider))
Case $iPing
$p = GUICtrlRead($iPing)
If $p > 5000 Then
$p = 500
ElseIf $p < 100 Then
$p = 100
EndIf
GUICtrlSetData($cSlider, $p)
Case $bBrowse
$file = FileOpenDialog("File Selection", "", "Text Files (*.txt;*.csv)")
If Not @error Then GUICtrlSetData($iAutoLoadFile, $file)
Case $bSet
$GUI_Bg_Color = "0x" & Hex($aColors[_GUICtrlComboBoxEx_GetCurSel($hComboColor)], 6)
GUISetBkColor($GUI_Bg_Color, $hGUI)
Case $bApply
$GUI_Bg_Color = "0x" & Hex($aColors[_GUICtrlComboBoxEx_GetCurSel($hComboColor)], 6)
GUISetBkColor($GUI_Bg_Color, $hGUI)
IniWrite($ini_file, "Bg-Color", "Color", "0x" & Hex($aColors[_GUICtrlComboBoxEx_GetCurSel($hComboColor)], 6))
$em = @error
IniWrite($ini_file, "Auto-Load", "Load", GUICtrlRead($iAutoLoadFile))
$em = @error
IniWrite($ini_file, "Ping-Timeout", "Ping", GUICtrlRead($iPing))
$em = @error
If $em Then
MsgBox(16, "Error", "Unable to save one or more settings to ini file!", 10)
Else
MsgBox(64, "Information", "Settings were save to " & $ini_file & " successfully", 10)
EndIf
;~ Case $bAddColor
;~ $newcolor = _ChooseColor(2, 0, 2, $hGUI_Settings)
;~ If Not @error Then
;~ ConsoleWrite($newcolor & @CRLF)
;~ EndIf
EndSwitch
WEnd
EndFunc
Func WM_NOTIFY($hWnd, $iMsg, $wParam, $iParam)
;~ ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $wParam = ' & $iParam & "/" & Hex(BitAND($iParam, $hComboColor)) & "," & $hComboColor & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR
$tNMHDR = DllStructCreate($tagNMHDR, $iParam)
$hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
;~ ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hWndFrom = ' & $hWndFrom & "/" & $hComboColor & "/" & $hGUI_Settings & "," & $hGUI & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hComboColor
Switch $iCode
Case $CBEN_ENDEDITA, $CBEN_ENDEDITW ; Sent when the user has concluded an operation within the edit box or has selected an item from the control's drop-down list.
ConsoleWrite("huhu")
Return False ; accept the notification and allow the control to display the selected item
Case Else
;~ ConsoleWrite(Hex($iCode) & "/ " & Hex($CBEN_ENDEDITA) & "," & Hex($CBEN_ENDEDITW) & @CRLF)
EndSwitch
EndSwitch
Return "GUI_RUNDEFMSG"
EndFunc ;==>WM_NOTIFY
BugFix hat mir einige Beispiele geschickt, um das Ganze mit DllCallbackRegisters (Hooking) zu lösen, nur sehe ich nicht den Vorteil gegenüber der "normalen" Variante mit GUIRegisterMsg(), was doch auch eigentlich ein DllCallbackRegister ist, oder? Abgesehen davon, habe ich auch keinen Erfolg mit DCR!
Danke und Gruß,
UEZ