Problem mit ControlCommand

12/02/2011 15:33 Whoknowsit#1
Moin,

es ist zum Haare raufen... Ich habe eine simple ComboBox und möchte, sobald etwas in der ComboBox ausgewählt wird, mit der Auswahl weiterarbeiten. Das funktioniert auch soweit.

Jetzt möchte ich jedoch mittels ControlCommand etwas spezielles extrahieren und stelle mich dabei etwas blöde an...

Code:
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

; GUI start
$Form1 = GUICreate("Form1", 160, 55, -1, -1)
$Combo1 = GUICtrlCreateCombo(" ", 8, 16, 145, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE))
GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
; GUI ende

; PID-Liste start
$List = ProcessList()
For $i = 1 To $List[0][0]
	GUICtrlSetData($Combo1, 'PID: ' & $List[$i][1])
Next
; PID-Liste ende

; Bla....
While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit

	EndSwitch
WEnd

; WM-Command
Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
	Local $nNotifyCode = BitShift($wParam, 16)
	Local $nID = BitAND($wParam, 0xFFFF)
	Local $hCtrl = $lParam

	Switch $nID
		Case $Combo1
			Switch $nNotifyCode
				Case $CBN_SELCHANGE
					MsgBox(0, 0, $List[ControlCommand(" ", "PID: ", $nID, "FindString", GUICtrlRead($nID)) + 1][1])
			EndSwitch
	EndSwitch

	Return $GUI_RUNDEFMSG
EndFunc   ;==>MY_WM_COMMAND
Wie kriege ich aus der Auswahl die PID?! Der Mist beschäftigt mich unnötigerweise schon seit Wochen.
12/02/2011 16:17 lolkop#2
warum nicht mit standard autoit funktionen arbeiten?
Code:
GUICreate("Form1", 160, 55, -1, -1)
$Combo = GUICtrlCreateCombo(" ", 8, 16, 145, 25, 0x200043)
GUISetState(@SW_SHOW)

$List = ProcessList()
for $i = 1 to $List[0][0]
  GUICtrlSetData($Combo, 'PID: ' & $List[$i][1])
next

While 1
	Switch GUIGetMsg()
		Case -3
			Exit
		Case $Combo
			MsgBox(0, 'blubb', GUICtrlRead($Combo))
	EndSwitch
WEnd
12/02/2011 16:23 Whoknowsit#3
Geht weniger um den Inhalt der ComboBox als um die Tatsache, dass ich von der Auswahl nur die PID und nicht das "Drumrum" brauche. Ich dachte, mit ControlCommand wäre ich da ganz gut bedient.
12/02/2011 16:39 lolkop#4
auch da gibts wieder 2 einfache möglichkeiten^^

beim durchlaufen der prozessliste alles in einem array speichern, und später so auf die pid kommen, oder einfach per stringoperationen^^
12/02/2011 17:15 Whoknowsit#5
Quote:
stringoperationen
Was schlägst du vor? _StringBetween? Alles in Allem sollte das Ganze selbstverständlich performant bleiben.
12/02/2011 17:45 lolkop#6
naja steht ja immer das gleiche da recihts doch die ersten par zeichn zu entfernen...

Code:
GUICreate("Form1", 160, 55, -1, -1)
$Combo = GUICtrlCreateCombo(" ", 8, 16, 145, 25, 0x200043)
GUISetState(@SW_SHOW)

$List = ProcessList()
for $i = 1 to $List[0][0]
  GUICtrlSetData($Combo, 'PID: ' & $List[$i][1])
next

While 1
	Switch GUIGetMsg()
		Case -3
			Exit
		Case $Combo
			MsgBox(0, 'blubb', StringTrimLeft(GUICtrlRead($Combo),5))
	EndSwitch
WEnd
12/02/2011 18:17 Whoknowsit#7
Wasn heute los mit mir?! Danke ^^