Quantcast
Channel: Sandstorm's Blog (Home of ssUltimate Library)
Viewing all 160 articles
Browse latest View live

xBox, How To..

$
0
0
xBox' Usage, Explained Further

xBox is among my most complicated classes to date due to the fact that I have given this three (3) possible usage.  And a new user is getting confused with it that I decided to rush here explanations on its features as I believe not everyone can easily see, despite my examples shown in codes on the sample form, how the class' different features can be utilized to each developer's advantage.

Take a look at this image below where the class is using the Combo Feature (QuickFill + Popup Grid)


But then, the class is designed to be used as just plain quickfill, plain popup/dropdown grid or that combo.  Explanations follow:


=====

Plain QuickFill/AutoComplete Feature - is the above image without the popup/dropdown grid.  This is where the class gives suggestions on the next possible match based on what you have typed so far by highlighting that suggestion

Quickfill means it will fill the possible remaining values for you.  Like in this image above, I just typed A and it results to that.  Where the highlighted text is the suggestion based on nearest possible matches.

Quickfill will be in place and fire if you use these properties:
  • AutoCompSource = The source table/cursor for searching autocomplete/quickfill
  • AutoCompField = the source field of the source table/cursor.  This is what gets returned to the class' Value property
  • ExtraField = is the field of the source table/cursor of secondary possible return value (aside from AutoCompField)
  • ExtraValue = mandates the type of value to be returned (is it character, numeric, etc).  If it is numeric, you have to put 0 there.  Later I will adjust the class to make this automatic dependent on the type of ExtraField field


One thing you need to realize with Quickfill in place is the class will utilize either SEEK() or LOCATE basing whether AutoCompField is indexed or not.  That means your record pointer on the underlying source table changes each time as you type as it will position that to the nearest match.

Another is that with Quickfill in place, the class manipulates the mouse insertion point via SelStart and the way to clear up the previous entry is via double-clicking on it or calling its _Clear() method.

Again, Plain QuickFill does not have the popup grid.

====

Plain Popup Grid(xBoxGrid subclass) feature is again that above image without the highlighted suggestions.  The class performs less manipulations that way and is good for fast searching. It does not manipulate SelStart so it is just like an ordinary textbox with that extra dropdown near matches inside a grid.  For you to use this feature, you have to do it in codes.   xBoxGrid is affected by 3 events, i.e.,

Init - Where we can set the popup grid, you need to include DODEFAULT() then set the grid via calling _SetGrid() method.  Let us take a look into these codes I have responsible for generating the above image:

* Init     
DODEFAULT()

This._SetGrid('Asset#-60|Registration-60|Asset Type-250',2,,150,2,'Calibri',10,.T.)

Lparameters cColumnList, nScrollBar, nWidth, nHeight, nGridLines, cFontName, nFontSize, lNoTitleBar

Where:

cColumnList - is for the column header captions and width.  It can be broken into 2 things:

  • Pipe Symbol - To break the Column Header Captions, e.g. Asset|Registration|Asset Type
  • Dash Symbol - To instruct by code the width of the column, e.g., Asset-60 or Column 1's width is 60.  Default is 80.

While these will be bound by the class later to the fields of the resultant cursor based on the field sequence on SQL SELECT which is done in InteractiveChange event (explained later), you have to realize what you will type here is for the columns' headers only and column widths.  And so you can put space if you like such as in Asset Type.

nScrollBar - is for scrollbar property of grid or 2 in this case or just vertical scroll

nWidth - is Grid Width or in example, 580

nHeight - is Grid Max Height or is 200 here.  This is max height I set on the above image but is not fixed as popup grid will auto-adjust to smaller based on number of results on the cursor.

nGridLines - is Grid Lines or 2 in this case

cFontName - The font to be used on the grid

nFontSize - The size of the font to be used on the grid

and finally lnoTitleBar - To remove or retain the titlebar of the popup form

Do not get confused with _SetGrid() method.  It is just meant to set up the appearance of the dropdown grid.  Readying it for the resultant cursor later via _SearchGrid() method.

Actual cursor creation based on what has been typed so far is done here:

* InteractiveChange    
Local lcSQL, lcRetVal, lcAssetNo
TEXT TO lcSQL NOSHOW PRETEXT 12
Select t1.assetno, t1.regno, t2.xDescript, t1.assetpk, t1.assignfk From assets t1 ;
      LEFT Outer Join adescript t2;
      ON t2.descpk  = t1.descfk;
      where [MySearch] $ t1.assetno OR [MySearch] $ t1.regno OR [MySearch] $ t2.xdescript;
      order By 1 ;
      into Cursor junkasset nofilter
ENDTEXT    
lcSQL = STRTRAN(m.lcSQL,';','')

This._searchgrid(m.lcSQL,'junkasset.assetno','junkasset.assetpk')

While I do it that way, you guys can put the SQL SELECT straight onto the first parameter ignoring local variable usage, your choice.  Only that the SQL SELECT needs to be of character type, meaning you have to enclose the whole SQL SELECT with quote, double-quote or bracket.  For readability's sake, I myself prefer the above local variable approach.

The above means we are asking it to fire _SearchGrid() method and perform a query (m.lcSQL) on every changes we do (keystrokes) on its textbox section or to search and perform filtering sort of as we type on the resultant cursor.  It only has three (3) parameters:

Lparameters cSQL, vValue, vExtraValue

Where:

cSQL = is the SQL SELECT we want.  In the example above, it is based on local Variable lcSQL

vValue = is the primary value which is what gets returned to the textbox portion. It is a field of your choosing in the resultant cursor. Above, it means we want to return the assetno field record from junkasset cursor

vExtraValue = is the secondary "invisible" value that the class can return, in the example above, assetpk which is an AutoInc Primary Key on my junkasset cursor


Navigation:

Once the popup grid appears, you can easily navigate onto that either via clicking onto it or pressing the down arrow.  Any of those two will set the focus onto the popup grid.

Once the popup grid receives focus, it will automatically return the value of the rows in highlight or ActiveRow back to the textbox section.  To finalize selection is either:

  1. Click outside of the popup grid
  2. Double-click on the selected row
  3. Press Enter key on the active row 


Another Event that can be used here is ProgrammaticChange, where I do manipulations on the other objects of the form based on the return value from the popup grid selection.  Its usage is something like this:

* ProgrammaticChange   
With Thisform
      ._driverpk = junkasset.assignfk
      ._assetpk = This.ExtraValue
      ._assetno = Alltrim(This.Value)
      ._showimage()

Endwith

Where I transferred the needed values on my form properties so those will be visible to the entire form and call a method that shows the image of the asset plus other things.

ProgrammaticChange is where we can implement immediate actions based on the activerow of the popup grid as we navigate to those records either via arrow keys or mouse click.  So as we move through the records of that popup grid, we can update other objects in the form as well

====

Combo Usage (Both QuickFill and Popup Grid in place)

The image above is the combo approach.  While this works good on my end, as I have said, I am not that confident yet that this will give you what you want.  So to avoid unknown problem, I suggest for you not to use this yet.  Or if you want, use it and if something is wrong, inform me.

====


Things for your consideration in selecting the usage type:

Quickfill - uses an actual table or cursor and performs either SEEK() or LOCATE.  Therefore record pointer changes as we type.  It requires manipulation of mouse insertion point via SelStart and storing of what you have typed so far; that to ready it for the next entry properly, you have to either double-click on it for it to fire _Clear() method, or you call the _clear() method  yourself.

Plain Popup Grid - creates a cursor that is being filtered as you type based on your WHERE condtion.  [MySearch] is mandatory there as the class looks for it and replaces it with what you have typed so far in the textbox section.  It creates a cursor that gets rebuilt over and over again filtering it with your WHERE condition as you type.

Keep on checking this post as I will slowly update this with other more properties and features of the class.  This will be the help documenation on the proper usage of the class.

P.S.

A bug I realized only later is popup grid won't work with ShowWindow=2 or Desktop = .T..  Will check that one out one time.

This is it for now.  Cheers!





Going Barefoot, Health Benefits

$
0
0



Lately I observed that whenever I take a shower, while wet and I reached for the shower knob, I always receives a minor electric jolt, not too much but still disturbing.  When I reported that to my wife, she said she never experienced such, so it appears that is related in my body system and not with the circuitry of the house.

So I started wearing rubber slippers while taking a shower and it worked good for quite a while. Until this morning, I got a much stronger shock when I reached again for the knob to turn the water off, now even while wearing a rubber slipper during the shower.

So immediately upon arriving here in the office, I googled outright what could be causing this severe static electricity problem I have and the possible remedies, if any; as I am sure something is wrong with my current body metabolism.

And that is why I am making this blog to share what I have found out

Electricity Build-Up

As we know, our body is capable of generating electricity and storing those up.  There are numerous reasons for that but the amount of static electricity each of us can store varies on our own metabolism.  Some are very susceptible to it, others not much.  It appears that the more acidic our body is, the greater it can absorb and store electricity.  Or if our blood is thicker, then the same goes.


Lifestyle

With our modern lifestyle where we surround ourselves with modern technologies that requires electricity (and spreads discharge around us invisibly), then we are more susceptible to this static electricity build-up.  For instance, in the office I am surrounded by aircon, laptop, monitor, cpus, cctvs, ups, etc.  In the house, it is the same.  In-between, I am inside a car with all the glory of the air-con it provides.  Plus now in this era, my mobile phone is constantly near my body.

Impact on Health

These change in lifestyle is not mainly focused on the static electricity build-up alone inside our body.  This has also adverse effects on our internal organs and our well being.  We feel more stressed, we are more prone to sleep deprivation, our body is aging faster, our metabolism is more weaker, and the lot.

Going back to the roots

Our fore-parents are much stronger than us.  That is a fact.  But that is because their lifestyle is much more different than us now.

However, the reason for this post is to make readers aware that while we are on these era of modernization, it won't hurt to learn to do some basic things our fore-parents do.  And that is to go barefoot, once in a while

Earthing/Grounding

Like mentioned, we now constantly wore slippers or shoes and the soles of our feet now almost never come in contact with the soil/ground.  And this is actually one of the main reasons, as suggested by several articles, that degrades our health.

For instance, we are now more Electron Deficient than our fore-parents are. Simply for a sole fact that we seldom get in contact directly with the ground now (Eww!!! It is dirty!).

Borrowing writings from one of the links I will share below:

Physical contact with the Earth or lack thereof, affects inflammation, a causal influence in most common diseases. Inflammation has been linked to rheumatoid arthritis, diabetes, asthma, multiple sclerosis, lupus, autism, atherosclerosis, Alzheimer’s, bowel disorders, osteoporosis and cancer.
“The growth in chronic illnesses since the early 1960s is likely related to the fact that we have become increasingly disconnected from the vital life force of the planet. Rubber soled shoes, indoor lifestyles without any Earth contact, and living in multi-storey, ungrounded buildings, where the voltage on a person rises the higher in the building one resides, is where we are beginning to find the answers.”

Ultimate Antioxidant and Anti-Inflammatory
Grounding or Earthing is defined as placing one’s bare feet on the ground whether it be dirt, grass, sand or concrete (especially when humid or wet). When you ground to the electron-enriched earth, an improved balance of the sympathetic and parasympathetic nervous system occurs.
It appears our body's immune system functions optimally when we are in contact with earth.  As earth offers an abundant supply of free electrons, then going barefoot and in contact with the ground is a healthier way of living, even if we only do this once in a while.

Aside from receiving these much needed electrons, going barefoot is a fast and healthy way of discharging the stored static electricity out of our body.

Going Barefoot myself

And I tried it a while ago myself.  Lately I am constantly getting shocked as mentioned during showering, have been feeling quite not good myself, am having lack of proper sleep, and an alarming (not quite) prolonged heartburn (while a sign of heart attack, mostly caused only by too much acid in the stomach).  And as I have mentioned, too much acidity increases the chance of storing more static electricity within one's body.

So I said to myself, before I decided to write this article, I won't loose anything to try it myself.  So I went out of the office, looked for a good place to go barefoot for a few minutes (clean soil or gravel), found one under a tree, removed my socks and shoes, and went barefoot.  I was trying to discharge said static electricity out of my system and is trying to see what receiving these needed electrons can do to my body.

After around 5 minutes of standing, I sat down with my bare feet on the gravel and soil and mused to myself, let's speed up the process by touching the tree as well with my other hand (while I am still reading other articles about this).



And after another 5 minutes or more, I did felt  getting better.  The heartburn slowly goes away (but it came back again now while I was in front of this laptop), I felt refreshed, my head's fog seems to have slowly lifted, my eyes started to get sharper, and I felt very very relaxed.

Psychological?  Maybe, maybe not.  But then my belief is more into the scientific explanations.  I was able to discharge my stored static electricity (maybe not all) and I was able to receive electrons my body has been lacking, plus I also received a doze of negative ions (research for that as well); being I was in contact with mother earth and I am under the cool shade of that tree.

Epilogue:

We are always cocooned into our modern lifestyle constantly surrounding ourselves with various gadgets that we forget to go out in the open once in a while.

So the reason for this article is to advice everyone to at least go out in the open, say weekend, do some barbecues outside in your lawn, give some time to sit under the trees, to read or simply gaze at the beauty of the nature, breathe the free air and expose ourselves with what nature can give.  And yes, go barefoot to directly interact with mother earth, even for a brief period of time.

Update:

I have been doing the morning routine, during my coffee break, for 3 days now where I go to my secluded place under the tree and gone primitive without any foot apparel, just for 5 to 10 minutes.  My bare feet on the gravel and sand.  And what is noticeable is while I am doing that in the early mornings, at night I can still feel my blood in my feet coursing through the veins.  It is something you feel after you got a foot massage where the veins seems to be very active.  Or when you go to the beach barefooted and came back at night to sleep.  Have you experienced the same, if you did tried this?

Links/Sources:


Encapsulating Popup Calls Within Forms

$
0
0

One of my dissatisfaction when creating a popup shortcut via Define Popup and later On Selection Popup or On Selection Bar commands is its insistence of not accepting Thisform reference.  Something like this:

Define Popup PopFaves From Mrow(),Mcol() Margin SHORTCUT
Define Bar 1 Of PopFaves Prompt "Add to My Favorite"
Define Bar 2 Of PopFaves Prompt "Remove from My Favorite"
Define Bar 3 Of PopFaves Prompt "Show My Favorite"
On Selection Popup PopFaves Thisform._SubFave(Bar(), m.lcCaption)
Activate Popup PopFaves




Where _SubFave is a form method I created to receive parameters and handle calls of current selection.  And it just darn won't accept Thisform reference there!

And so on all popups I have, I have to use an outside prg for that with something like this:

* Calling as Procedure
Define Popup PopFaves From Mrow(),Mcol() Margin SHORTCUT
Define Bar 1 Of PopFaves Prompt "Add to My Favorite"
Define Bar 2 Of PopFaves Prompt "Remove from My Favorite"
Define Bar 3 Of PopFaves Prompt "Show My Favorite"
On Selection Popup PopFaves DO SubFave with Bar(), m.lcCaption  
Activate Popup PopFaves

or

* Calling as Function
Define Popup PopFaves From Mrow(),Mcol() Margin SHORTCUT
Define Bar 1 Of PopFaves Prompt "Add to My Favorite"
Define Bar 2 Of PopFaves Prompt "Remove from My Favorite"
Define Bar 3 Of PopFaves Prompt "Show My Favorite"
On Selection Popup PopFaves SubFave(Bar(), m.lcCaption) 
Activate Popup PopFaves


And then later finds a way to bring back focus from that Function/Procedure to the active form's methods because like I said I want to encapsulate "almost" everything to said form; which works, but not to my entire satisfaction.  However, when I need to do things, I need to do things fast and so I use the function/procedure calling way until I am free to experiment, which I do today

Playing with my popup for favorites (using right-click on treeview), through trials and errors, I found that we can do it like this:

Define Popup PopFaves From Mrow(),Mcol() Margin SHORTCUT
Define Bar 1 Of PopFaves Prompt "Add to My Favorite"
Define Bar 2 Of PopFaves Prompt "Remove from My Favorite"
Define Bar 3 Of PopFaves Prompt "Show My Favorite"
On Selection Popup PopFaves _Screen.ActiveForm._subfave(Bar(), m.lcCaption)
Activate Popup PopFaves

And it works, I can now use a form method for said popup

But then, _Screen.ActiveForm seems to still be outside of  a real encapsulation because in a way you are going out of the current form back to VFP's main screen (_screen), checking which form is currently active (current form) and then coming back inside the form to work on the form's method.  So here is a better way (for me) than that.  Put the reference to the current form in a local variable and use that variable on your need like this:

LOCAL loForm
loForm = thisform
Define Popup PopFaves From Mrow(),Mcol() Margin SHORTCUT
Define Bar 1 Of PopFaves Prompt "Add to My Favorite"
Define Bar 2 Of PopFaves Prompt "Remove from My Favorite"
Define Bar 3 Of PopFaves Prompt "Show My Favorite"
On Selection Popup PopFaves m.loForm._subfave(Bar(), m.lcCaption)
Activate Popup PopFaves

And there you have it.  A way to encapsulate the call to popups within the form itself.  Just in case you didn't know yet as well like I do before this.  Cheers!

xBox (a Textbox Control class)

$
0
0
Release 4

  • Made the appearance cleaner by imitating a plain textbox so when you resize on form during design time, you will see the borders cleanly
  • Fixed seeding initial Value via PEM
  • Added seeding via ExtraValue property which displays the correct Value counterpart  
  • Used inherent Picture property for alternate icon.  Removed icon property as that is just a waste of extra unneeded property. Although on form, when a picture for icon is selected, the icon image is shown tiled on the class
  • Added ControlSource, PasswordChar, ReadOnly, FontBold and FontItalic properties

Release 3

Color Toggling on Enabling/Disabling the class - Fixed

Seeding the class via .Value does not perform an AutoComp resulting to .ExtraValue giving a wrong result. Fixed that. However, seeding values to other xBoxes on the form with each having an AutoComp feature enabled short-circuits it; as each tries to perform an AutoComp search during when values are changed.

Solution is to ensure that only the active xBox will perform an AutoComp search. So now, you can do something like this: 

*xBox1's InterActiveChange
*  where search is made and seeding other xBoxes as we type
thisform.xBox2.Value = field2
thisform.xBox3.Value = field3
thisform.xBox4.Value = field6


And only xBox1 will perform the AutoComp search and the others will simply receive the values. Anyway, there is no need for the record pointer to change on those 3 others.

Caveat:

When seeding an xBox where you want it to perform an AutoComp search, then you have to ensure it is the active object in the form. Something like this:

Thisform.xBox1.SetFocus
Thisform.xBox1.Value = 'Whatever'

Say like when you open another form where you want to seed an xBox some value from the calling form and later would also like to reflect the .ExtraValue back, then you have to set focus onto it before the value is seeded.

If you are not after the .ExtraValue though and is only after the .Value, then no need to SetFocus on the class.


Here is the link for the latest class and demo form: https://dl.dropboxusercontent.com/u/15025358/xbox_demo.rar

Enjoy!

Release 2:

What's new:

- Added a protected property named Release just for the sole purpose of differentiating between releases (if any more release will happen in the future)

- Added Caption property.  This is what gets shown inside the box when there is no value



















- Added markers 3 & 4 which are magnifying glasses









- Added Icon property so any of you can customize the marker.  This icon image will be prioritized by the class over the default marker, if any.  If an image to be used as marker is included in the project, then you do not need to include fullpath.  If it is not, you need to include fullpath






- Moved the hover effect from within the textbox object to the class itself.  I was thinking of creating another property to optionally disable this hover effect should the user do not want it.  But then I realized all you need to do to disable this is to ensure that BorderEnter and BorderLeave are of the same RGB().

- Added KeyPress Event


=====

Release 1

What is xBox?  This is a textbox with curvature effect which is a descendant of ssTextBox container class for my ssUltimate library.  Basically, this class is cleaner since I now use a control class type here as against a container class for ssTextBox.

Actually, I decided to create this new control class yesterday because of a post I saw inside Foxite about a textbox with auto-complete.  So I fooled around with codes but before being able to post a way, I found out that our good friend Vilhelm-Ion Praisach has already beaten me in posting there how it can be done.  :)

Another reason why I decided to work on this new class is because I saw that it will be faster for users of my ERP app to have something like that auto-complete instead of using a combobox.  And thus, this new class is born.

Why, you may say, instead of enhancing the old ssTextbox, I created this new one?  Because I am not overly satisfied with that old one being I designed it as a container class before.  Control classes are cleaner in a sense that objects inside won't be shown in the form.  Here are images comparing a container class and a control class when inside a form:

Container Class


 Control Class


However, its strength is also its weakness in the sense that you won't be able to directly reach the objects of the control class from within the instance of the class inside a form as those are somewhat hidden.  For reaching a control class, the developer has to create properties and methods in the class itself; which is what we have here (see new features).

