Saturday, August 6, 2011

Form Control Part 2 - Resizing the Form

This a continuation of my experiences building this form

First, I need to correct something I said in Part 1:  "With the old system, Superbase, I could just add a where clause to the detail block definition to filter the data, but in the new system, SIMPOL, I did not yet have that ability.  I therefore wrote a filter routine to check the records before adding them to the subset file, which linked to the form."  I have since learned there is indeed a way to add a where clause to a detail block. If the detail block is not linked to the master record, you can set the parameters of the detail block to include a SQL92 compliant where clause.  I tried it initially, but did not have the syntax quite right, so I did not get the desired result.  Anyway, I have already developed a filter routine that works, so I'm not going back to retry the unlinked query approach, but it is there if I need it.

I was still working on this form but I could not get the event handler for the option buttons to work. They allow me to filter the records displayed in the form's detail block.  In fact, the development environment would crash when I tried to debug the source code.  It took a couple of days, but SIMPOL support were able to identify and resolve the problem.  It turned out to be an issue specific to my operating system (Windows 7 64-bit) that could not be reproduced on SIMPOL support's machines because they were using Windows Vista.  I let the technical director (sorry Neil, I'm not sure your real title) debug the problem on my machine.  It involved connecting using remote control software called TeamViewer and installing MS Visual Studio.  Neil was able to find and fix the issue.  I was sympathetic to Neil's plight.  I have been it the same position myself, not being able to reproduce the problem locally and needing to use remote control software to debug remotely.

Next, I decided to make my form resizeable.  Why? I have clients with different monitor resolutions, ranging from 800x600 to 1920x1080.  The standard form is designed to work in the minimum screen size, but that is too small for some of the users, with the highest resolution monitors.  The form needs to be readable regardless of the monitor, and on the large resolution displays, the text can get tiny. 

I decided to allow three resolutions to start: original - 100%, 125%, and 150%.  I added a Form Size menu and added these options to on it.  Further, I decided an Auto option was required.  The Auto option would be the default and the program could determine the display size and decide what was the optimum form size to fit.

I was going to hook everything up to a new menu, "Form Size", but I decided to first write the code and test it that did the real work.  This involves iterating through all the form objects and changing their position (top and left corner) and size (width and height) by the specified amount. I discovered there are actually several collections of objects that I had to work on, the form controls, the pages collection, the graphics collection, and the detailblocks collection. 

Actually, the each page has it's own controls collection, so I did not need to deal directly with the forms controls collection.  Actually collections is a Superbase or Windows term.  SIMPOL uses the term "dring".  A dring is a list of objects linked together and you can go from one to the next in the list and when you reach the end, the next retrieved is the first object again.  (That is the simple definition.) 

Even though I was dealing with a single page form, I wrote code to assume a multi-page form, so I could reuse the function later with multi-page forms.  I cycled through the pages collection first and changed the size of each page, then cycled through the page's controls dring and changes all the controls. When all pages were processed, I cycled through all the form's graphics elements doing the same thing.  Finally, I cycled through the form's detailblocks, changing the offset between rows.

Once I had the form resizing working (at application start-up), with a specified re-size percent, I added the menu and menu items and tried to get it to work on demand.  Adding a menu and menu items was straight forward, but things did not go smoothly.  I needed to work out the logic for restarting the form on the fly.  Up to this point, the program re-sized the form before it was shown to the user.  Now I was letting the user decide to change it and reload the form.  So I muddled around with that until I had the restart working smoothly. 

The final piece of was saving the users selected resizing option in a configuration file, so that the application could use the same setting the next time it was launched.  There is a library supplied with the development environment (conflib.sml) that handles reading and writing to private configuration files.  I added the library to my project, looked up how to use the getprivateprofilestring and writeprivateprofilestring functions, and got them working rather quickly.

This single form project is now relatively compete, but there are a few things missing.  I still need to add logic to filter the detail block records by date, but I may leave that until later, as I don't consider it very hard.  I am also waiting for a revised volatable library that will allow me to delete all records in the (volatile) 'notesubset' table. 

Any time you click one of the option buttons on the form, the app deletes all records in the notesubset table and reloads the table, filtering the records that can be loaded according to the user selection.  My current approach is to delete records one-by-one until the table is empty, but if there are more than 51 records, the delete record statement is hanging.  The problem appears to be beyond the reach of my debugger, so I have asked my SIMPOL vendor to take a look. The problem has only been detected because I am using volatile files in a different way than they were originally designed.  Using physical files, I did not have a problem. I'm using a volatile file because a memory-based file should be faster at deleting records. (I like my apps zippy.)

Once those items are addressed, I think I will progress to the next stage, hooking up the main form and making the app a multi-window application.  I have researched how to add an additional window to the app.  It seems easy enough and I am itching to get started.

-djinks         Apps and Services: www.jinksinc.com

5 comments:

  1. Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.

    rpa training in chennai
    rpa training in bangalore
    rpa course in bangalore
    best rpa training in bangalore
    rpa online training

    ReplyDelete
  2. Inspiring writings and I greatly admired what you have to say , I hope you continue to provide new ideas for us all and greetings success always for you..Keep update more information..
    Python training in bangalore
    Python course in pune
    Python training in bangalore

    ReplyDelete
  3. This is an awesome post.Really very informative and creative contents. These concept is a good way to enhance the knowledge.I like it and help me to development very well.Thank you for this brief explanation and very nice information.Well, got a good knowledge.
    Java training in Bangalore | Java training in Indira nagar

    Java training in Bangalore | Java training in Rajaji nagar

    Java training in Bangalore | Java training in Marathahalli

    Java training in Bangalore | Java training in Btm layout

    ReplyDelete
  4. Some us know all relating to the compelling medium you present powerful steps on this blog and therefore strongly encourage contribution from other ones on this subject while our own child is truly discovering a great deal. Have fun with the remaining portion of the year.
    Best Devops Training in pune
    excel advanced excel training in bangalore

    ReplyDelete