Question About Function Execution in a Form

Started by Martin Francom, December 26, 2009, 01:57:31 PM

Previous topic - Next topic

Martin Francom

Paul,
   Does every function located on a FORM get executed during the Form Create process?

   Because that seems to be what is happening in one of my programs.  I have a function located on FORM1  that searches a SQL DB.  I found that I was getting an SQL error message before FORM1 displays.  The SQL DB is opened at the end of the FORM1_Create function. When I put a test to ensure FORM1_Create had finished before that function would fire then the error message stopped.
    If this is normal behavior (that all functions on a Form are triggered at it's creation) then functions that should not be run untill after the form is created should not be placed on the form.   Is my thinking correct?

Martin Francom

Well, I found a solution to my problem.  It turns out not to have anything to do with Theme Support.   After much trial and error.  I found the code that was causing the problem.
    I was doing an initial search of the SQLite DB at the end of the Form1_Create function. That search also loaded the TextBoxs of  Form1.    I found if I moved that code out of the Form1_Create function then the program would load it's GUI and run correctly in both Windws-7 and Windows-XP.
   Can anyone explane why this would cause the problem?

Roger Garstang

Did the code do anything else...say on error or if not able to connect to the Database, etc?  Something like closing or destroying the form in the Create message or something that would cause it to hang and maybe Win7 didn't allow it.  I don't see how just setting the text of a control would be an issue.  I do it for Textboxes, Combos, Listboxes, Listviews, etc all the time.  And, I think the Init function mentioned Paul made it call either all the time or with an option in the FF options..not at Dev PC to check.  It couldn't be detected 100% of the time if Common Controls were used since people can use Tooltips and such on their own, so I think he improved it to be always added.

Roger Garstang

??? What happened to this thread?  I replied to your Theme thread and it split into this one and put my reply here...