Thursday, March 29, 2012

Various Images in a Grid - Part II

I have previously posted a way to show different images in a grid on Weblogs using 5 image objects and employing DynamicCurrentControl property of the grid.  That is because the need is limited only to that 5 images. http://weblogs.foxite.com/sandstorm36/2008/08/09/placing-various-images-on-a-grid/

However, now that I need to really show varying undetermined number of images on a grid based on outside image files (jpegs) in a folder, that approach is a no no.  Therefore I sought other ways shown by experts such as Cetin Basoz and checked how that can be implemented on my needs. 

Most of the codes are adapted from Cetin's especially the usage of DynamicFontBold, except that this approach gets the images straight on outside files in a folder.  The trick is to be able to link the record with the real file name of the image file via one field (or several combined fields).  And since mine has an asset number and the images are named after the asset number (by design), then it did not pose any problem.  Here is the result:

Wednesday, March 28, 2012

More Objects Inside a Grid Cell

In pursuit of making the appearances of our app more powerful, I decided to make my grid more appealing by way of showing several objects inside a cell.  And that can be attained via containers plus manipulating .controlsource(s).

Let us say I have this SQL SELECT:

SELECT fld1, fld2, fld3, fld4, fld5, fld6, fld7, fld8, fld9, fld10 from mytable into cursor junk nofilter

So I have 10 fields above.  Normally we would have 10 columns as well to show everything inside a grid, a column for each field, a record for each row.  Now, I wanted to show only 2 columns where fields 1 to 5 will all be cramped inside Column1 and the rest on Column2.  Here is how to do it.

By default, a grid will bind itself to the current active table/cursor and will follow the field arrangement like in the above fld1, fld2.....etc.  Ignore the sequence of the fields because it will be useless now. 

Tuesday, March 20, 2012

Controlling the Panel from Within - Part II

Last time I created a blog called 'Controlling the Panel from Within' which I posted in Weblogs. http://weblogs.foxite.com/sandstorm36/2009/05/07/controlling-the-panels-from-within/

While I showed there how we can do that, it is limited to controlling just the main applet.  It do not show how we can dig down from within that applet.  This is actually supposed to be titled 'Drilling Down an Applet' but readers may say, what the heck is that?  So I instead named this as above.

On my first blog, I showed the way to gather all applets into a form and allows user to call those applets from that listbox using ShellExecute().  Here we will use RUNDLL32 instead.  While the same can only open the main applet again, we can employ scripting here to drill down further to objects inside that applet.

Monday, February 20, 2012

ssExcelPivot class


Summary of what this class can do:

  • Will create a pivot report inside excel or as html for you without needing much effort on your part.  You don't need to know automation nor pivoting to create wonderful reports
  • Gives you possible 84 report appearances on pivot report alone.
  • Gives you possible 84 report appearances on non-pivot report (looks differ than the pivot report output)
  • Allows user interaction or not
  • All you need is just a recordsource (cursor or table) with all the fields you need, declare values of some properties of the class (or not) and you are on the go.  No fuzz, no cuzz, straight mouth approach of report generation.
Properties that can be set to give the report its initial (default) look:


This one is a must:
  • _recordsource- specifies the record source which maybe a cursor or a table. 
 The rest are optional:

Why Append/Import From an .xlsx fails?


We do know that since Office 2003, VFP pose no problem importing from an .xls or any of its other formats; then came Office 2007 introducing with it an .xlsx format and suddenly VFP can no longer "directly" append nor import from it.  A lot has been baffled by this and maybe have thought 'hey, VFP is really dying!'.    So is it really VFP's incompetence or not?  Let us find out.

One solution I proposed to tackle that problem of importing/appending from an .xlsx file is via automation as I have shown in these blogs:

a. Appending/Importing from Excel 2007's xlsx via automation:
 http://weblogs.foxite.com/sandstorm36/archive/2009/11/20/9387.aspx

b.  Importing from an xlsx file via automation - Part II:
 http://sandstorm36.blogspot.com/2011/11/importing-from-xlsx-file-via-automation.html

