It is currently Fri Jan 15, 2021 7:03 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Rigth click detection on listicon header
PostPosted: Thu May 28, 2020 7:31 am 
Offline
User
User

Joined: Wed Nov 06, 2019 10:28 am
Posts: 84
Hi,

I've achieved the detection of right click on listicon header (not possible with purebasic function) by subclassing the gadget but I'm surprised that it's working that way.
Look at the code, the right click event is triggered only on header? Why not in the entire listicon ?


Code:
Global oldproc

Procedure SubClass_LV(hwnd, msg, wparam, lparam)
   Protected result = CallWindowProc_(oldproc, hwnd, msg, wparam, lparam)
   
   Protected *nmh.NMHDR
   
   If msg = #WM_NOTIFY
      *nmh = lparam
      Select *nmh\code
         Case #NM_RCLICK
            Debug "rclick"
            
      EndSelect
   EndIf

;       Another solution
;    If msg = #WM_PARENTNOTIFY And wparam = #WM_RBUTTONDOWN
;       Debug "rclick"
;    EndIf

   
   ProcedureReturn result
EndProcedure


 If OpenWindow(0, 100, 100, 300, 100, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
   ListIconGadget(0, 5, 5, 290, 90, "Name", 100, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
   AddGadgetColumn(0, 1, "Address", 250)
   AddGadgetItem(0, -1, "Harry Rannit"+Chr(10)+"12 Parliament Way, Battle Street, By the Bay")
   AddGadgetItem(0, -1, "Ginger Brokeit"+Chr(10)+"130 PureBasic Road, BigTown, CodeCity")

   oldproc = SetWindowLongPtr_(GadgetID(ListView_ConsoleRA), #GWL_WNDPROC, @SubClass_LV())

   Repeat
     Event = WaitWindowEvent()
   Until Event = #PB_Event_CloseWindow
 EndIf



Top
 Profile  
Reply with quote  
 Post subject: Re: Rigth click detection on listicon header
PostPosted: Thu May 28, 2020 3:38 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Apr 12, 2009 6:27 am
Posts: 3822
Hi
Header is totally different Class than ListView(ListIcon)
Code:
Global oldproc ,header

Procedure SubClass_LV(hWnd, uMsg, wParam, lParam)
  result = CallWindowProc_(oldproc, hWnd, uMsg, wParam, lParam)
  Select uMsg
    Case #WM_NOTIFY     
      *nmh.NMHDR  = lParam
      Select *nmh\code
        Case #NM_RCLICK
          GetCursorPos_ (@p.POINT)
          ScreenToClient_ (header, @p)
          nmhi.HD_HITTESTINFO
          nmhi\pt\x = p\x
          nmhi\pt\y = p\y
          SendMessage_(header,#HDM_HITTEST,0,@nmhi)
          index = nmhi\iItem
          Debug index
      EndSelect       
   
    Case #WM_RBUTTONDOWN           
      nmlv.LVHITTESTINFO
      nmlv\pt\x = (lParam & $FFFF)
      nmlv\pt\y = (lParam>> 16 & $FFFF)                   
      SendMessage_(GadgetID(0),#LVM_SUBITEMHITTEST,0,@nmlv)
      row = nmlv\iItem
      col = nmlv\iSubItem
      Debug row
      Debug col   
    EndSelect
   
   ProcedureReturn result
EndProcedure

 If OpenWindow(0, 0, 0, 300, 200, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered )
   ListIconGadget(0, 5, 5, 290, 190, "Name", 100, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
   header = SendMessage_(GadgetID(0),#LVM_GETHEADER,0,0)
   AddGadgetColumn(0, 1, "Address", 250)
   AddGadgetItem(0, -1, "Harry Rannit"+Chr(10)+"12 Parliament Way, Battle Street, By the Bay")
   AddGadgetItem(0, -1, "Ginger Brokeit"+Chr(10)+"130 PureBasic Road, BigTown, CodeCity")

   oldproc = SetWindowLongPtr_(GadgetID(0), #GWL_WNDPROC, @SubClass_LV())

   Repeat
     Event = WaitWindowEvent()
   Until Event = #PB_Event_CloseWindow
 EndIf


_________________
Egypt my love


Top
 Profile  
Reply with quote  
 Post subject: Re: Rigth click detection on listicon header
PostPosted: Fri May 29, 2020 12:50 pm 
Offline
User
User

Joined: Wed Nov 06, 2019 10:28 am
Posts: 84
Oh I see.
Thank you RASHAD.


Top
 Profile  
Reply with quote  
 Post subject: Re: Rigth click detection on listicon header
PostPosted: Tue Jun 02, 2020 5:40 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 4835
Location: Lyon - France
Thanks RASHAD :wink:

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye