I don't know what prompted me to create a new container class which will replace ssContainer but that is what has happened. Maybe because of the curvature feature that was requested to me to by MK Sharma last time or maybe some other things. But the outcome I deem is nice. Take a look at how ssClasses affects the appearance of a form. Shown below is a form with standard objects only (with the exception of Ony Too's datepicker class):
And this is how it looks like with just the ssTitlebar class and the new ssContainer2 class:
This is dedicated in assisting others on developing and non-developing matters. It is also the official home of ssUltimate Library.
Thursday, September 29, 2011
Friday, September 23, 2011
Glass PageFrame (sort of)
With the coming of Windows 7 glass
style, everybody seems to want to have its effect incorporated into our
projects. Though this is really not Glassy as it is more
transparent, I still decided to call this Glass PageFrame as I know it
will attract more attention (Nasty reasoning), LOL!
This is very simple to implement but the impact is cool.
Ready? Then follow these 7 steps (some are optional):
1. Initially hide the tabs of the PageFrame
2. Themes property should be set to .F.
3. Change the tabs’ Backstyle to 0 (transparent). Note that while tabs are shown (default), VFP will not allow you to change the backstyle that is why we need to hide those first.
4. Add a container inside pages so the inner part of the pageframe will appear normal and only those outside of that container will appear transparent
5. Optionally, you can change the style of the container into 3 (Themed) which adds effect to the Glass-like interface you wanted to achieve
6. Change the forecolor of the tabs to mix properly with the background
7. Finally, show the tabs again.
And that is it. Told you it is very simple. Enjoy!
And here are the codes:
Source code
This is very simple to implement but the impact is cool.
Ready? Then follow these 7 steps (some are optional):
1. Initially hide the tabs of the PageFrame
2. Themes property should be set to .F.
3. Change the tabs’ Backstyle to 0 (transparent). Note that while tabs are shown (default), VFP will not allow you to change the backstyle that is why we need to hide those first.
4. Add a container inside pages so the inner part of the pageframe will appear normal and only those outside of that container will appear transparent
5. Optionally, you can change the style of the container into 3 (Themed) which adds effect to the Glass-like interface you wanted to achieve
6. Change the forecolor of the tabs to mix properly with the background
7. Finally, show the tabs again.
And that is it. Told you it is very simple. Enjoy!
And here are the codes:
Source code
Local oForm As Form
oForm = Createobject('GlassPage')
oForm.Show(1)
Return
Define Class GlassPage As Form
AutoCenter = .T.
Height = 370
Width = 341
Caption = "Glass PageFrame"
Picture = Addbs(Getenv("WinDir"))+"Prairie Wind.bmp"
Add Object label1 As Label With;
left = 24,;
Top = 23,;
Width = 300,;
WordWrap = .T.,;
AutoSize = .T.,;
BackStyle = 0,;
FontSize = 8,;
FontName = "Tahoma",;
ForeColor = RGB(255,255,255),;
Caption = "This simple demonstration will show how to make a PageFrame "+;
"tranparent. Seems nice to combine with Windows 7 Glass Effect. "+;
CHR(13)+CHR(10)+CHR(13)+CHR(10)+;
"Additional Effect has been implemented on the container inside the pageframe "+;
"via Style property (as shown on page1)."
Add Object GlassPage As PageFrame With ;
Left = 22, Top = 120, Width = 295, Height = 200, PageCount = 2,;
Themes = .F., Tabs = .F., TabStyle = 1
ADD OBJECT command1 as commandbutton WITH ;
left = 22, top = 330, Caption = "\<Change Background", AutoSize = .T.
Procedure Load
Endproc
Procedure Init
With Thisform.GlassPage.Page1
.BackStyle = 0
.Caption = "Master"
.ForeColor = Rgb(255,255,0)
.AddObject("Cont1","Container")
With .Cont1
.Top = 10
.Left = 10
.Visible = .T.
.BackStyle = 1
.Width = 270
.Height = 145
.SpecialEffect = 1
.Style = 3
Endwith
Endwith
With Thisform.GlassPage.Page2
.BackStyle = 0
.Caption = "Transactions"
.ForeColor = Rgb(255,255,0)
.AddObject("Cont1","Container")
With .Cont1
.Top = 10
.Left = 10
.Visible = .T.
.BackStyle = 1
.Width = 270
.Height = 145
.SpecialEffect = 1
.BackColor = RGB(202,202,255)
Endwith
Endwith
Thisform.GlassPage.Tabs=.T.
ENDPROC
PROCEDURE Command1.Click
thisform.Picture = GETPICT()
ENDPROC
Enddefine
NOFILTER Clause on an SQL SELECT, when to use?
I believe some VFP developers are still wondering what this clause is all about so I will try to explain things based on my perspective. NOFILTER clause is given to us to ensure that a true cursor and not just a filtered result of the source table (FROM) is created.
When is it needed? The basic answer is if you are performing an SQL SELECT ... FROM .. a single table with no joins whatsoever and no extra new field created. Without adding the NOFILTER clause, what will happen is you will only have a filtered result of the source single table. That you are still working on the same table but just a filtered result.
Whereas what most of us needed is a true cursor or something that is independent and separate from the source table.
But is that clause really needed in ALL SQL SELECT commands? The answer is yes and no!
Yes - if you are not familiar when it is needed, then to be safe put NOFILTER clause on every SQL SELECTs.
No - If you already knew (which I hope this post can assist you in learning) where it is needed or not as there are conditions where NOFILTER will be automatic, or to rephrase, a true cursor will be created even without us placing that clause and these are:
Here is another thing you need to remember. When performing another SQL SELECT ... FROM (a cursor), then NOFILTER becomes mandatory on first cursor.
Without the NOFILTER clause above, this 2nd SQL SELECT will fail:
Closing Words:
We add NOFILTER clause to instruct VFP to create a true cursor or a cursor that is separate and different than the source table. But the risk of having a filtered result only if records comes just from a single source table with no JOINs whatsoever. The moment you combine fields from different tables, that risk goes away. The moment you created something new to the existing fields like changing its field type via CAST(), then it goes away. Or perform aggregate functions because that will create a new field as well.
However, since most of us needs a true cursor, then even when some of the conditions I mentioned above will automatically result to VFP creating a true cursor, if you are still getting confused when it is needed or not, then just issue NOFILTER clause.
When is it needed? The basic answer is if you are performing an SQL SELECT ... FROM .. a single table with no joins whatsoever and no extra new field created. Without adding the NOFILTER clause, what will happen is you will only have a filtered result of the source single table. That you are still working on the same table but just a filtered result.
Whereas what most of us needed is a true cursor or something that is independent and separate from the source table.
But is that clause really needed in ALL SQL SELECT commands? The answer is yes and no!
Yes - if you are not familiar when it is needed, then to be safe put NOFILTER clause on every SQL SELECTs.
No - If you already knew (which I hope this post can assist you in learning) where it is needed or not as there are conditions where NOFILTER will be automatic, or to rephrase, a true cursor will be created even without us placing that clause and these are:
- If READWRITE clause is used
- If SQL SELECT involves two or more tables
- When GROUP BY clause is used
- When calculated columns are done like DISTINCT, TOP, PERCENT
- When Aggregate functions are used such as AVG(), CNT(), MAX(), MIN() or SUM().
- When you change a field type into something else via CAST()
- When a result of SQL SELECT does not result to fully optimizable cursor (like when a new field is created with something like this):
Mandatory NOFILTER
SELECT * FROM Table1 INTO CURSOR Cursor1 NOFILTER
SELECT * FROM Cursor1 INTO CURSOR Cursor2 NOFILTER
We add NOFILTER clause to instruct VFP to create a true cursor or a cursor that is separate and different than the source table. But the risk of having a filtered result only if records comes just from a single source table with no JOINs whatsoever. The moment you combine fields from different tables, that risk goes away. The moment you created something new to the existing fields like changing its field type via CAST(), then it goes away. Or perform aggregate functions because that will create a new field as well.
However, since most of us needs a true cursor, then even when some of the conditions I mentioned above will automatically result to VFP creating a true cursor, if you are still getting confused when it is needed or not, then just issue NOFILTER clause.
Learning mdot Usage
Seeing that there are still a lot of VFP users confused with the usage of MDOT (m. prefix), I decided to create simple explanations regarding this.
When mdot usage is mentioned, a lot of developers argue about whether it is really needed or not. And as usual with developing there are a lot of ways to do things (skin a cat as Mike Yearwood fondly says) and so every time a thread or a post is started regarding this, it came out the argument seems to be endless.
Originally I titled this “Delving into (un)popular argument, MDOT prefix” because it is a popular argument where threads became long but some think of it as an unpopular way. LOL! Later I decided to simply title it “Learning mdot Usage”.
Well I am not here to argue whether mdot is really needed or not. What I am after here is if you will decide to use this, at least you know how properly. Fair enough? Then let us go on with the topic:
Let us take a look at this equation:
WholeName = FirstName + ” ” + LastName
When mdot usage is mentioned, a lot of developers argue about whether it is really needed or not. And as usual with developing there are a lot of ways to do things (skin a cat as Mike Yearwood fondly says) and so every time a thread or a post is started regarding this, it came out the argument seems to be endless.
Originally I titled this “Delving into (un)popular argument, MDOT prefix” because it is a popular argument where threads became long but some think of it as an unpopular way. LOL! Later I decided to simply title it “Learning mdot Usage”.
Well I am not here to argue whether mdot is really needed or not. What I am after here is if you will decide to use this, at least you know how properly. Fair enough? Then let us go on with the topic:
Let us take a look at this equation:
WholeName = FirstName + ” ” + LastName
Wednesday, September 14, 2011
Get a document's paper size via automation in VFP
Here is a question inside Foxite that took my interest:
how to make code this in vfp, to get the Paper's Size of the document file in (MS OFFICE)?
So I also thought, how? And I can't think of any other way but automation. Problem though is it seems you have to recompute the page width and height before you can attain the proper result as those are computed inside Word via "InchesToPoints" and I cannot find a property to get that computed result. Solution? Try to compute it yourself. :)
Anyway, this seem to work. Maybe there is a better way than this but this is what I can think of right now:
If you think this approach will work on your side, better create a table to store the widths, heights and paper sizes; and use that table to get the appropriate document's paper size. Widths and Heights should be stored as numeric. I just want to show here how we can see things like (8.5x11 for letter) but best save those as numeric and seek those numeric values in the table itself. Also as you can see, you can determine further if the document is in landscape or portrait, i.e., if width is bigger than height, it is landscape; otherwise portrait.
And like some of my blogs, I decided to post it here so maybe some other non-members of foxite who will find this somewhat useful can maybe implement this on their side. Enjoy!
So I also thought, how? And I can't think of any other way but automation. Problem though is it seems you have to recompute the page width and height before you can attain the proper result as those are computed inside Word via "InchesToPoints" and I cannot find a property to get that computed result. Solution? Try to compute it yourself. :)
Anyway, this seem to work. Maybe there is a better way than this but this is what I can think of right now:
*******Beginning of Code
LOCAL loWord as word.application, lnHeight,
lnWidth, lcSize, lcPaperSize
loWord = CREATEOBJECT("word.application")
lcFile = GETFILE("doc,docx")
loWord.Documents.Open(m.lcFile)
lnHeight = ROUND((loWord.Selection.PageSetup.PageHeight/72.0231),2)
lnWidth = ROUND((loWord.Selection.PageSetup.PageWidth/71.98911),2)
lcSize = TRANSFORM(m.lnWidth)+"x"+TRANSFORM(m.lnHeight)
DO CASE
CASE m.lcSize = "8.50x11" OR m.lcSize = "11x8.50"
lcPaperSize = "Letter"
CASE m.lcSize = "8.50x14" OR m.lcSize = "14x8.50"
lcPaperSize = "Legal"
CASE m.lcSize = "11x16.99" OR m.lcSize = "16.99x11"
lcPaperSize = "Tabloid"
* and so on......
OTHERWISE
lcPaperSize = "Unrecognized Size"
ENDCASE
MESSAGEBOX(m.lcPaperSize)
loWord.Quit
******* End of Code
If you think this approach will work on your side, better create a table to store the widths, heights and paper sizes; and use that table to get the appropriate document's paper size. Widths and Heights should be stored as numeric. I just want to show here how we can see things like (8.5x11 for letter) but best save those as numeric and seek those numeric values in the table itself. Also as you can see, you can determine further if the document is in landscape or portrait, i.e., if width is bigger than height, it is landscape; otherwise portrait.
And like some of my blogs, I decided to post it here so maybe some other non-members of foxite who will find this somewhat useful can maybe implement this on their side. Enjoy!
Friday, July 15, 2011
ssGridSorter Class
I was creating a lot of grids on my end and as I am rushing to develop a lot of module for my BizCore ERP software I decided to temporarily leave minor features like grids having sorting capability until.... one of my users requested that feature to me.
And so I thought that maybe I can create a small class where all I need to do is drag it in a form and bind the grid(s) that will be given sorting capability. Originally, I wanted it to only have sorting capabilities but I saw that others who have that feature have down and up arrow representing the order. So I added that.
It was okay for my needs where a grid's recordsource is coming from a cursor or table. I was about to share this when I suddenly thought of making the up and down arrows part of the class. Meaning there is no need for me to attach images on the sample I will give here. Finally I found the way to do that and so here now is ssGridSorter for your usage as well.
Using this class is as simple as 1...2...
1. Drag the class to your form
2. On its INIT event, place your settings:
this._Settings( < grid name >, < cursor name > )
Sample:
this._Settings("Grid1","Junk")
As simple as that!
For the current listing of ssClasses, click this link: http://sandstorm36.blogspot.com/2011/10/ssclasses-components-list.html
Tuesday, June 14, 2011
ssDropCalc - a dropdown calculator class
Update November 7, 2011:
Changed the buttons from native VFP to my own design. Now this looks better in appearance. These buttons also changes color on mouse enter event.
Added the ability to choose between normal appearance and semi-transparent via _ltransparent property (Default value is .F.). Just turn it into .T. via PEM window and you will have something like this:
Removed also some properties that I don't need anymore like nThemes, nColor, etc.
============
Release 2 (June 16, 2011):

