Using event handlers - (EasyVENT version 3.2)
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
I've no plans to make this a dll or a user lib!Tipperton wrote:Any plans to make this a user library instead of a DLL?

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.
I may look like a mule, but I'm not a complete ass.
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
Hmmm.....
I noticed its a .pbi file (meaning its an include file) but...
maybe I'm missing something or just don't understand why the DLL procedure declarations...
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)
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
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!
It makes no difference to its use as an include file.
Just me being helpful!

It makes no difference to its use as an include file.
I may look like a mule, but I'm not a complete ass.
Which I will probably do, I find user libraries easier to use than include files.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.
Ah! Nice tip!srod wrote:It makes no difference to its use as an include file.

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!
Swings and roundabouts!

I may look like a mule, but I'm not a complete ass.
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
With the #OnUnhandledWinMessage there appears to be a problem with CustomDraw...
It seems to skip #NM_CUSTOMDRAW messages (part of #WM_NOTIFY):
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?)
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
Any ideas?
(Maybe #OnCustomDraw is needed?)
Works okay here with ListIcon's :
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
#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
I may look like a mule, but I'm not a complete ass.
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
I may look like a mule, but I'm not a complete ass.
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact:
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:
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!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())

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!

I may look like a mule, but I'm not a complete ass.
- DoubleDutch
- Addict
- Posts: 3220
- Joined: Thu Aug 07, 2003 7:01 pm
- Location: United Kingdom
- Contact: