ComboBox - hwndCombo anhand hwndEdit ermitteln

Stelle Fragen zur Programmierung mit Autohotkey

Moderator: jNizM

User avatar
Holle
Posts: 187
Joined: 01 Oct 2013, 23:19

ComboBox - hwndCombo anhand hwndEdit ermitteln

08 Oct 2013, 10:31

Dank "just me" weiß ich nun dass eine Combobox mehr als nur eine HWND besitzt.

Nun ist es mit seinem Script möglich mit der hwnd der Combobox die einzelenen hwnds (Editbox, DropDownList) zu ermitteln, doch geht das auch andersrum?
Hier ist "just me´s" Script:

Code: Select all

GetComboBoxInfo(hCtrl, ByRef hCombo, ByRef hItem, ByRef hList) {
   Static cbCBI := 40 + (A_PtrSize * 3)
   hCombo := hItem := hList := hCtrl
   VarSetCapacity(CBI, cbCBI, 0)
   NumPut(cbCBI, CBI, 0, "UInt")
   If DllCall("User32.dll\GetComboBoxInfo", "Ptr", hCtrl, "Ptr", &CBI) {
      hCombo := Numget(CBI, 40 + (A_PtrSize * 0), "UPtr")
      hItem  := NumGet(CBI, 40 + (A_PtrSize * 1), "UPtr")
      hList  := Numget(CBI, 40 + (A_PtrSize * 2), "UPtr")
      hCtrl += 0
      Return True
   }
   Return False
}
Nun habe ich jedoch das Problem dass ich die hwnd der EditBox habe und die Hwnd der Combobox benötige.
Leider blicke ich nicht ausreichend durch, um das Script selber umzustellen :oops: .

Kann mir da jemand helfen?
Vielen Dank.
just me
Posts: 9509
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: ComboBox - hwndCombo anhand hwndEdit ermitteln

12 Oct 2013, 03:33

Hallo,

mir kommt da ein globales Array für die HWNDs in den Sinn. Darin wird als Key das HWND des jeweiligen Controls und als Value das HWND der ComboBox abgelegt. Wenn Du dann das HWND des Edits hast, kannst Du per Array[HwndEdit] auf das HWND der zugehörigen ComboBox zugreifen.

Code: Select all

Global HwndArray := []
Gui, Margin, 20, 20
Gui, Add, ComboBox, hwndHCBB w400 h300
HCBB += 0
GetComboBoxInfo(HCBB, HCombo, HEDIT, HLIST)
GuiControl, , %HCBB%, |HCBB: %HCBB%||HCOMBO: %HCOMBO%|HEDIT: %HEDIT%|HLIST: %HLIST%
HwndArray[HCBB] := HCBB
HwndArray[HEDIT] := HCBB
HwndArray[HLIST] := HCBB
Gui, Add, Button, gEditParent w100, Edit's parent
Gui, Add, Button, gListParent x320 yp wp, List's parent
Gui, Show, , GetParent()
Return

GuiClose:
ExitApp
EditParent:
   MsgBox, % HwndArray[HEDIT]
Return
ListParent:
   MsgBox, % HwndArray[HLIST]
Return

GetComboBoxInfo(hCtrl, ByRef hCombo, ByRef hItem, ByRef hList) {
   Static cbCBI := 40 + (A_PtrSize * 3)
   hCombo := hItem := hList := hCtrl
   VarSetCapacity(CBI, cbCBI, 0)
   NumPut(cbCBI, CBI, 0, "UInt")
   If DllCall("User32.dll\GetComboBoxInfo", "Ptr", hCtrl, "Ptr", &CBI) {
      hCombo := Numget(CBI, 40 + (A_PtrSize * 0), "UPtr")
      hItem  := NumGet(CBI, 40 + (A_PtrSize * 1), "UPtr")
      hList  := Numget(CBI, 40 + (A_PtrSize * 2), "UPtr")
      Return True
   }
   Return False
}

Return to “Ich brauche Hilfe”

Who is online

Users browsing this forum: No registered users and 20 guests