a. Added switching capability between showing formula (Ony Too's suggestion) or values on the dropdown calculator class. Formulas will be enclosed with the necessary parenthesis. Default is to show formula instead of values. It can be toggled by clicking on the labels F (Formula) or V (Values) on the face of ssdropcalc.
b. Fixed problem on positioning (done applying Ony Too's approach on his popup calendar using WinAPI, many thanks!). This also fixed problem when parent form is top level.
c. Added formula error detection (as mentioned by Tushar). When an error is detected, a message "Formula Error" will appear on the upper right corner of the formula/value box and the class will attempt to fix it for you by either removing the faulty entry or infusing the proper operator before your value.
d. Backspace will smartly detect and remove extra open and close parenthesis. So you can change your formula anytime except when the dropdown is deactivated (area outside the dropdown calculator is clicked or you have pressed spacebar) where the result will be transferred to the textbox class. From the value there, you can start a new formula or computation.
e. Clicking on an operator will smartly detect previous operators and replace those if necessary
f. Added Copy to Clipboard button. This is not that much necessary but if you want to transfer your formula to excel for quick evaluation of the result, you can use this. This will work even if dropdown is set to show values.
g. Removed SET CLASSLIB hardcoding inside the class (as mentioned by Yousfi). This actually should not be there in the final distribution
Release 1 (Jun 14, 2011):
Last Friday, alternating between checking payroll documents and waiting for more to be submitted to me, I decided to post advances given to staff on my advances module. This advances is based on a single invoice related to several employees so I have to manually compute each individual share (a simple average calculation of Net Purchases divided by number of staff for that invoice). And for that I use Excel if it is already open or windows calculator.
Then a thought hit me. Why not create a simple dropdown calculator for numeric textboxes so I don't need to invoke anymore those outside apps if and when a manual calculation is needed? And when there is no payroll document yet (as they submit to me one at a time payroll documents of a specific project for cross-checking and approval), I started and continued working on that idea. The basic things are set but it still lack some more features so I continued playing with it this weekend.
Finally, I think this is ready to be shared. And because I love having the ability to somewhat change the appearance of my classes, here are the things it can do aside from of course basic mathematical calculations:
a. The ability to set number of decimals. On class init:
This._nDecimal = 4 (default is 2)
b. The ability to remove Themes. On class init:
This._lTheme = .F. (default is .T.)
c. The ability to change calculator background color. On class init:
this._color = rgb(255,255,255)
d. The ability to remove shadow. On class init:
This._lShadow = .F. (default is .T.)
I thought of applying _settings() style again but then decided against it on this particular class.
Very important!!! When you place something on Class Init event, after any or all of the above properties, put:
DODEFAULT()
Some more things:
You can either click on calculator icon or press spacebar when the numeric textbox is in focus to show the dropdown calculator. Pressing spacebar again while dropdown is shown will hide it (similar to combobox style = 2 feature).
When dropdown is shown, you can either click on buttons or use your keyboard for calculation. For numbers and operators, just press the corresponding keys for those. Additional keys are:
Esc = clear Button
Backspace = BS button
= key = Equals button
Spacebar = Hides dropdown calculator (you can do this also via clicking outside of the calculator area using mouse)
R = Memory Recall (MR Button)
C = Clear Memory (MC Button)
P = Memory Plus (M+ Button)
M = Memory Minus (M- Button)
You can continue with the current value meaning after a result has been transferred to the numeric textbox and you already have hidden the dropdown calculator, you can invoke it again and continue calculation from that number. If you want to start anew, just press Esc or hit the Clear button.
Getting its value is just similar to an ordinary textbox:
lnValue = thisform.ssdropcal1.value
You can use this class in place of native textboxes with numeric values to give more "cool effect" to your apps. And like all of my ssclasses (except with images), this is done in 100% native vfp objects and codes fashion.
Subscribe to:
Posts (Atom)




