dwtveventdelay_20071217.zip
Version 1
Datawindow and Treeview Event with a Time Delay
--------------------------------------------------
Requirements
--------------------------------------------------
Windows NT4 and later
PB 9.03 ( convertable to PB 8 / PB 7 /PB 6.5  using Export/Import
PB 11 should work without problems
Most Datawindows are Release 6, so no source edit is necessary
------------------------------------------------------------------
Purpose
-------------------------------------------------------------------------
- Treeview Event Selectionchanged forwarded to UserEvent with Time Delay
- Datawindow Event RowFocusChanged  forwarded to UserEvent with Time Delay

using a timing object control events are forwarded to control user events
this creates an asynchronous behavior with the option, that a user
may scroll through a Treeview or Datawindow without executing
the depending code on selectionchanged/rowfocuschanged events
every time

to show when the delay userevent is triggered
I out different Pictures in a picture control
because selectionchanged and rowfocuschanged happen
with opening the window, the events will be triggered after opening once

-------------------------------------------------------------------------
Additional Features
-------------------------------------------------------------------------
- print treeview
- print a datawinodow with preview
- print a treeview in conjunction with a datawindow in one composite
- Tooltips for Command and Picturbuttons
- Tooltips for Datawindow Buttons
- Tooltips for Pictures  also Tooltip for Picture Areas 
- Tooltips more than one line
- Click on Picture Areas
- Resize and Move Controls with Windows Resize
- Resize and Move Controls with Cursor Move
- Multiselect Datawindow Rows
- Datawindow Sort on Header Doubleclick

Try:

move through treeviewitems using keyboard 
selectionchanged is forwarded to ue_delayended with delay value set

move through datawindow rows using keyboard 
rowfocuschaged is forwarded to ue_delayended with delay value set

change value for timer delay abd try again

try to select multiple rows in datwindow using ctrl,shift


--------------------------------------------------------------------
General Comment
--------------------------------------------------------------------
Most of the objetcts are necessary, because they are
referenced by basic classes that I use.

The main window in focus is    w_dwtveventdelay
Controls in Focus
u_datawindow
u_treeview
n_dodelay (timing object inherited from n_dotiming)



--------------------------------------------------------------------
Implementation Details
--------------------------------------------------------------------
The basic idea is, to create a timer object for the control
call timing.start(interval) within a control event
trigger a userevent within the control, when delay time has passed

code the userevent to execute the action

the only code 

Timing Object to implement Time Delay Events
--------------------------------------------
within u_datawindow and u_treeview
n_dodelay is instantiated

the function in focus is 
n_dodelay.of_starttimer (dragobject ado_dragobject,
       long al_intervalmillisec)
in Selectionchanged or rowfocuschanged
inv_dodelay.of_starttimer (This,  1000)

this starts the timer
after 1000 MiliSec "ue_delayended" is triggered

code in the instance of control the event "ue_delayended"
for execution of business (in te example pictur change)

Timing Object to implement Tooltips
---------------------------------------
a second timing object (inv_dotimimg) is used to implement the Tooltip
For tooltips within the calling control event "ue_timerended" is used 
to determine after 1000 Milisec if the Mouse Pointer is still on the
Control and Tooltips should be displayed or closed


-------------------------------------------------------------------------
Problems
--------------------------------------------------------------------------
Because the behavior becomes asynchronous
some Problems may appear.
The user may close the window during timer is running.
although it is to be expected that the timing object will be destroyed.
 
When the window is closed, this seems not to be the case.
The timer runs on and calls object that doesnt exist any more
(This may have been a PB Bug maybe solved)
To prevent the timer stays running, I call in the windows closequery event.

inv_wbusiness.of_timerstop()
calls inv_fbusiness.of_controlstrigger(This, "ue_timerstop")

to trigger  "ue_timerstop" within all controls
within ue_timerstop I call stop for all instantiated timing objects
If IsValid(inv_dodelay) Then inv_dodelay.of_stoptimer()
If IsValid(inv_dotiming) Then inv_dotiming.of_stoptimer()
to make sure that the timer will be stoppped

Other Problems may occur depending on the action
that is done with the asynchronous event.
In this case it may be better to do the business synchronous
coding the basic event


-------------------------------------------------------------------------
Other features in the application
--------------------------------------------------------------------

You will recognize, that there are some other features in the application.
- Tooltips (using Tag) for Picturebutton, Commandbuttons, Picture and Datawindow
  using u_picturebutton, u_commandbutton, u_picture, u_datawindow 
  just place u_picturebutton on a window and it will work
	n_dotiming is the timing object to make tooltips work
  The Mousemove Event is used to start Tooltip Action

- Resizeservice for Windows and Userobjects using n_wbusiness   n_ubusiness 
  n_wbusiness.of_resizeaddcontrol(dc_x, dc_y, dc_width, dc_heigt)

- dropdown calculator for editmask  and datawindow column

- dropdown calculator and calendar for datawindow columns

- different Tooltips and click actions for Picture depending on area definition

- Microhelp (using Tag) for all controls, telling them there Microhelpparent using
   n_fbusiness.of_controlstrigger(windowforcontrolcollect,w_MicrohelpParent,"ue_sethelpparent"
   then capture mousemove of the control and trigger w_MicrohelpParent
	Watch the MicrohelpText while moving over the controls
	Within a Datawindow  Tags of DwObjects are displayed instead of the Datawindow.Tag
	 Works for all controls on the window , no matter if on tabs or userobjects
  	Requires Basic Class Controls i.e. u_statiktext , u_datawindow

- Basic for a lot of reducing complexity, is to get a reference of the next parent window
  in the constructor of every control. So you can use iw_ControlParent within every control
  no matter if it is on a tabpage.(See u_commandbutton.constructor  for example)
  to centralize function i use inv_dobusiness.of_controlparent(This, iw_ControlParent)
  for this business

- the window w_txt_sh is the general window to display text
  save an read text files
  print text, search within text
  close with return text to multiline controls
  try to open a text from a multiline, modify and Close With Return Text
  
- Resizable Response Windows i.e. w_txt_sh

- every control has a functioncall to of_controlinfo 
	using key ctrl-shift-enter when control has focus
  <control>.of_controlinfo() displays specific Control Informations

- print treeview in a composite
  I use a function to create a treeview datawindow within a datastore
  to print with a composite I use functions to share child reports with
  datawindows.  So I first have to copy datastore to datawindow using setfullstate

- to print a treeview   d_printtreeitem    is used
  for printing within composite d_printtreeitem has to be designed in PBUnits
  in previous versions d_printtreeitem was designed in pixels, I changed this 

------------------------------------------------------------------------
Recommandation
--------------------------------------------------------------------------
There is a very good third party tool for browsing and analysing existing
PB Applications.
It is called PBBrowse and available at http://www.oowidgets.com/
Costs for a license is more than accetable (49.00 $)
I'm using this for years and it helps me a lot.  
-----------------------------------------------------------------------
Regards
Martin Bremer
E-Mail: m-bremer@wellcom.de (prefered)
or   martinbremer@compuserve.com  
 //EOF