Forwarded Features from ssTextBox:

  • Curvature
  • Marker (check marks)
  • Others (I forgot, just check my blog entry for that)

    New features:
    • As mentioned, being a control class type then it is cleaner
    • Added hover effect on border with curvature (although if you have my latest ssClasses as well I shared recently inside Foxite, then this is now also included there).  This is affected by .BorderEnter and .BorderLeave properties of the class, the values you need to put there are RGB() of your taste.
    • AutoComplete Feature (Optional) - If you wanted this class to perform an auto-complete, then you should use these two properties:
      • AutoCompSource - is the record source (cursor or table) subject to seeking
      • AutoCompField - is the fieldname of the recordsource where search would be performed by the class


    The class takes advantage of a structural index tag of the same name as the AutoCompField, if there is, and will use SEEK().  If the table does not have that necessary index tag, then it will switch to using LOCATE.

    • Since my goal in creating this new class is to replace some of my comboboxes for faster searching, then I have to have the Combobox' ability to return two possible values at a time.  But it is comparably easier though to return any values from any fields of the AutoCompSource with xBox via the ExtraField and ExtraValue properties. 
    Shown below is the comparison between a combobox and xBox:
      ComboboxxBox
      DisplayValueValue
      ValueExtraValue
      How come I have not swapped the above?  That is because in combobox, no matter where you get the value, what will be shown on the object is always the DisplayValue.  So in the case of xBox, that is the same.  
      In combobox, value can come from any column, be it visible or not (see http://sandstorm36.blogspot.com/2012/08/combobox-tricks-part-i.html).  In xBox, ExtraValue then is the same, it can come from any other field aside from the field being displayed (Value).  This ExtraValue is dependent on the  ExtraField property of the class (see demo project).  
      • When AutoComplete feature is used, then when a match is found, it is shown on the current forecolor we set.  When a match is not found, then forecolor turns into red as an added visual indicator









      • Right-click context (just usual stuff like cut, copy, paste, select all, Clear, Undo/Redo last action; maybe I will add more in the future)
      • InteractiveChange Event is added
      • Basic properties like FontSize, FontName, ForeColor, Format, and InputMask are added.  Will add others soon but for now, those are what I basically need

      I hope that you will find this useful on your end as well.  I welcome suggestions to improve this further.  Like I said, this is created only yesterday and I have added features based only on what I need right now.  For my subscribers, then this will be part of ssUltimate library.  I will update you all soon.

      Cheers!

      Enumerate and Kill Selected Windows Processess

      $
      0
      0

      A question inside Foxite was raised yesterday requesting for a way to kill selected Windows processeses using API calls as what we normally use is the scripting way.  And googling around, there are ways shown by several developers; but none, AFAIK, that terminates successfully a process on each run/attempt.  

      My first attempt yesterday combining information I gleamed across the web from several developers were not able to close the target process on every run.  Digging further, one fault I see is my usage of GetModuleFileNameEx is failing to get a proper result thus skipping onto the next process among processes list.  

      With the belief that everything is possible given enough time and attention, when I arrived back in the office this morning, I renewed experimenting on the task; playing with different values and finally I settled with dwDesiredAccess value of 1041 here for the OpenProcess API call as this gets the proper handle necessary later on terminating my target process, though it skips some vital OS processes.

      For whatever reason, said value of 1041 also gets more result than the PROCESS_ALL_ACCESSvalue which I expected to give more result.  Maybe in the future I will play further with this, or maybe not anymore.

      I included in this function a cursor showing the remaining processes it was able to acquire showing the Process Name and ID.  This is optional as in reality we do not need this unless out of maybe a curiosity?  Here are the codes:

      KillProcessAPI('winrar.exe')

      ***********
      Procedure KillProcessAPI(cAppName)
      ***********
      Local lnLoop, lnBytesReturned, lnPID, lnPH, lcBuffer, lnSize
      * This is just so we can see the processess in task manager
      Create Cursor junk (pname c(40), pid i)
      Index On pname Tag pname

      Clear
      cAppName = Upper(Alltrim(m.cAppName))

      Declare Integer EnumProcesses In psapi.Dll ;
            String  @lpidProcess,;
            Integer cb,;
            Integer @cbNeeded

      Declare Integer OpenProcess In win32api  ;
            Integer dwDesiredAccess,;
            Integer bInheritHandle,;
            Integer dwProcessId

      Declare Integer GetModuleFileNameEx In psapi;
            INTEGER hProcess,;
            INTEGER hModule,;
            STRING ModuleName,;
            INTEGER nSize

      Declare Integer CloseHandle In win32api ;
            Integer hObject

      Declare Long GetExitCodeProcess In kernel32 Long, Long @

      Declare TerminateProcess In WIN32API ;
            INTEGER hProcess, ;
            INTEGER fuExitCode

      lnSize = 4096 * 4
      lnBytesReturned = 0
      lcBuffer = Replicate(Chr(0), m.lnSize)
      lnResult = EnumProcesses(@lcBuffer,m.lnSize,@lnBytesReturned)

      If  m.lnResult <> 0
            For lnLoop = 1 To lnBytesReturned / 4
                  lnPID = BUF2DWORD(Substr (m.lcBuffer, 4 * (m.lnLoop - 1) + 1, 4))
                  lnPH = OpenProcess(1041, 0, m.lnPID)
                  If lnPH <> 0
                        lnResult = GetModuleFileNameEx(lnPH, 0,@lcBuffer, 255)
                        lcPN = Alltrim(Upper(Justfname(Strtran(Left(m.lcBuffer, m.lnResult), "\??\", ""))))
                        If !Empty(m.lcPN)
                              Insert Into junk Values (m.lcPN,m.lnPID)
                        ENDIF
                        IF m.cAppName = m.lcPN
                              * Terminate target
                              lnExitCode = 0
                              GetExitCodeProcess(m.lnPH, @lnExitCode)
                              TerminateProcess(m.lnPH,m.lnExitCode)
                        Endif
                        CloseHandle(lnPH)
                  Endif
            Next
      Endif
      * Show the list of processes it was able to enumerate
      Browse Normal
      Clear DLLs
      Endproc

      **********
      Function BUF2DWORD(cBuffer)
      **********
      Return Asc(Substr(m.cBuffer, 1.1)) +;
            ASC(Substr(m.cBuffer, 2.1)) * 256 +;
            ASC(Substr(m.cBuffer, 3.1 )) * 65536 +;
            ASC(Substr(m.cBuffer, 4.1)) * 16777216


      Hope this helps as well! Cheers!

      ShellExecute, Force open file to non-default application

      $
      0
      0
      As most of us know, ShellExecute() is a very useful tool to open a file on its external associated application.  When you issue this command:

      Local lcFile
      lcFile = Getfile('doc,docx')
      If !Empty(m.lcFile)
            ShellExecute(0,'open',m.lcFile,'','',1)
      Endif

      Then that document file will be opened by MsWord or its counterpart like say on LibreOffice

      Or if you do:

      Local lcFile
      lcFile = Getfile('xls,xlsx')
      If !Empty(m.lcFile)
            ShellExecute(0,'open',m.lcFile,'','',1)
      Endif

      Or even:



      Local lcFile
      lcFile = Getfile('csv')
      If !Empty(m.lcFile)
            ShellExecute(0,'open',m.lcFile,'','',1)
      Endif

      Most probably, it will be opened using Excel or its counterpart; whatever is set in the registry to be the default application associated to a file.

      It also allows us to execute commands on the OS Shell such as open a folder to a specific location, prints directly a file to printer, etc.

      See this:  http://www.ml-consult.co.uk/foxst-26.htm

      In this blog though, we will focus on opening a file on an external application, but opening it not on its default associated external program, but based on our own choice.   What we will do is somewhat similar to right-clicking a file, choosing OPEN WITH, and forcefully using another program to open such file.

      Going back to the last example above, we can say open a .csv file using a notepad instead of its default Excel program.  Or a .prg that is associated with VFP, to be opened using notepad as well.

      The trick, you'll be surprised is very easy.  Okay, here we go:


      * Declare it
      Declare Integer ShellExecute In shell32.dll ;
            INTEGER hndWin, ;
            STRING cAction, ;
            STRING cFileName, ;
            STRING cParams, ;
            STRING cDir, ;
            INTEGER nShowWin

      * Open an csv forcefully using Notepad
      Local lcFile
      lcFile = Getfile('csv')
      If !Empty(m.lcFile)
            ShellExecute(0,'open','notepad.exe',["]+m.lcFile+["],'',1)
      Endif


      * Open an html forcefully using Word (normally it defaults to a browser)
      Local lcFile
      lcFile = Getfile('htm')
      If !Empty(m.lcFile)
            ShellExecute(0,'open','winword.exe',["]+m.lcFile+["],'',1)
      Endif

      I think those two examples are enough.

      Comparing the two approach side by side:

      Standard approach
      ShellExecute(0,'open',m.lcFile,'','',1)

      Alternative approach
      ShellExecute(0,'open','notepad.exe',["]+m.lcFile+["],'',1)

      Notice that in the standard approach, the file to be opened is passed as the 3rd parameter and 4th parameter being empty?  On the Alternative approach, the 3rd parameter is the application we want to open and on the 4th parameter the file we wish to open.  Also, additional double quotes are added on both ends as enclosure to ensure that it will get the full path and file name correctly even if the path and filename will include spaces inbetween.


      Cheers!

      Tick/Untick a checkbox on Grid with AllowCellSelection = .F.

      $
      0
      0
      Normally, when we want to put a checkbox on grid for the purpose of ticking and unticking it, then most probably most of you do it this way:



      • Set AllowCellSelection = .T.
      • Drill to every textbox object inside each columns and put under When method Return(.f.).  That is to prohibit the cell in getting focus


      An alternative way is to set AllowCellSelection = .F. and use grid's double-click on toggling the value of the logical field bound to that checkbox, then perform a grid refresh



      While any of the two will work, I will be showing here an alternative to that where the Grid's AllowCellSelection will still be set to .F. disallowing individual objects inside to receive a focusyet will allow you to click on the checkboxas if the checkbox can really be selected.

      The trick is really simple.  Here are the codes:

      Local oForm
      oForm=Newobject("Form1")
      oForm.Show
      Read Events
      Return

      Define Class Form1 As Form
            Height = 460
            Width = 500
            AutoCenter = .T.
            Caption = 'Ticking Checkbox on Grid with AllowSelection = .F.'
            ShowTips = .T.

            Add Object grid1 As Grid With ;
                  GridLines = 0, ;
                  Height = 400, ;
                  Left = 10, ;
                  Top = 50, ;
                  Width = 490,;
                  GridLines = 3,;
                  DeleteMark = .F.,;
                  ScrollBars = 2,;
                  ColumnCount = 3,;
                  AllowCellSelection = .F.


            Add Object label2 As Label With ;
                  top = 10,;
                  left = 15,;
                  Height = 36,;
                  caption = 'This is a simple trick on allowing the checkbox object to be ticked even though '+;
                  "the grid's AllowCellSelection is set to .F.  The trick is on MouseDown",;
                  WordWrap = .T.,;
                  Width = 570

            Procedure Load
                  Close Databases All
                  Select .F. As xSelect, cust_id, company From (Home(2)+"data\customer") Into Cursor junk Readwrite
            Endproc

            Procedure grid1.Init
            With This
                  .RecordSourceType = 1
                  .RecordSource = 'junk'
                  .Column3.Width = 360
                  With .Column1
                        .AddObject("check1","checkbox")
                        .CurrentControl = "check1"
                        .Sparse = .F.
                        .check1.Caption = ''
                        .check1.Visible = .T.
                        .check1.BackStyle=0
                        .Width = 20
                  Endwith
                  .SetAll('DynamicBackColor','IIF(xSelect,RGB(128,255,0),RGB(220,228,211))','Column')

            Endwith
            Endproc

            Procedure grid1.MouseDown
            Lparameters nButton, nShift, nXCoord, nYCoord
            Local lnWhere, lnRelRow, lnRelCol
            This.GridHitTest(m.nXCoord,m.nYCoord,@lnWhere,@lnRelRow,@lnRelCol)
            If m.lnRelCol = 1
                  Replace xSelect With !xSelect In junk
                  This.Refresh
            Endif
            Endproc

            Procedure Destroy
                  Clear Events
            Endproc

      Enddefine


      Said trick will give the grid an illusion that there are two groups, i.e., 1st is the checkbox and the 2nd is the rest of the columns.  And for those new with Grid Dynamic Properties as well, just to highlight the selected (ticked) records, I use DynamicBackColor here.

      Hope you'll find this useful! Cheers!

      TitleBarX Class

      $
      0
      0
      * Updates February 2, 2015

      Added NoMax property to hide Max Button.  This should not be confused with _noMax property which simply disables the max button

      Added NoMin property to hide Minimum Button

      Added 3 shapes at the bottom to give an illusion of a gradient bottom border.  Although GDI+X is good for gradient, I want my classes to not be dependent of an external file like an .app.  Maybe in the future I may change decision or not

      Added Form Pinning capability on Controlbox section.  When it is pinned, the pin icon will turn into red and you won't be able to move the form.  To unpin, click on it again

      Removed the date and showed instead plain time().  Made it bigger

      Added _shade method.  That is what you can use to get a different shade of the current color you  pick for other objects in the form (using _SwapColor Method).  So now you can implement color themes with variying shades not only on the class itself but on any objects you wish.  Here is how it looks like







      Removed (in the meantime) coloring of controlbox.  I retained the blue and red

      If you have any ideas on what objects we can add to this class, then don't hesitate to suggest.  Future plan is to add a date picker on it and to return its date value.  Besides that, right now I cannot think of anything.  Oh yes, like one of my title bar classes, I can add there a way to change OS default printer but I am not sure if that is a good idea as well here.  Cheers!

      Demo Project:  https://dl.dropboxusercontent.com/u/15025358/titlebarx_freex.rar

      ======

      Here is the latest among my toys which is part of ssUltimate class.  This new TitleBar class is very unique against what is already around the web




      What makes this unique?

      Well for one, I can say this is unique in the sense that this allows users to change color of the titlebar class on-the-ply, and retain it.

      It allows two captions, One Main and one sub

      It has a built-in unique dropdown color picker

      The control box is a series of shapes so it is cleaner

      Embedded a cool looking mouse pointer inside


      This is my first release of this class.  I will add some more features in the future

      Especial thanks to Cesar Chalom for the function to convert colors he posted on Weblogs which allows me to calculate the shades I want for lower shape, border and controlbox:  http://weblogs.foxite.com/vfpimaging/2006/11/27/function-to-convert-colors/

      Especial thanks to Cesar Chalom and Cetin Basoz for the color picking sample:  http://weblogs.foxite.com/vfpimaging/2008/01/17/a-great-color-picker/


      How to use this class


      • Drop into your form
      • Change MainCaption property.  If you leave it blank, it will pick-up the caption of the form
      • Add a sub-caption (optional)
      • You can toggle showing Clock ON and OFF via NoClock property (default is .F.)
      • You can toggle The glow effect on Captions into ON and OFF via NoGlow property (default is .F.)
      • You can make it look flat via the FlatLook property (default is .F.)
      • When Dropdown Picker is open, these are the actions you can do:
        • Move around the mouse pointer on the palette to pick a color.  Those will be reflected back on the class itself (titlebar, controlbox, border, shade)
        • Click on a color to stop picking.  Click again to resume picking
        • Change shade of selected color via the spinner object
        • Click outside to finalize and hide the palette form
      • Allowed developer to use the class BackColor to change color of other objects on the form on the ply as well.  Later I will add the capability to control shades of those.

      I did enjoyed working on this these last few days causing me to temporarily abandon enhancements on xBox class and I hope you will find this not only useful but enjoyable as well.  Cheers!


      Accurate Age Calculator

      $
      0
      0

      I never gave thought to calculating an age of a person in terms of years, months and days. But since I read a thread in Foxite pertaining to such need, then I decided to find out how hard it really is.  And it really is not simple as problems appear in months and days.

      Anyway, I always try to think beyond the box meaning I do not limit my tools from within VFP itself so I realize a way to do that easy is via automation using Excel.  Excel has this cool function called DATEDIF to get an accurate difference between years, months and days.  So that is where the experiment went.  And here it is:

      Public oAge
      oAge = Createobject('EMPTY')
      AddProperty(oAge,'Year',0)
      AddProperty(oAge,'Month',0)
      AddProperty(oAge,'Day',0)

      Create Cursor junk (Person c(10),birthdate d, enddate d, nYear I, nMonth I, nDay I)
      Insert Into junk Values ('Jun',Date(1971,7,13),Date(),0,0,0)
      Insert Into junk Values ('Rolly',Date(1952,9,21),Date(),0,0,0)
      Insert Into junk Values ('Whoever',Date(2012,6,11),Date(),0,0,0)
      Insert Into junk Values ('Baby 1',Date(2014,8,3),Date(),0,0,0)
      Insert Into junk Values ('Baby 2',Date(2014,12,29),Date(),0,0,0)

      * Create an Excel file
      Local loExcel As excel.Application
      loExcel = Createobject('excel.application')
      With loExcel
            .Workbooks.Add()
            .DisplayAlerts = .F.
      Endwith
      Scan
            GetAge(birthdate,enddate,loExcel)
            Replace nYear With oAge.Year, nMonth With oAge.Month, nDay With oAge.Day
      ENDSCAN

      loExcel.Quit
      Browse Normal


      ******
      Function GetAge(dBirth, dEnd, loExcel)
      *****
      With loExcel
            .Cells(1,1).Value = m.dBirth
            .Cells(2,1).Value = m.dEnd
            .Cells(4,1).Value = '=DATEDIF(A1,A2,"Y")'
            .Cells(5,1).Value = '=DATEDIF(A1,A2,"YM")'
            .Cells(6,1).Value = '=DATEDIF(A1,A2,"MD")'
            oAge.Year = .Cells(4,1).Value
            oAge.Month = .Cells(5,1).Value
            oAge.Day  = .Cells(6,1).Value
      Endwith
      Return


      Quite simple, isn't it?  Cheers!

      xBox with Dropdown Grid

      $
      0
      0
      Updates 2/10/2015

      Added optional sort of tooltip guide containing the internal caption via _withGuide property (default is .T. or shown).  I realized that with the class relying on internal caption, it is sometimes hard to know where you are once the focus is on it (I feel sorry for my users) until they become so familiarize with the module.

      I was adjusting our Request module when that realization hit me.  So if you want it shown, set it to .T..  However, please be aware that once you allow the guide to be shown, then the dropdown grid will adjust downwards to give room for it, otherwise it won't be seen.



      Updates 2/9/2015



      1. Fixed bug I introduced last Saturday on keypress with the class ignoring non-alphabetic characters

      2. Fixed problem on dropdown grid not clickable when parent form is modal.

      3. Added HalfHeightCaption property to add options on how the dropdown grid will look like.

      4. Introduced dropdown grid DynamicHeight. The height will change based on _tally result when it is between 1 to 10. Beyond 10, it will follow the height you have set.



      5. _NoHeader property is added. Turn this into .T. if you don't want the headers to be shown. So now you have several choices on the appearance of the dropdown grid:


      • With titlebar or none
      • With HalfHeight Titlebar (Will effect only when titlebar is shown)
      • With or without headers


      6. Smarter Selection

      I realized that when quickfill cannot find a match, then pressing the enter key will leave the class with the value of the few keystrokes we did. And so I introduced a smart selection as follows:

      a. When quickfill and dropdown is both in action, pressing enter when quickfill match is present, the class will prioritize the quickfill suggestion even though it is not the first on the list of dropdown

      b. The moment the quickfill is not in place (no left to right match), then when you press enter, the class will auto-pickup the first recod on the dropdown list


      Updates 2/7/2015

      1.  Down arrow now works good.  Once you press down arrow, it now goes to the grid where you can use arrows to navigate through records.  If you want to finalize selection, press enter, double-click or click outside of the popup grid.

      2.  Works on Modal form now (I was informed earlier by Bryan Gerlach inside the forum that it is not clickable on modal forms)

      - Redownload demo form

      Updates 2/6/2015

      Fixed some problems mentioned by MK and Alejandro inside Foxite forum, plus those reported to me by my users. Added also 5 more features:

      1. _nCaptionAlign - where we can change alignment of the inner caption. This works useful when if you want to retain the caption even when the class has a value via _retainCaption = .T..  When you position it on right alignment (1), then when the class looses focus, if the class has a value it will position itself on the right.  If the class remains empty of value, then it will position itself on the left.

      2. Shown titlebar of popup form and added Near Matches result as its caption (taking ideas from Ali Koumaiha's popup grid)

      3.  Added lNoTitleBar parameter in _SetGrid().  That is if others are not comfortable with a form looking popup with titlebar and border, all you need to do is pass .T. onto that and the titlebar will be hidden again (#2 above)

      4.  Added _Clear method.  That is to make clearing both the value and extravalue in one go.  Plus that also takes care of resetting SelStart and SelLength of the class. So instead of doing these:

      This.xbox1.Value = ''
      this.xbox1.ExtraValue = 0

      All you need to do now to allow it for new entry is:

      This.xbox1._clear()

      5.  I realized just now with the recent exchanges with MK inside the form that I never mentioned that Double-Clicking the class will clear it up for a fresh entry.  I now also have updated tooltiptext to include that information.  And as for ToolTipText of the class, you can type your own ToolTipText and now those two mandatory information about the double-click and right-click context will automatically be added onto your own ToolTipText.

      Image of number 1 and 2 above:

      Updates 2/5/2015

      * Minor Update

      ·      Added _RetainCaption property (Default is .F.).  When you set this to .T., even when the class has a value, the caption will remain
      ·         Changed the icon for marker 3 (search icon) to something more appealing to me


      * Major Update

      Added Popup Grid
      This one is a bit tricky and honestly has taken a lot of my time.  Anyway, I won't bore you anymore with details and just run you down on the necessities.



      How to Set the Popup Grid for PopUp feature

      On INIT event of the class, you have to set the grid appearance.  But first you have to issue DODEFAULT() as that will run all the necessary codes I put in the init event of the class.  Next is to call _SetGrid Method

      DODEFAULT()
      this._setgrid('Customer Name-260|Address-200|City-100',2,585,250,2,'Calibri',11)

      _SetGrid Method Parameters

      Lparameters cColumnList, nScrollBar, nWidth, nHeight, nGridLines, cFontName, nFontSize

      Where:

      ·         cColumnList - Controls the captions of the headers of each column.  As you can see on the sample code above, it has two delimiters, i.e., dash and pipe sign.
      o   Pipe Sign ( | ) - is used by the class to break between the captions
      o   Dash Sign ( - ) - is used by the class to determine the width of the column
      ·         nScrollBar- is a numeric representative of the ScrollBars property of Grid (Default is 3 or both scrollbars are shown)
      ·         nWidth- is the width of the popup grid (default is the same wide as the class instance on form)
      ·         nHeight- is the Height of the popup grid (default height is 100)
      ·         nGridLines - controls the horizontal and vertical lines the way it is controlled natively on Grid (default is 3)
      ·         cFontName- is the font to be used on grid (default is Arial)
      ·         nFontSize- is the size of font on grid (default is 9)

      How to Perform a Popup Grid filtering

      Use the InteractiveChange event of the class so the search/filtering is made as you type

      *InteractiveChange Event
      Local lcSQL
      TEXT TO lcSQL NOSHOW PRETEXT 12
      Select distinct to_name, to_address, to_city, cust_id From orders;
            where [MySearch]  $ to_name;
            ORDER By 1;
            GROUP BY 1,2,3,4;
            into Cursor junk NOFILTER
      ENDTEXT
      This._searchgrid(STRTRAN(m.lcSQL,';',''),'junk.to_name','junk.cust_id')

      You can perform any SQL SELECT you want but this is mandatory:  WHERE [MySearch] $  OR WHERE 'MySearch' $ OR WHERE "MySearch" $.  Or you can use instead the SQL LIKE instead.  What you have to keep in mind is that [MySearch] holds the values of your keystrokes which is the basis of the class.

      MySearch is not case sensitive but the class needs to see the exact mysearch word.

      - Single click on popup grid will seed the class with .Value and .ExtraValue
      - Double-click will seed and close popup grid
      - You can use the class marker to show/hide popup grid as long as the current value of class is not empty.

      For other features and usage of the class, refer to my first post here: http://sandstorm36.blogspot.com/2014/12/xbox-textbox-control-class.html

      Special thanks to:

      Tom Knauf for advising me to work on popup grid and sharing ideas as well.

      Ony Too - for sharing us the DatePicker class which is a great help on my learning further about popup forms and control classes.

      MK Sharma - for testing the class and informing me of bugs.

       Again, here is the demo project and library:  https://dl.dropboxusercontent.com/u/15025358/xbox_demo.rar

      xBox October 2015 release

      $
      0
      0
      Its been a long time that I have not done any intensive developing but last week I decided to try to resume my mood on it.  Finally, yesterday my mood somewhat returned and so after a long time, I decided to adjust xBox class which really needs an overhaul.

      Here now are the new features for this release:

      Introduced _HighlightKey Property

      .T. (Default) = will highlight the keys you've pressed so far.  Good for dropdown feature (see images)




      I decided to have this as an extra guide for users to know what keys they have pressed so far.




      .F. = will highlight suggestions for quickfill.  Good for without dropdown


      Introduced _PlainBox Property

      If you will be using xBox just because of its look (curvature and markers) without any quickfill suggestion or dropdown feature, then set this as .T..  Default is .F.

      Miscellanous Enhancements

      Well, I've made some clean-ups on codes such as relocating all the WinAPI declarations so it will be declared only once instead of repeatedly re-declaring those on the popup/dropdown grid.  Centralized as well the highlighting capability of the class.

      To get the latest, click on the link below.  Cheers!




      What’s on ssUltimate Library

      $
      0
      0
      What’s on ssUltimate Library Now?

      During these past months, some people are showing interest in ssUltimate Library.  And finally after receiving several email enquiries, I decided to create a demo project so when they subscribe onto it (USD 30), then they will have a guide.

      Aside from what I already have shown here now and then, there are others inside the library I have not shown before which you will see now.  Here is what’s inside ssUltimate Library in alphabetical order:

      AnchorSizer
      Is the same as ssAnchorSizer found in ssClasses Library.  Used to properly resize the insides of grid, combobox and listbox when anchor is implemented on those

      ButtonX
      Is my latest button class showing better themes and added new features.   For instance, there is now an x icon when you disable it (optionally), it can be with themes or no theme for the curvature purposes (can be used with TitleBarX color theming), etc.



      CloseX
      Is another form of titlebar class that gives a unique appearance.  It can have a titlebar or just that plain close button located at the right side of the form

      ContainerX
      Is my version of ssContainer of ssClasses.  This has better themes and again new features

      ConX
      For lack of idea to name a class when I first decided to create this as ContainerX already exists, I simply named this as ConX.  It is another container class but with a twist:
      1.       It can be used as a plain container
      2.       It can be used as a button
      3.       It can be used as a tab for a pageframe ssUltimate style
      4.       It can be used in connection with TitleBarX on-the-ply color theming



      DTPickerX (new 12.30.2015)
      A unique DateTime Picker class that can be morphed into a month picker, a date picker and a datetime picker



      DropClock
      Is my design of a dropdown clock.

      EditX
      Better design than ssEditBox of ssClasses.  Unlike ssEditBox, this one is a control class.  No need to set when the dropdown will appear as now it auto-detects when the dropdown is needed.  Auto-adjusts based on width and font

      ExcelPivot
      Better than ssExcelPivot of ssClasses.  With more features
      FaderX
      Same as ssFader of ssClasses

      GridLock
      Same  as ssGridLock 

      GridSort
      Same  as ssGridSorter of ssClasses.  To give a grid an instant sorting capability

      MonthYear
      Another one that is not shown before.  It is a button class that shows a dropdown section for months and year.  I created this as sometimes I am getting lazy utilizing two date pickers for the from and to dates.  Best used for monthly reports.  Returns four values:

      1.       Year (nYear)
      2.       Month (nMonth)
      3.       Beginning of Month date (_BOM)
      4.       End of Month date (_EOM)



      OptionSwitchX
      Counterpart of ssOptionSwitch, better GUI, more themes

      PolyClock
      Counterpart of ssPolyClock


      ScrollTime
      Another time class, like the one on android mobile


      StickyX
      Another class that can be used to replace editbox with a sticky note look.



      SwitchX
      Counterpart of ssSwitch.  Better and more themes


      TitleBarX
      Another titlebar class.  This one though gives user a capability to choose their own colors on objects (when applied) on-the-ply.  Retains the last color selection


      TransparentX
      Counterpart of ssTransparent.  For irregular forms.  Create a background of irregular form (the transparent section should be of RGB(0,0,64),make the image the form’s background and just drop that class on form and run.  Like most of my classes, it will handle the rest.

      xBox

      Made some more fixes on highlights when you choose dropdown usage.  Also added PlainBox (turn it into .T.) property so you can use this without the dropdown or quickfill feature; just a plain textbox with curvature and other effects.  A much faster way to search than combobox. 


      Interested new subscribers can email me on ss.classes.jun at gmail.com

      Controlling Windows 10 Auto-Updates

      $
      0
      0
      I bought a laptop a few months ago with a licensed Windows 8.1 OS.  But since a colleague of mine was able to download an offline Windows 10 free upgrade and burned it into a CD, then immediately after purchase I upgraded mine to that latest OS version (to hell with Windows 8).

      And I love it (though on some machines, I encounter blank screens after upgrade that I was forced to reinstall an older version) but there are certain things we need to turn off on privacy settings for our own peace of mind.

      Since my Windows 8 is a 64-bit home version, I got the 64-bit Home version of Windows 10 as well.  And unfortunately, while I like Windows 10 better, I am annoyed by its auto-Windows Update where MS totally removes our freedom to choose which upgrades we would like to be installed in our machine.

      And due to that forced updates, I  have seen reports on the net of people wailing that after some certain updates, it short-circuit their machine making them curse in grief Windows 10.  Due to that is why I decided to create this post

      Option 1 - Turn-off Windows Update

      Right-click on taskbar, Task Manager, click on Services Tab, click on Open Services link below.

      Inside Services, look for Windows Update, double-click it, choose "Disabled" as start-up type.

      In some cases, you will wonder why sometimes after you've done this and after a while you re-checked its status, you will realize it is still running even though the start-up type is still on Disabled.  That is because MS provides a "recovery" action to be done in case it detects failure of a service.

      So to totally kill this update, you have to turn off recovery action as well.  See image below



      However, it appears that in some cases, even when these are implemented, Windows 10 can still do an uncontrolled update.

      Is turning it totally off a good suggestion?  I will leave that to each of you whether you are already comfortable with your OS 10 version or if you want it to still install some patches.  In which case you can re-enable it back at your own accord.

      This next alternative might be better for you

      Option 2 - Intercept Updates

      Okay, this option deals with still leaving windows 10 to do an auto-update but now we will be intercepting its updates.  And to do that you have to install 3rd party downloaders such as Internet Download Manager (IDM), Xtreme Download Manager (XDM), and Download Accelerator Plus (DAP), to name a few.

      I am using on my end now XDM 2015.  So when Windows 10 attempts to download a file, this is now being intercepted by XDM.  It will then ask you whether you want to continue downloading it or you can press Cancel.  The moment you pressed/clicked Cancel button, then XDM will release its hold on said intercept and the OS will be given back control over it.

      In this way, it is like having control as well which of the attempted downloads will be given back to Windows.  What I do on my end is for those I do not like to be downloaded, I leave XDM intercept window and just move it out of the way and for those I like my OS to download, I clicked Cancel to allow my OS to download it.




      There you go, ways to control windows update features of Windows 10.  Cheers!

      DTPickerX (new)

      $
      0
      0
      So what is this latest class that is also now part of ssUltimate?

      DTPickerX is a unique DateTime picker.  Unique in its look and unique in its functions.  Right now it has three levels via nLevel property:


      • nLevel = 1  (Month and Year picker)
      • nLevel = 2  (Date, Month and Year picker)

      • nLevel = 3 (or any other values, full date and time picker)




      The class auto adjusts based on the nLevel property value (default is 2)

      Return Values:
      • .Value = is the date value
      • ._BOM = is the beginning of the month value
      • ._EOM = is the end of the month value
      • .cTime = is the military time portion in character type, e.g., 16:35 
      • ._DateTime = is the complete DateTime value
      • .nDay = is the numeric day of the date value
      • .nMonth = is the numeric month of the date value
      • .nYear = is the numeric year of the date value

      Objects inside the popup form:
      • The calendar control class is adjusted awesome Ony Too's _calendar control class (no need to reinvent the wheel)
      • The MonthYear control class is derived from my MonthPicker form class
      • The Time control class is a new control class consisting of two spinners, one for hour and another for minutes


      Why create a new class like this when there are already others out there in the web?

      For starter, I want something unique.  Another is I want something that is faster in navigation or date selection.  The combination of the MonthYear class makes it possible as you can easily spin or scroll the year up and down plus select a corresponding Month way much easier and faster than the existing date pickers out there.  Plus I wanted something that can have the time as well.

      So there you are, the latest awesome addition to my classes inside ssUltimate.  Subscribers will be updated next year.  Cheers!

      How to be a Subscriber?

      Interested in being a part of ssUltimate Subscribers and users?  Email me on ss.classes.jun at gmail.com for several subscription payment options.  For new subscribers starting January 2016, subscription fee will now be USD 35.  The library comes with a demo project, source code included.  Subscription fee is one time payment and subscribers receive free update now and then.

      Where do those subscription fee go?


      I maintain a separate account for that.  Majority of those funds are stuck inside paypal at the moment pending linking of a visa card from me (I haven't taken the time to do that yet since I started ssClasses).  So I cannot withdraw those.

      These subscription fees are my funds in assisting other contributors on the web who are sharing their tools, in assisting some forums, and in contributing to Wikipedia (c'mon guys, let us help wikipedia, they need funds).  

      Most of the funds are set aside to contribute to flood victims in the area where I live in the Philippines.  A little portion I give to my sister as a gift for her effort in getting those via Western Union (my preferred payment these days), the rest she holds for future donations to flood victims per my request.  None goes to my own pocket.  None used for my own expenses.  

      By subscribing, you get an awesome tool, and you are likewise helping others who are in need through me (flood victims).  Though we remain anonymous when we do so. So don't be thrifty! :) 

      Next Update to Subscribers

      After I posted what's inside ssUltimate library, I have updated existing subscribers.  And sends the same to new subscribers.  The next update will be on January 2016.  

      This was not included because I have not thought of this one yet during that time.  While I have tested this new class to my satisfaction, I will still have to do some further testings.  I have more plans for new features of this class.

      For a list of what's inside ssUltimate library, check this out:  http://sandstorm36.blogspot.com/2015/12/whats-on-ssultimate-library.html

      Popup Calculator

      $
      0
      0
      I was popped yesterday by a fellow developer who showed me his form using ssDropCalc saying he is very satisfied with ssClasses library.  Thinking that others are really using said class, I decided to create a counterpart of that today for ssUltimate.  Of course, it has to be better.

      What is PopCalc?

      This is the counterpart of ssDropCalc of ssClasses but is better in many ways


      • Better Look
      • Unlike ssDropCalc which is a container class, this one is a control class
      • This one does not switch between formula and values.  The formula is simply shown on the popup calculator but it always returns the value
      • Better hotkeys (hover the mouse to see)
      • Highlights the keys pressed (if you do not want to use mouse)
      • Easier to use


      Using on Form

      Drop it and resize if you want.  On focus, this auto-pops the popup calculator and with starting value of what you put there (default is zero unless you change it via code, e.g., this.value = 123)




      To exit the popup portion, either click outside, press Esc or press Enter (hotkey to pressing = sign) on your keyboard. To forcefully pop it up again if you want, press down arrow or Ctrl+Down Arrow keys.

      Using on Grid

      This is easier than ssDropCalc in that all you need to do is drop it down to a selected column of numeric value.  It will then take ownership of that column without setting anything further by doing the following:


      • Inheriting ControlSource
      • Inheriting Font Name and Size
      • Inheriting Alignment
      • Making itself the CurrentControl
      • Setting Column's Sparse = .F.



      When used on Grid, the popup calculator won't auto-pop (by design).  The shortcut to pop it up is Ctrl+Down Arrow Keys.

      There you are, the latest addition to ssUltimate!  The only thing I am not that satisfied is because I used here ButtonX class for better look, then there is a bit (nanosecond) delay in popping up form as it has to redraw those buttons on loading of popup calculator.  But I still prefer it than creating several images for those buttons.


      Added January 7, 2016

      Added/Utilized these properties:

      Classic Property - Whether to use native commandbuttons (default or .T.) or ButtonX (.F.).  While buttonx looks cooler, there is that nanosecond delay that some of you may not like, thus this option.

      Themes - Affects only Classic popup calculator, whether Themese are used or not on those native commandbuttons

      SpecialEffect - Affects only Classic popup calculator.   Using the control class' SpecialEffect property so I won't need to add another myself, ignore what is shows:

      Control Class                  Effect on Classic Popup
      0 = Raised                     0 = 3D (Default)
      1 = Sunken                     1 = Plain
      2 = Flat                       2 = HotTracking





      CalendarX

      $
      0
      0
      This is based on my DTPickerX's idea of a faster date navigation/selection.  Have 3 return values:

      .Value = date value
      ._bom = Beginning of Month
      ._eom = End of Month

      Use Click event to perform other things as we change/select dates.  Here is how some classes of ssUltimate library looks on form.


      ProgBarX

      $
      0
      0
      A simple progress bar which I created to replace the WAIT WINDOWs I put in ExcelPivot and ExcelExport classes.

      Late last week, I decided to add more features onto it so its usage can go beyond those two classes such as for my other looping needs.

      Progressbar on SQL SELECT

      After that, I decided to see how I can incorporate this to an SQL SELECT as well, a desire which most of us share.  Here is how it looks like when incorporated on an SQL SELECT





      SQL SELECT..  INTO CURSOR TEST RESULTS

      * Update, April 14, 2016

      Thought of another way to slash the overhead of progressbar on SQL SELECT.

      Test is performed on our requested items for 9 years joining 5 tables in the process.   The SQL SELECT produces a cursor with  51,743 records:

      - standard SQL SELECT (not using this class), average elapsed time on multiple runs is 1.83 seconds

      - with ProgBarX showing records being processed, the bar and  percentage of completion (via SQLBar() method of class),
       average elapsed time is 4.50 seconds.

      - with ProgBarX showing only the progress bar and percentage of completion via its SQLBarNoRec() method, average elapsed time of 3.72 seconds.

      Again, the test is done on a 9-year dataset.  If it will be just within months or a year, the overhead will be less than a second.

      The beauty of this is now we can see the number of records and its percentage of completion as those are created by an SQL SELECT.

      Not only that, visual is the key.  Without a progressbar showing records being processed by an SQL SELECT with huge number of records, it appears to be slower than the one with ProgBarX.  That, of course, is an illusion as users do not like staring at the screen wondering what the hell is going on.  Users never like to unknowingly wait.

      With this in place,  it provides users a real-time live feedback of what's going on behind the sql select processes as it shows the number of records being processed so far and can give them estimates on how much more to wait via the progressbar and percentage of process completion.  It also shows them that the app is currently doing something and has not frozen, as some tend to wonder or think on SQL SELECTs resulting to huge number of records.

      This class though is only available for ssUltimate users.  The one added onto ssClasses does not have the latest features including that capability to show progress of an SQL SELECT.

      A demo form for this is now available for my subscribers:




      Interested in being a subscriber?  Email me at ss.classes.jun at gmail.com

      Cheers!





      ExcelExport

      $
      0
      0
      This is the counterpart of ssToExcel2 of ssClasses.  




      Unlike ExcelPivot, this one simply transfers your cursor/table into excel with added formats, titles, etc.  An example is a ledger as shown at the bottom hereof

      New properties


      • _PaperSize (1 = letter (Default), 3 = tabloid, 4 = ledger, 5= legal, 7 = executive, 8 = A3, 9 = A4, 11 = A5, 66 = A2, 119 = 11x17 size)

      • _MarginLeft, _MarginRight, _MarginTop, _MarginBottom (all Defaults to 1 inch)

      • _WithFooter (Default is .F.)

      • _Orientation (1 = Portrait (Default), 2 = Landscape)

      • _scaling (For zooming of sheet, default is 100)

      • _isProper = to turn the field names into PROPER() (Default or .T.) or UPPER() (.F.)





      Miscellanous:


      • Added Progressbar (ProgBarX class)

      • Replaced Default body font from Tahoma to Calibri

      • Cleaned codes, speed up automation a bit






      Shown below is what I meant by exporting cursor result to excel using this class on a spreadsheet with added features. Please note that with this class, it us entirely possible to do that even when you have zero automation knowledge.













      Available only to ssUltimate subscribers.




      APPEND FROM fails on Memo (VFP)

      $
      0
      0
      It appears that APPEND FROM command has an undocumented behaviour which is it cannot transfer its values into a Memo Field.  So in cases where you want to append data from say a csv, text or other types and your destination table has a memo field, then forget about this command.

      Inside foxite forum, this exact problem causes a member to search for a way to achieve getting the values of a column of a CSV file that has more than 256 characters (definitely a candidate for a memo field type).  And APPEND FROM cannot simply just do that.

      Having said, an alternative way to transfer data from a CSV file to our table with memo fields is to use excel automation.  It is quite simple really to do that.  Here is a small snippet for that:


      Create Cursor junk (familyid i, Name c(60), Description M)

      Local lcFile, loExcel As Excel.Application, lnLastRow
      lcFile = Getfile("csv")
      If !Empty(m.lcFile)
            loExcel = Createobject("excel.application")
            With loExcel
                  .Workbooks.Open(m.lcFile)
                  For lnloop = 2 To .Cells(1, 1).CurrentRegion.Rows.Count
                        Insert Into junk (familyid, Name, Description) Values ;
                              (.Cells(m.lnloop,1).Value,.Cells(m.lnloop,2).Value,;
                              .Cells(m.lnloop,3).Value)
                  Next
                  .ActiveWorkBook.Close
                  .Quit
            Endwith
            Go Top
            Browse Normal
      Endif



      Using his sample data, here is the result of said automation:



      And that is it, an easy way to import data from a CSV file (or any other files that excel supports) into our tables including ones for Memo fields.  Cheers!


      Why I am never a Loyalist (a Political Issue)

      $
      0
      0
      While I do not want to involve politics on my blog, I will make an exception for these thoughts; hoping it can reach more of my countrymen.

      I am not a loyalist, never was and never will be, even with du30 no matter how good I see he is.  Because most of the times being a loyalist clouds a person's perspectives, and that I won't let happen to me.   Studying du30's character, he does not want it too.  He wants people to correct him if he is making a mistake too.

      I don't want to be a loyalist for my need to see the good and acknowledge the faults.  The same way I like my friends and family members to see and treat me too.  Then to balance those visible actions out to build a more accurate composition and assumption of a person's character.

      I can never be a loyalist because I don't and will never blindly follow anyone without analyzing the implications of a move.

      The problem with us, Filipinos, is most of us has this personality disorder (yeah it is a disease) of following blindly a leader, from the baranggay level up to the highest position.  "Sabi ni kapitan, sabi ni boss tsip, gawin daw natin yan!" "Hindi ba bawal yan?" "Walang bawal bawal, sagot ni kapitan at konsehal yan".  How I wish we should learn to question and oppose our leader if what he/she is doing is wrong.  Hey, nobody is born perfect so learn to acknowledge their mistakes, and oppose those.

      Another problem that I see is we filipinos are in awe of those in power thinking of them as "royal bloods" and that leads to us ourselves enabling them to build political dynasties.  Once a person was voted to hold a higher position, we gave them more powers by also voting for their family members to hold other positions in the government too when they decided to run because the thinking is they are "entitled" or mostly suited than others to do that; again because of that royal blood mentality.

      We also view the politics like a beauty contest where popularity is a major factor.  And this resulted to some movie actors/actresses holding key government positions.  I am not saying they are not capable to hold those positions as there are some who has the interest of their community at heart like Gov. Vilma Santos; to name one. I am just saying that we based hugely our casting of votes on popularity, not even minding to do a research on a candidate.

      With this attitudes of ours,  political dynasties of families are born on parts of the country (Josons, Marcoses, Umalis, Ampatuans, Binays, Aquinos; to name a few).  Later we come to regret this but it is too late.  Later we shout at the abuse we get.  And whose fault is it anyway?

      Most of you forgets that they (government officials) are elected to "serve" the country and its people and not to be "revered" as the almighties.  And that we should be more in power and has the right to question their wrong actions.

      I am never a loyalist  as I can easily see beyond facades, beyond sweet talks and empty promises during election time.  Because I don't easily believe in words but look at existing and previous works.

      Having said, as this write up has been spawned by my post of Marcos' accomplishments, I came into conclusion long time ago that Filipinos have been deceived by cries of oppression and how bad martial law is.  Because when I put  the next governments in comparison, I saw only more rampant corruptions and sweet talks with the later regimes.  I saw that those self-claimed victims of martial law are the ones who have benefited the most on the next regimens, financially and politically; massively.

      And since they enjoy fully those benefits, they continue to use until now the bad side of marcos' regime as propagandas to hold us in our necks forcing us to look only on what they want us to see.  Not surprisingly because if and when you look around and compare their achievements, collectively all of them lack in comparison with what the late Marcos has done.  Way way down below.

      What makes me angrier is they are aided by paid and bias medias, just to continuously misdirect the attentions of the citizens so we will only focus on the "bad sides" of marcos.  These sleight of hands should stop.  I urge everyone, when they start shouting about the past, look instead in the current and see what they've done.  Doing so will lift the fog that is hiding their own corruptions, malpractices, and non-accomplishments & very poor jobs.  The things they don't want us to see and the reason for misdirection and mind conditioning.

      It is not bad to be a loyalist people, but don't be a blind loyalist following your chosen leaders even though when they are wrong.

      And finally, I AM A LOYALIST!  My loyalty though is towards my country for I want what is good for it and abhor the bad things they are doing to it.  So I will support those that have proven by actions to have the country's interest by heart.  No matter who he/she is, no matter what parties they are in.

      Be a real and proper loyalist my friend.
      Viewing all 160 articles
      Browse latest View live