Page 1 of 1

Notify Event for own Control

Posted: Mon Oct 17, 2022 5:55 am
by Jimmy
hi,

for my CLASS TGrid i like to receive Notify Event when fired for LVN_GETDISPINFO

---

when use CLASS ActiveX i can use Codeblock Slot bOnEvent

Code: Select all | Expand

  ::oControl:bOnEvent := { | cEvent, aParams | ::VLC_Event( cEvent, aParams ) }

it is called in METHOD OnEvent() CLASS TActiveX

---

how can i use this Concept in my own Class TGrid under FiveWin :?:

Re: Notify Event for own Control

Posted: Mon Oct 17, 2022 6:40 am
by Antonio Linares
Dear Jimmy,

Please post here the code of your Class TGrid so we can review it and help you, thanks

Re: Notify Event for own Control

Posted: Mon Oct 17, 2022 7:50 am
by Jimmy
hi Antonio,

i have no (working) Code yet, just begin to build Method and HB_FUNC()

---

i have from TLISTVIE.PRG

Code: Select all | Expand

METHOD Notify( nIdCtrl, nPtrNMHDR ) CLASS TListView
local nOption
local nCode       := GetNMHDRCode( nPtrNMHDR )

   do case
      case nCode == NM_CLICK
        ...
      case nCode == LVN_ITEMCHANGED
        ...
      case nCode == LVN_GETDISPINFO   // add here ?
 

do i add LVN_GETDISPINFO here :?:

---

Listview can use "Single" API Call

Code: Select all | Expand

   Listview_InsertItem()

for each Row or "just" assign hole Array and use Notify Event when set LVN_GETDISPINFO

this is my Xbase++ using OT4XB Syntax

Code: Select all | Expand

// create Notify Event to send UserDef Event xbeMyLv_DISPINFO
   ::SetLvNotifyCB( LVN_GETDISPINFO  , ;
     { | xbp, code, lp, st | st := NMLVDISPINFO():New(), st:_write_( lp, 0, - 1 ), ;
     PostAppEvent(xbeMyLv_DISPINFO, st:item, st, Self ), NIL } )


Code: Select all | Expand

INLINE METHOD SetLvNotifyCB( notify_code , b )
       local k,r
       local np  := PCount()
       if Valtype(notify_code) != "N" ; return NIL ; end
       k := cPrintf("LV%08.8X.notify",notify_code)
       r := delegated_eval( {|| iif( ::m_ht == NIL,, _hdict_GetProp(::m_ht,k)) } )
       if np > 1
          if Valtype(b) == "B"
             delegated_eval( {|| iif( ::m_ht == NIL,, _hdict_SetProp(::m_ht,k,b)) } )
          else
             delegated_eval( {|| iif( ::m_ht == NIL,, _hdict_RemoveProp(::m_ht,k)) } )
          end
       end
       return r

Code: Select all | Expand

// will be activate when get WM_NOTIFY
INLINE METHOD xbp_wndproc(hWnd,nMsg,wp,lp,ctx)
   ...
    elseif nMsg == WM_NOTIFY
       if lp == 0 ; return NIL ; end // must not happen
       if( PeekDWord(lp) == ::hLv ) // hLv Handle of Listview
         return ::_HandleListViewNotify_( PeekDWord(lp,8) , lp )
       end
       return NIL


Code: Select all | Expand

// will EVAL() Codeblock
INLINE METHOD _HandleListViewNotify_( notify_code , p ) // do not call outside GUI thread
local b := iif( ::m_ht==NIL,NIL, _hdict_getprop(::m_ht, cPrintf("LV%08.8X.notify",notify_code)) )
   if Valtype(b) =="B"
      return Eval(b, Self , notify_code , p )
   end
return NIL

Re: Notify Event for own Control

Posted: Mon Oct 17, 2022 10:34 am
by Antonio Linares
Dear Jimmy,

> do i add LVN_GETDISPINFO here ?

yes, that is fine

Re: Notify Event for own Control

Posted: Tue Oct 18, 2022 11:27 pm
by Jimmy
to use Notify Event LVN_GETDISPINFO i need Structure LV_DISPINFO (NMLVDISPINFO) and lParam

i have found

Code: Select all | Expand

GetLParam( nPtrNMHDR )

and try to use it in METHOD Notify() but i only got 0 (zero)

Code: Select all | Expand

METHOD Notify( nIdCtrl, nPtrNMHDR ) CLASS TGrid
LOCAL nOption
LOCAL nCode   := GetNMHDRCode( nPtrNMHDR )
local nLPar   := GetLParam(    nPtrNMHDR )

   DO CASE
      CASE nCode == NM_CLICK
           ...
      CASE nCode == LVN_ITEMCHANGED
           ...
      CASE nCode == LVN_GETDISPINFO
         IF ::bDisplay != nil
            msgInfo(VAR2CHAR(nLPar),"LVN_GETDISPINFO")
            EVAL( ::bDisplay, nLPar, Self )
         ENDIF
 

so how use LParam for Notify Event LVN_GETDISPINFO :idea: