Sunday, August 14, 2011

Multiple Windows

I worked the last two days on adding a second window.  When the user clicks on a button in the main window, a second window will open and display  a form for browsing through multiple notes created for the main form's current contact record. It took a while to get this going.  The examples showed how to do this, but with a wxwindow object, the underlying windows object.  I needed to do this with the appwindow object, which was derived from the wxwindow object, but has more properties and methods and belongs to the SIMPOL appframework library.  There were no examples of this, so I had to deduct what to do.  Basically I followed the code for creating a new window and modified it to just add a window (type appwindow) to the existing application.

The main thing to learn here, and actually throughout this entire blog, is to learn to navigate and explore the object heirarchy that is provided.  I studied the appwindow object and saw that there was method.  I scanned the sample code projects and saw how it was used to create a primary window, then extrapolated what must be changed to produce a secondary window.  After several false starts, I created a second window.

The more difficult part was to sync the two windows.  I wanted the main record in both forms to be the same, so I needed to determine how to access the main application window's data while creating the second window.  That took a bit of digging, again through the object heirarchy, and several false starts.  I originally wanted to get the main form's master record and set that as the master record for the second form, but I had no luck.  Then I decided to just get the key from the first form's master record and use that to select the record for the second form's master record.  Each window's form has a select key method, so just needed to find the key value for the main form's master record and use that to select the record for the second form.  (Each window contains a form so second form means second window.)

Determining the exact syntax for doing all this required most of my time.  I'm new to the object heirarchy and took longer to find the exact syntax.  The more I learn, the faster I progress.  Finally I had a second window displayed, but there were problems.  For the master record on the second form, I only displayed the first record in the master file,  not the same record as the main window displayed.  I wanted to display multiple notes in the second form that matched in record in the main form.  The master record for both forms must be the same.  Anyway i finally worked out the syntax and I now have both forms displayed.

Well, there still are some problems to work out.  The same master record shows all the time on the second form.  In certain situations, I generate a third window, similar to the second. I'm tracking those down tomorrow.

Overall, I am pleased though.  I have a multi-window application and that is not trivial.  It looks pretty good and I'm confident I can fix the problems.  Soon I'll be moving on to the real purpose of this blog, running the application on more than one operating system.. Stay tuned.

-djinks         Apps and Services:

No comments:

Post a Comment