Events OnChanged and OnPaint and OnInitialize

Started by velasquez, February 14, 2009, 01:14:10 PM

Previous topic - Next topic

velasquez

OpenDCL 4.1.2.2 
 
The event OnChanged of TabControl works before the event OnInitialize. 
Should not it be later? 
This doesn't happen with the event OnPaint of PictureBox. 
That is normal.

owenwengerd

The form's OnInitialize event does not get called until all controls are created. In the case of the tab control, its OnChanged event gets fired during creation when the first tab is set current. It could probably be argued that OnChanged should not be fired at that point, but a case could also be made that this behavior is useful (e.g. when OnChanged needs to initialize the tab page before it is displayed).

OnPaint is a different animal altogether, because painting is always deferred until other Windows messages are processed. The bottom line is that there is no guarantee that some control events will not occur before the form's OnInitialize event.

Fred Tomke

Hi, there are orther controls and events which will also be fired at creation, so that's why I solve it this way.
It is a bit more code but it works:


(defun c:proj_form_OnInitialize ()
  (do_something_here)
  (dcl_tab_setcursel proj_form_tab intTabToSel)
  (setq isInit nil)
); c:proj_form_OnInitialize

(defun c:dcl_tab_setcursel_OnSelChanged (intTab)
  (if (not isInit)
    (tab_was_changed)
  ); if
); c:dcl_tab_setcursel_OnSelChanged

(setq isInit T)
(setq intTabToSel 2)
(dcl_form_show proj_form)


Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]