Page 2 of 9

Posted: Sun Sep 23, 2007 4:46 pm
by Tipperton
Any plans to make this a user library instead of a DLL?

Posted: Sun Sep 23, 2007 5:41 pm
by DoubleDutch
It's not a DLL, it's an include file :?

Posted: Sun Sep 23, 2007 7:40 pm
by srod
Tipperton wrote:Any plans to make this a user library instead of a DLL?
I've no plans to make this a dll or a user lib! :wink:

As DoubleDutch says, EasyVENT comes in source code form - you just XIncludeFile() the main source file and you're good to go. This gives you far more flexibility than either a dll or a user library.

Posted: Sun Sep 23, 2007 9:44 pm
by DoubleDutch
EasyVent is really very good. It makes controlling gadgets much easier than before. Fred/Freak should take a real look at it and see if they can implement something similar that would be cross platform (I mean for V4.40 ;) ).

Posted: Sun Sep 23, 2007 10:41 pm
by Tipperton
Hmmm.....

I noticed its a .pbi file (meaning its an include file) but...

Code: Select all

ProcedureDLL.l PerformDefaultWinProcessing(*sender.PB_Sender)
.
.
.
ProcedureDLL.l RemoveEventHandler(hwnd, evtype, commanditem=-1)
.
.
.
ProcedureDLL.l SetEventHandler(hwnd, evtype, procaddress, commanditem=-1)
maybe I'm missing something or just don't understand why the DLL procedure declarations...

Posted: Sun Sep 23, 2007 10:47 pm
by DoubleDutch
Maybe SRod had plans at one time to make it into a lib, but hasn't?

Posted: Sun Sep 23, 2007 11:05 pm
by srod
I've labelled the functions which would need exporting in the case that any user of the library wanted to create a user library for themselves. That's the only reason. Some people like to package such things up into static libraries rather than have an extra source file flying around.

Just me being helpful! :wink:

It makes no difference to its use as an include file.

Posted: Mon Sep 24, 2007 12:11 am
by Tipperton
srod wrote:I've labelled the functions which would need exporting in the case that any user of the library wanted to create a user library for themselves. That's the only reason. Some people like to package such things up into static libraries rather than have an extra source file flying around.
Which I will probably do, I find user libraries easier to use than include files.
srod wrote:It makes no difference to its use as an include file.
Ah! Nice tip! :cool:

Posted: Mon Sep 24, 2007 12:18 am
by srod
Of course, if you create a user library of your own (I don't mean converting EasyVENT to a user lib) which just happens to use EasyVENT in source code form, then you'll want to switch the three ProcedureDLL's for regular Procedure's else you'll export the EasyVENT commands alongside your own exported commands!

Swings and roundabouts! :wink:

Posted: Mon Sep 24, 2007 3:22 pm
by DoubleDutch
With the #OnUnhandledWinMessage there appears to be a problem with CustomDraw...

It seems to skip #NM_CUSTOMDRAW messages (part of #WM_NOTIFY):

Code: Select all

Procedure CustomTree(*sender.PB_Sender)
	If *sender\uMsg=#WM_NOTIFY
		Debug("At notify")
		*nml.NMTVCUSTOMDRAW=*sender\lParam
		If *nml\nmcd\hdr\code=#NM_CUSTOMDRAW
			Debug("At custom draw")
			Select *nml\nmcd\dwDrawStage
				Case #CDDS_PREPAINT
					ProcedureReturn #CDRF_NOTIFYPOSTPAINT|#CDRF_NOTIFYITEMDRAW
					
        Case #CDDS_ITEMPREPAINT
          item=*nml\nmcd\lItemlParam
The debug message "At Notify" should display when there is a draw to the screen (before a paint message). But there are hardly any messages getting to this point and none of them #NM_CUSTOMDRAW codes.

Any ideas?

(Maybe #OnCustomDraw is needed?)

Posted: Mon Sep 24, 2007 3:56 pm
by srod
Works okay here with ListIcon's :

Code: Select all

#NM_CUSTOMDRAW = #NM_FIRST - 12 

#CDDS_ITEM = $10000 
#CDDS_PREPAINT = $1 
#CDDS_ITEMPREPAINT = #CDDS_ITEM | #CDDS_PREPAINT 
#CDRF_DODEFAULT = $0 
#CDRF_NOTIFYITEMDRAW = $20 


XIncludeFile "EasyVENT.pbi"
DisableExplicit

Declare.l MainProc(*sender.PB_Sender)

Global ListGadget.l 


hwnd.l = OpenWindow(0, 0, 0, 356, 197, "",#PB_Window_ScreenCentered | #PB_Window_SystemMenu) 
CreateGadgetList(hwnd) 

ListGadget = ListIconGadget(1, 10, 10, 336, 177,"ssss", 70, #PB_ListIcon_GridLines) 
AddGadgetColumn(1, 1, "Sun", 35) 
AddGadgetColumn(1, 2, "Mon", 35) 

; add some rows 
For i = 0 To 10
  AddGadgetItem(1, -1, "Row "+Str(i)) 
Next

SetEventHandler(hwnd, #OnUnhandledWinMessage, @MainProc())

Repeat 
Until WaitWindowEvent()=#PB_Event_CloseWindow 

End 


Procedure.l MainProc(*sender.PB_Sender)
  Protected result
  Select *sender\uMsg
    ;First deal with all Windows messages that we require to handle.
      Case #WM_NOTIFY 
        *LVCDHeader.NMLVCUSTOMDRAW = *sender\lParam 
        If *LVCDHeader\nmcd\hdr\hwndFrom = ListGadget And *LVCDHeader\nmcd\hdr\code = #NM_CUSTOMDRAW 
          Select *LVCDHeader\nmcd\dwDrawStage 
            Case #CDDS_PREPAINT 
              result = #CDRF_NOTIFYITEMDRAW 
            Case #CDDS_ITEMPREPAINT 
              Row.l = *LVCDHeader\nmcd\dwItemSpec 
              If (Row/2) * 2 = Row 
                *LVCDHeader\clrTextBk = RGB(255, 255, 223) 
              Else 
                *LVCDHeader\clrTextBk = #Blue
              EndIf 
              result = #CDRF_DODEFAULT 
            EndSelect 
        Else
          result = PerformDefaultWinProcessing(*sender)
        EndIf 
      Default
        result = PerformDefaultWinProcessing(*sender)
  EndSelect
  ProcedureReturn result
EndProcedure


To be honest I can't see how it can play up since #OnUnandledWinMessage just throws the message straight at the respective handler.


Here's a tree gadget :

Code: Select all

Enumeration 
  #MainWindow 
  #TreeGadget 
EndEnumeration 


XIncludeFile "EasyVENT.pbi"
DisableExplicit

Global hBrush 
hBrush = CreateSolidBrush_(#Red) 

Procedure.l MainProc(*sender.PB_Sender)
  Protected result
  Select *sender\uMsg
    ;First deal with all Windows messages that we require to handle.
      Case #WM_NOTIFY 
        *tvCD.NMTVCUSTOMDRAW=*sender\lParam 
        If *tvCD\nmcd\hdr\hwndFrom=GadgetID(#TreeGadget) And *tvCD\nmcd\hdr\code=#NM_CUSTOMDRAW    
          Select *tvCD\nmcd\dwDrawStage 
            Case #CDDS_PREPAINT:ProcedureReturn #CDRF_NOTIFYITEMDRAW 
            Case #CDDS_ITEMPREPAINT: ProcedureReturn #CDRF_NOTIFYPOSTPAINT 
            Case #CDDS_ITEMPOSTPAINT 
              thisItem=*tvCD\nmcd\dwItemSpec 
              tvItemRect.RECT\left=thisItem 
              SendMessage_(GadgetID(#TreeGadget),#TVM_GETITEMRECT,#True,@tvItemRect) 
              tvi.TV_ITEM 
              tvi$ = Space(256) 
              tvi\mask = #TVIF_HANDLE | #TVIF_PARAM | #TVIF_TEXT 
              tvi\pszText = @tvi$ 
              tvi\cchTextMax = 256 
              tvi\hItem=thisItem 
              tvFlags=#DT_END_ELLIPSIS 
              SendMessage_(GadgetID(#TreeGadget),#TVM_GETITEM,0,tvi) 
              tvi$=ReplaceString(tvi$,"[name]","Anthony") 
              SetTextColor_(*tvCD\nmcd\hdc,RGB(255,255,255))  
              FillRect_(*tvCD\nmcd\hdc, tvItemRect, hBrush) 
              If *tvCD\nmcd\uItemState = #CDIS_FOCUS | #CDIS_SELECTED 
                SetBkColor_(*tvCD\nmcd\hdc,#Blue) 
              Else 
                SetBkColor_(*tvCD\nmcd\hdc,#Red) 
              EndIf 
              DrawText_(*tvCD\nmcd\hdc,tvi$,Len(tvi$),tvItemRect,tvFlags) 
              ProcedureReturn #CDRF_DODEFAULT 
          EndSelect 
        Else
          result = PerformDefaultWinProcessing(*sender)
        EndIf 
      Default
        result = PerformDefaultWinProcessing(*sender)
  EndSelect
  ProcedureReturn result
EndProcedure


If OpenWindow(#MainWindow,0,0,355,180,"",#PB_Window_SystemMenu|#PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0)) 
  TreeGadget(#TreeGadget, 10,10,330,160)  
  AddGadgetItem (#TreeGadget,-1,"Item 0") 
  AddGadgetItem (#TreeGadget,-1,"Item 1") 

  SetEventHandler(WindowID(0), #OnUnhandledWinMessage, @MainProc())

  Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow 
  DeleteObject_(hBrush) 
EndIf

Posted: Mon Sep 24, 2007 4:25 pm
by srod
Try this :

Code: Select all

Procedure CustomTree(*sender.PB_Sender) 
   If *sender\uMsg=#WM_NOTIFY 
      Debug("At notify") 
      *nml.NMTVCUSTOMDRAW=*sender\lParam 
      If *nml\nmcd\hdr\code=#NM_CUSTOMDRAW 
         Debug("At custom draw") 
         Select *nml\nmcd\dwDrawStage 
            Case #CDDS_PREPAINT 
               ProcedureReturn #CDRF_NOTIFYITEMDRAW 
                
        Case #CDDS_ITEMPREPAINT 
          item=*nml\nmcd\lItemlParam
          
          ; ...blah blah

          ProcedureReturn #CDRF_NOTIFYPOSTPAINT

Posted: Mon Sep 24, 2007 4:29 pm
by DoubleDutch
IC, I was attaching the EasyVent it to the actual tree, not to the main window.

no problem now, but it would be good if EasyVent could somehow allow you to do something like:

Code: Select all

SetEventHandler(SubjectTreeId,#OnCustomDraw,@CustomTree())

Posted: Mon Sep 24, 2007 4:34 pm
by srod
DoubleDutch wrote:no problem now, but it would be good if EasyVent could somehow allow you to do something like:

Code: Select all

SetEventHandler(SubjectTreeId,#OnCustomDraw,@CustomTree())
I'm sure it would! :wink:

To be honest, custom draw is a little out of the ordinary and so off the beaten track that it would be a pretty esoteric addition to EasyVENT. No, #OnUnhandledWinMessage is there for just this kind of thing and so it will remain! :)

Posted: Mon Sep 24, 2007 4:45 pm
by DoubleDutch
np :)