The trick I used there is to save the excel file on a lower version format and I advice .xl5 format for that.

However, though I have shown the automation ways on those blogs, we haven't tackled exactly "why" appending/importing from an xlsx format is failing.  And this blog is meant to shed some light onto that.

With Office 2003 and lower versions, when we open an excel file, we are dealing with only a "single" file.  With the advent of Office 2007 however, along comes a new format called xlsx.  Why the extra x at the end?  Because that extra x at the end actually signifies the new format which is 'xml'.

With .xlsx, we are no longer dealing with a single file but "several" xml files.  An .xlsx actually is a compressed folder with several sub-folders and several xml files.  If you want to study it, here is what you should do:

a.  Create a copy of one of your xlsx files. 
b.  Rename the copy to any name you want but rename the extension as well from .xlsx to .zip
c.  Open or Extract
d.  Analyze the contents



Here is how it will look like:

VFP has no fault at all why it can no longer append nor import directly from an .xlsx file.  My automation approach works because what it does is like fusing all the pieces of a broken glass to make it as a whole again, which is what VFP is designed to recognize in the first place. 

So is VFP the one at fault on failure to append/import from an .xlsx file?  Now you know better!


Cheers!



Friday, February 10, 2012

ssPolyClock - a 100% VFP clock widget

Update: February 13, 2012

5 new skins for this class. Skins can be cycled via clicking on the arrows on the lower left of the clock.  Advantages of this class over activex ones are:
  • Works properly with Anchor.  Unlike activex where anchoring pose a little problem (if you don't know how to work around it), this one does not pose any problem with Anchor.
  • Can be skinned on the ply (6 skins to choose from)
  • Can be moved around your form (optional)
  • Can hide digital clock portion (optional)
Here are all skins for now:



That is all for now!

 ======

Originally, I gave you a tutorial under weblogs about adding a Graphical Analog Clock ( http://weblogs.foxite.com/sandstorm36/2008/05/27/graphical-analog-clock/ ) in your form.  That one utilizes a ShockWave Flash animation and is done using SwissMax.

The idea of that clock, as I have said there, plus the way to use it in our form comes from my cousin Glen Villar, my protegee and a proud member of Foxite forum.  Since ssClasses are becoming famous and I was not making any more clock widget, he volunteered to include his PolyClock class among my ssClasses objects and requested that I try to make it look better.  Well here it is now, Glen's PolyClock into ssClasses.

It is called ssPolyClock because the objects here are pure shapes with manipulated polypoints with the exception of the background image which is embedded now into the class.  And I salute my cousin Glen for thinking about this, the first ever (as far as I know) graphical analog clock that is 100% VFP in objects and codes.


Shown above is another widget called ssCalendar under old _Sandstorm36 class.  Do you like it?


P.S.  It appears that Glen is not the original who thought of something like this, LOL!  Let us give a proper credit to Luis Maria Guayan (co-creator of FoxBarCode) who published an Analog Clock running on Polypoints in 2005 (Wow!):  http://www.portalfox.com/article.php?sid=1887


Monday, February 6, 2012

ssToExcel2

Enhancements (February 16, 2012):

Created two new sections called fonts and colors.  This is where you can control further the fonts (in addition to _ExtraFonts which will be the default font for columns if used) and colors of data cells:




 

Enhancements (February 13, 2012):

Added new properties to make it more flexible.  Here is a complete listing of those plus showing below is how to instruct ssToExcel2 on its click event:

Sample Click Event:

CREATE CURSOR junk (fld1 c(30), fld2 d, fld3 I, fld4 i)
INSERT INTO junk VALUES ('Jun Tangunan',DATE(),40,26)
INSERT INTO junk VALUES ('Sandstorm36',DATE()-5,40,26)
INSERT INTO junk VALUES ('Celyn Tangunan',DATE()+8,27,17)

* Change the field name to proper ones using AS clause.  To create more than one word in excel, use underscore