It is currently Wed Oct 21, 2020 2:12 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: ExplorerTreeGadget and #PB_EventType_RightDoubleClick
PostPosted: Sun Sep 27, 2020 11:05 am 
Offline
User
User

Joined: Sun Oct 24, 2004 9:25 am
Posts: 84
ExplorerTreeGadget falsely returns only #PB_EventType_RightClick when actually a Double Right Click was executed.
Code adapted from example in the EventType docs (which uses ListIconGadget, where Right Double Clicks are working, but also return an additional #PB_EventType_RightClick )
Environment: PB5.71x64, PB5.72x64 on WIN 7 x64 pro

Code:
  If OpenWindow(0, 0, 0, 230, 120, "Eventtypes example...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    ExplorerTreeGadget(2,10,10,100,100, "C:\")
 
     Repeat
       Event = WaitWindowEvent()
       
       Select Event
       
         Case #PB_Event_Gadget
           Select EventGadget()
             Case 2
               Select EventType()
                 Case #PB_EventType_LeftClick        : Debug "Click with left mouse button"
                 Case #PB_EventType_RightClick       : Debug "Click with right mouse button"
                 Case #PB_EventType_LeftDoubleClick  : Debug "Double-click with left mouse button"
                 Case #PB_EventType_RightDoubleClick : Debug "Double-click with right mouse button"
               EndSelect
           EndSelect
       
       EndSelect
     Until Event = #PB_Event_CloseWindow
  EndIf


_________________
Is this an artifact or should it be disposed of ?


Top
 Profile  
Reply with quote  
 Post subject: Re: ExplorerTreeGadget and #PB_EventType_RightDoubleClick
PostPosted: Sun Sep 27, 2020 12:53 pm 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 2681
Location: Germany
It's weird. PB evaluates for the mouse clicks the Notify Code from the controls.

The ExplorerTreeGadget is a "WC_TREEVIEW". Although in the description of MSDN the Notify Code "NM_RDBLCLK" should be given for the TreeView, it does not arrive. In case of a WC_LISTVIEW "ListIconGadget" the Notify code "NM_RDBLCLK" arrives.

But in the GadgetCallback you can request the message "#WM_RBUTTONDBLCLK".

But it is a question if the error is in the MS Control or if the message is intercepted by PB before.

Testcode
Code:
;-TOP

; Comment : Module SetGadgetCallback (Windows Only)
; Author  : mk-soft
; Version : v0.03
; Created : 10.06.2018
; Updated : 16.02.2020
; Link    : https://www.purebasic.fr/english/viewtopic.php?f=12&t=70842
;
; Syntax Callback:
;           Procedure GadgetCB(hWnd,uMsg,wParam,lParam)
;             Select uMsg
;               ;TODO
;             EndSelect
;             ; Call previous gadget procedure
;             ProcedureReturn CallGadgetProc(hWnd,uMsg,wParam,lParam)
;           EndProcedure
;
; *****************************************************************************

DeclareModule GadgetCallback
 
  Declare SetGadgetCallback(Gadget, *lpNewFunc)
  Declare CallGadgetProc(hWnd, uMsg, wParam, lParam)
 
EndDeclareModule

Module GadgetCallback
 
  EnableExplicit
 
  ; ---------------------------------------------------------------------------
 
  Procedure SetGadgetCallback(Gadget, *lpNewFunc)
    Protected hWnd, *lpPrevFunc
   
    If IsGadget(Gadget)
      hWnd = GadgetID(Gadget)
      *lpPrevFunc = GetProp_(hWnd, "PB_PrevFunc")
      ; Remove exists Callback
      If *lpPrevFunc
        SetWindowLongPtr_(hWnd, #GWL_WNDPROC, *lpPrevFunc)
        RemoveProp_(hWnd, "PB_PrevFunc")
      EndIf
      ; Set new Callback 
      If *lpNewFunc
        *lpPrevFunc = SetWindowLongPtr_(hWnd, #GWL_WNDPROC, *lpNewFunc)
        SetProp_(hWnd, "PB_PrevFunc", *lpPrevFunc)
        ProcedureReturn *lpPrevFunc
      EndIf
    EndIf
    ProcedureReturn 0
  EndProcedure
 
  ; ---------------------------------------------------------------------------
 
  Procedure CallGadgetProc(hWnd, uMsg, wParam, lParam)
    Protected result, *lpPrevFunc
   
    *lpPrevFunc = GetProp_(hWnd, "PB_PrevFunc")
    If *lpPrevFunc
      result = CallWindowProc_(*lpPrevFunc, hWnd, uMsg, wParam, lParam)
    EndIf
    ProcedureReturn result
  EndProcedure
EndModule

; *****************************************************************************

;-TOP

UseModule GadgetCallback

Procedure WinCallback(hWnd, uMsg, wParam, lParam)
  Protected *NMHDR.NMHDR
  Select uMsg
    Case #WM_NOTIFY
      *NMHDR = lParam
      Select *NMHDR\code
        Case #NM_CLICK
          Debug "Notify: Left click gadget " + *NMHDR\idFrom
        Case #NM_DBLCLK
          Debug "Notify: Left double click gadget " + *NMHDR\idFrom
        Case #NM_RCLICK
          Debug "Notify: Right click gadget " + *NMHDR\idFrom
        Case #NM_RDBLCLK
          Debug "Notify: Right double click gadget " + *NMHDR\idFrom
      EndSelect
     
  EndSelect
 
  ProcedureReturn #PB_ProcessPureBasicEvents
 
EndProcedure

Procedure GadgetCallback(hWnd, uMsg, wParam, lParam)
 
  Select uMsg
    Case #WM_RBUTTONDBLCLK
      Debug "GadgetCallback: Right double click"
     
  EndSelect
 
  ProcedureReturn CallGadgetProc(hWnd, uMsg, wParam, lParam)
 
EndProcedure

Procedure.s GetClassName(Handle.i)
  Protected Class.s
  Class.s = Space(1024)
  GetClassName_(Handle, @Class, Len(Class))
  ProcedureReturn Left(Class, Len(Class))
EndProcedure

If OpenWindow(0, 0, 0, 300, 120, "Eventtypes example...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ExplorerTreeGadget(2,10,10,290,110, "C:\")
 
  ;   ListIconGadget(2, 5, 5, 290, 110, "Name", 100, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
  ;    AddGadgetColumn(2, 1, "Address", 250)
  ;    AddGadgetItem(2, -1, "Harry Rannit"+Chr(10)+"12 Parliament Way, Battle Street, By the Bay")
  ;    AddGadgetItem(2, -1, "Ginger Brokeit"+Chr(10)+"130 PureBasic Road, BigTown, CodeCity")
 
  SetWindowCallback(@WinCallback())
  SetGadgetCallback(2, @GadgetCallback())
 
  Debug GetClassName(GadgetID(2))
 
  Repeat
    Event = WaitWindowEvent()
   
    Select Event
       
      Case #PB_Event_Gadget
        Select EventGadget()
        EndSelect
       
    EndSelect
  Until Event = #PB_Event_CloseWindow
EndIf

_________________
My Projects ThreadToGUI / OOP-BaseClass / OOP-BaseClassDispatch / EventDesigner V3
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
 Post subject: Re: ExplorerTreeGadget and #PB_EventType_RightDoubleClick
PostPosted: Sun Sep 27, 2020 1:34 pm 
Offline
User
User

Joined: Sun Oct 24, 2004 9:25 am
Posts: 84
Thanks, mk-soft for your indepth analysis (I wouldn't even know how to achieve that on my own).
Maybe, it is like it is, then the docs should simply be fixed for this gadget type.

Came across PB's misbehaviour incidentally with one of my humble programs.
I surely "won" a few grey hairs more, checking why my program would react inexpectedly when the simple example code from the docs worked like a charm,
until I finally changed the latter to the offending gadget type.

Of course, I checked the german and the english PB Forum before submitting the case, but it seems that Double Rigth Clicks are extremely unpopular with PB Developers. ;)

_________________
Is this an artifact or should it be disposed of ?


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: Axeman and 4 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