Hi NM
Unfortunately PtInRect_(r, PeekQ(@p)) will take the gadget itself into account
Just move the mouse over the gadget to see the difference
Thanks for commenting
Code: Select all
Structure COMBOBOXINFO
cbSize.l
rcItem.RECT
rcButton.RECT
stateButton.l
hwndCombo.i
hwndItem.i
hwndList.i
EndStructure
OpenWindow(0,0,0,400,200,"",#PB_Window_SystemMenu |#PB_Window_ScreenCentered)
ComboBoxGadget(1, 10, 10, 285, 20)
OpenWindow(1,0,0,0,0,"",#PB_Window_BorderLess)
TextGadget(2,0,0,0,0,"",#SS_CENTERIMAGE)
SetGadgetColor(2,#PB_Gadget_BackColor,$E7FEFF)
SetGadgetColor(2, #PB_Gadget_FrontColor, $0000FF)
inf.COMBOBOXINFO
inf\cbSize = SizeOf(inf)
GetComboBoxInfo_(GadgetID(1),@inf)
SetWindowLongPtr_( WindowID(1), #GWL_HWNDPARENT,inf\hwndList )
For a=0 To 20
s.s= s+ InsertString("test ", "test ", 5)
AddGadgetItem(1, -1, s +Str(a))
Next
;cbith = SendMessage_(GadgetID(1), #CB_GETITEMHEIGHT, 0, 0) +1
SendMessage_(GadgetID(1), #CB_GETDROPPEDCONTROLRECT, 0, r.RECT)
SetActiveWindow(0)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #WM_MOUSEMOVE
If SendMessage_(GadgetID(1), #CB_GETDROPPEDSTATE, 0, 0) = 1
GetCursorPos_(p.POINT)
If p\x >= r\left And p\x <= r\right And p\y >= r\top + 20 And p\y <= r\bottom
index = SendMessage_(GadgetID(1), #CB_GETCURSEL, 0, 0)
Text$ = GetGadgetItemText(1,index)
ScreenToClient_(WindowID(0),p)
ResizeWindow(1,WindowX(0)+20,WindowY(0)+p\y+40,Len(text$)*4+15,20)
ResizeGadget(2,0,0,Len(text$)*4+15,20)
SetGadgetText(2," "+Text$)
Else
ResizeWindow(1,0,0,0,0)
SetGadgetText(2,"")
EndIf
EndIf
Case #WM_LBUTTONUP
If SendMessage_(GadgetID(1), #CB_GETDROPPEDSTATE, 0, 0) = 0
ResizeWindow(1,0,0,0,0)
EndIf
EndSelect
Until Quit = 1
BTW
FindWindow_("ComboLBox",0) after any combobox will give us the same result as using the COMBOBOXINFO structure
Code: Select all
Structure COMBOBOXINFO
cbSize.l
rcItem.RECT
rcButton.RECT
stateButton.l
hwndCombo.i
hwndItem.i
hwndList.i
EndStructure
OpenWindow(0,0,0,600,200,"",#PB_Window_SystemMenu |#PB_Window_ScreenCentered)
ComboBoxGadget(1, 10, 10, 285, 20)
dlh1 = FindWindow_("ComboLBox",0)
Debug dlh1
inf.COMBOBOXINFO
inf\cbSize = SizeOf(inf)
GetComboBoxInfo_(GadgetID(1),@inf)
Debug inf\hwndList
ComboBoxGadget(2, 310, 10, 100, 20)
dlh2 = FindWindow_("ComboLBox",0)
Debug dlh2
GetComboBoxInfo_(GadgetID(2),@inf)
Debug inf\hwndList
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
EndSelect
Until Quit = 1