Einzelnen Beitrag anzeigen

Amateurprofi

Registriert seit: 17. Nov 2005
Ort: Hamburg
1.041 Beiträge
 
Delphi XE2 Professional
 
#7

AW: TComboBox - MouseMove

  Alt 11. Aug 2018, 17:02
Ja mit den Mouse Events würde ich halt über das Hint-Event gehen, darüber kannst Du Dir ausrechnen lassen wo die Maus gerade steckt, ich habe in Post #1 nicht so ganz verstanden worauf Du da genau aus bist, das Hint-Ereignis ermöglicht Dir halt ein Item aus der ComboBox nur anhand der Mausposition zu bestimmen.
Hallo KodeZwerg,
ich habe mir angeschaut, was unter den Links, die Du netterweise zur Verfügung gestellt hast, zu lesen ist.
Wenn ich das richtig verstehe, dann funktioniert Dein Vorschlag über das Hint-Event zu gehen, in meinem Fall nicht (Style ist csOwnerDrawFixed, nicht csSimple).

Zitat:
If the TComboBox.Style property is not set to csSimple, the ListBox is only visible when it is dropped down.
The OnShowHint/CM_HINTSHOW trick will not work in this situation.
However, you can use the TComboBox.OnDropDown event to manually subclass the ListBox directly (and the OnCloseUp event to remove the subclass), using SetWindowLongPtr() or SetWindowSubclass().
That will allow you to intercept WM_MOUSEMOVE messages that are sent directly to the ListBox, and then you can send LB_ITEMFROMPOINT to the ListBox with the provided mouse coordinates.
However, to actually display a hint, it is not enough to just set the TComboBox.Hint property in this Situation (it won't be displayed, as the dropped-down list is basically acting as a modal window and is blocking the normal hint mechanism).
You will have to display your own hint window manually, such as by using the THintWindow class directly.
Was mir vielversprechend erscheint, ist der in obigem Text erwähnte Hinweis auf TComboBox.OnDropDown / SetWindowSubclass() / OnCloseUp / (RemoveWindowSubclass()).
Problem ist, dass ich nicht einmal ansatzweise verstehe, wie ich das realisieren kann.
Kannst Du mir kurz skizzieren wie ich das machen kann.
Was ich mir vorstelle ist:
Wenn die Liste aufgeklappt ist, und die Maus in der List bewegt wird, wird ein MouseMove ausgelöst und eine "eigene" MouseMove Methode ausgerufen, in der ich die die Position der Maus auswerten kann.
Vielen Dank.
Gruß, Klaus
Die Titanic wurde von Profis gebaut,
die Arche Noah von einem Amateur.
... Und dieser Beitrag vom Amateurprofi....
  Mit Zitat antworten Zitat