Wednesday, November 30, 2011

ssTitleBar2

You may ask me, why have I created yet another title bar class again?  And the answer is because I want to give more to the users.

All my previous title bar class are dependent of images I designed using Adobe Photoshop and though those looks good per my own taste, creating yet another look or simply just colors takes time.  And so I want to get out of that bond I inadvertently created for myself, therefore ssTitleBar2.

What has this new titlebar class has to offer that those previous ones can't?

  • Less Images - This new class is designed mostly using native VFP shapes and are positioned properly to give it a good look.  The shapes are the whole titlebar component itself including the control box.  Now it is easier for me to create new themes and color, whenever the mood hits me.
  •  Additional objects
    • Another subclass in the appearance of a printer icon is created so users can switch their default OS printer on the ply (optionally shown)
    • Time is optionally shown
    • ssChkBox is embedded to allow movement of the form or not (optionally shown)
  • Resizable - Whereas the old titlebar classes cannot be resized when the lShowBorder parameter is set to .T., this one now can.  In addition, borderline is now better looking
Here is an image of this class:



One major improvement of ssClasses this week is the creation of ssColors which will allow me to make new color combinations that will affect all my sub-classes that needs it.  Like I said, creating new themes and colors next time will be easier (because of ssColors).  Not to mention that ssSkinner is also using this so you can extend color-theming on the ply even to native VFP objects much easier.


Friday, November 25, 2011

Troubleshoot Sending Email from Outlook

Due to intermittent connection with internet resulting from Degradation of Service on our VSAT, we constantly have problems sending emails. In addition, there are few minor reasons why email sending fails. So this blog is meant to give guide to those who have problems sending emails.

Reason: Invalid email address(es). Users kept telling me that their email is not delivered properly. And I kept telling them to check the email addresses because if you have more than one recipient or have some more on CC and BCC, a single invalid email will give you that undeliverable error report.

Solution: Confirm that you have the proper email addresses.

Reason: Dangling Reference - Because email sending is taking the user so much time, the tendency is they will close Outlook, Open it again, then try sending the email once more. They may repeat doing this but got no luck. The reason is (per our experience on several units here), there are dangling references of outlook in the system processes.

Solution: Right-click taskbar, activate Task Manager, Click Image Name Header to sort the processes alphabetically either ascending or descending, and kill all Outlook instances there. Ensure that there is no more outlook instance before reopening outlook again. I am not sure if this is a bug of Outlook 2007 or not but that happens.

Reason: Add Ins. For some more reasons, some add ins affect also the way how outlook works smoothly.

Solution: Open outlook in Safe Mode. Few users know about this feature. You can easily do this by pressing Ctrl button while clicking outlook. It will inform you that it has detected you pressing the Ctrl key and will ask you if you want to start outlook on Safe Mode. Click ok then try sending your email again.

Reason: Blocked outgoing port. In some cases, you may not know that your unit is spewing out SPAMs due to undetected malwares on your unit. When this happens, your ISP may block your outgoing port (default is 25) and you won't be able to send out email.

Solution: Try the alternate port 587. Click on Tools, Account Settings, double-click your account, More Settings, Advanced, then change your outgoing port (SMTP) to 587.

Reason: Your recipients admins has made some protection on their end against SPAMS. When attempting to send an email, you may see either a relay error stating, Relaying Not Allowed, or an alert box requesting you enter your password. This would be an indication you need to check Outgoing SMTP authentication on your mail client program.

Solution: To avoid the possibility of your email being treated as SPAM, ensure that your email is authenticated by your Outgoing Mail Server. To do this: On outlook, click Tools, Account Settings, double-click your account, More Settings, Outgoing Server Tab, tick My Outgoing Server requires authentication, Log to Incoming Mail Server before Sending Mail.

Well, that wraps up the way I troubleshoot our sending of emails problem over here. If I suddenly think of some more reasons and the ways to counter those, I will update this blog.

Hope this helps!

Tuesday, November 22, 2011

Importing from an xlsx file via automation Part II

Last time I created an entry in weblogs about the automation approach of importing an xlsx file because with the change of format on Excel 2007 onwards, VFP is generating an error now on importing it.  Since importing has no problem on lower versions of Excel files, the solution I have proposed is to save the sheet to a lower version, preferably XL5 format for backward compatibility reason.

Now, a new question is raised.  Though that approach works fast and is easy, how can we import from a specific worksheet inside the excel workbook?

If you use the approach that I have shown, it will always get only the first sheet.  Here is another trick though so we can do a selective import of an existing sheet inside that workbook.  And as a bonus due to another question raised inside Foxite Forum, here is also a way on how to replace the column names with the contents of the first row so Field Names will be better and proper instead of Field Name A, B, C.... and so on:

ssTab

ssTab is the latest on my ssclasses family.  I originally created ssPage before but since I am still new with classes way back then, although the class produces an appealing tab appearance, it is messier and harder to use.

ssTab is better in a lot of ways than ssPage.  It also offers more feature than ssPage.  Here are the parameters of ssTab:

Lparameters cCaption, cToolTip, nTab, cPageFrame, nColor, nStyle, cIcon, nIconStretch, lShowFold, lActiveTab

Where:

  • cCaption - is the caption of the tab
  • cToolTip - is the tooltiptext of the tab (optional)
  • nTab - is the tab number of the PageFrame to be binded to ssTab
  • cPageFrame - is the name of the PageFrame to be binded to ssTab
  • nColor - is a numeric color (right now only 1 to 4) to dictate what color of the tab will appear
  • nStyle - is the BackStyle of the tab (1 for Opaque, 0 for Transparent).  This produces extra appearances on ssTab
  • cIcon - is the icon of the tab (optional, use bmp or jpeg; preferably .bmp)
  • nIconStretch - will the icon stretch or not?
  • lShowFold - whether ActivePage (clicked page) shows a folded section on the right or not 
  • lActiveTab - to specify which one of the ssTabs you want to be the Active Tab (and which Page of the PageFrame to start active)
 Right now, here are the possible look of Active ssTab (all with lShowFold = .T.)



Of course, in the future I may create more.

Among the sample given to subscribers is this:


Enjoy!

Friday, November 18, 2011

Extending FastXtab (Cross Tab)

What is a Cross Tab?

Cross tabulation is the process of creating a contingency table from the multivariate frequency distribution of statistical variables. Heavily used in survey research, cross tabulations (or crosstabs for short) can be produced by a range of statistical packages, including some that are specialised for the task. Survey weights often need to be incorporated. Unweighted tables can be easily produced by some spreadsheets and other business intelligence tools, where they are commonly known as pivot tables.  - Wiki

===========

FastXTab is another cross tab utility developed and shared to us by Alexander Gorovlev which aims to replace the cross tab utility shipped with VFP (VFPXtab).  Its name lives to its reputation of being faster than VFPXtab.  It can be downloaded here: http://www.universalthread.com/ViewPageNewDownload.aspx?ID=9944

Originally I do cross-tabbing (pivoting) inside Excel via automation and it has its own merits but though it offers more features that after the pivot sheet is created that you can still manipulate it, it appears to be slower and of course you have to do a lot of codings to attain it.

Enter FastXTab, as I mentioned a very fast cross tabulating utility.  One thing though that I noticed with it is on the bottom, the author has placed these:


* TODO:    Support for long field names
*        lTotalRows property

And I needed at that time that lTotalRows property.  So since it is not yet there (in the downloadable zip), I took the liberty to add that feature on my end and now decided to create this entry so interested users of FastXTab who has not added or made that property work yet can add it on their end as well.  Here is infused portion for lTotalRows:



Set Talk &cTalkStat
Set Null &cNullStat
Wait Clear

* If rows are totalled
If This.lTotalRows
      Alter Table Alias() Add Column "Total" N(12,2)
      Local lcField, lnTotal, lnloop
      Scan
            lnTotal = 0
            For lnloop = 2 To Fldcount() - 1
                  lcField = Field(m.lnloop)
                  lnTotal = lnTotal + &lcField
            Endfor
            Replace Total With m.lnTotal In Alias()
      Endscan
Endif

If This.lBrowseAfter
      Browse Nowait Normal
Endif



Ignore the ones colored in red.  Those are already there.  I just copied it here so you will know where I inserted the lTotalRows feature.

And if you are a user of ssToExcel, then combining FastXTab with that class will allow you to create your report in excel very fast and with good formatting plus column totals as well like this:





Tuesday, November 15, 2011

Restrict users from changing time on their local unit

Here is a trick on Restricting users changing the local CPU time.  Some people need it especially when a software is based on the running local unit’s clock, so by restricting the users’ ability to change it, they cannot cheat.

There are several ways to restrict it, but we will focus on Group Policies and some outside tricks.  To start, open Group Policy Editor by clicking Start button, Run, typing GPEDIT.MSC and hitting enter.

Once inside, navigate to these Folders:

a. Local Computer Policy
b. User Configuration
c. Administrative Templates

* Hiding the clock on system tray of Taskbar (User Notification Area)

On Start Menu and Taskbar Folder:
- Remove Clock from the system notification area – set to Enabled

* Hiding the Date and Time icon on Control Panel

Steps to Remove Recycler Folder

What is Recycler folder anyway?  Is it really part of Windows or not?

When you delete a file in Windows NT Explorer or My Computer, the file is stored in the Recycle Bin (if this feature is not turned off). The file remains in the Recycle Bin until you empty the Recycle Bin or restore the file.

The Recycler folder is used only on NTFS partitions. The RECYCLER folder is the recycle bin for every drive that has read/write capability. Naturally CDROM won’t have that. Saying another way, the Recycle Bin on your desktop is simply a shortcut to all the RECYCLER folders in your computer. If you have a C: and D: drives on your unit which is of read/write capability (harddrives, USB Mass Storage Devices); then your recycle bin shows the contents of C:RECYCLER and D:RECYCLER. Having these RECYCLER folders on each drive saves the OS from having to physically move/copy a deleted file or folder into one fixed location which maybe on another drive.  Needless to say, retaining an individual RECYCLER folder for each drive is way much reasonable, easier and faster.

Now, why in the heck would I want to “Remove Recycler Folder?” as the title suggests?

BSQXITA virus removal


What does this virus do?

a.  When you log into your OS account, a folder will pop up like My Documents, Windows folder itself, or any other folders.

b.  When the infection goes deeper, the only thing you can see is whatever that folder has popped out and its contents.  No desktop, no start button, and a lot of no other things.

When you experienced something like this, then you can suspect that that is BSQXITA virus (I am not sure if it is called by any other names by other antiviruses software out in the market but that is the name I have seen).

This tutorial will show you the way to recover from that infection and to totally eradicate said malware.  The steps will involve removing related registry entries as well as physically removing those file infections in the harddrive.  Here goes:

a.  When you are already logged and a folder (with its contents) automatically appears and nothing else, you need to kill the Explorer process.  Explorer is Windows shell and the reason why I said to kill it is because the Explorer loaded by your OS upon logon has something extra.  You will learn what later.  So press Ctrl+Alt+Del and go to Task Manager, then search for Explorer.exe, right-click, choose Kill Process Tree.

b.  Everything disappers at this time except with the task manager.  Do not close it and instead click File, New Task (Run) then type explorer and hit Enter. After that everything is proper.  All we need to do now is start removing the infections, both files and registry entries.

c.  Click Start, Run and type MSCONFIG then hit Enter.  Once inside MSCONFIG, go to Startup Tab and look for these entries:  BSQXITA.EXE and NETSFIGX.EXE.  Untick those so it won’t be auto-loaded next time.   Click apply, then close.  It will ask you to restart, choose Exit without Restart!

d.  Click Start, Run and type REGEDIT then hit Enter.  We will now clean registry entries made by this virus.  Go to these locations (HKLM means HKEY_LOCAL_MACHINE):

- HKLM\Software\Microsoft\Windows\CurrentVersion\Run (delete entries for those two files mentioned above).

Optionally, you can also clean the startupreg as shown in MSCONFIG.  Go to:
- HKLM\Software\Microsoft\Shared Tools\MSConfig\startupreg
Delete the files that is being autoloaded there that seems suspicious like the BSQXITA.EXE and NETSFIGX.EXE entries

Now in letter a above, I have said to kill Explorer exe because it does an extra thing, right?  The next registry entry is responsible for that.  Navigate to:

- HKLM\Software\Microsoft\Windows NT\CurrentVersion\WinLogon

Under “shell” entry, you will see something like this:  Explorer.exe System3_.exe

The reason why during initial logon, a folder is popping up and nothing else is because of that entry.  Explorer is auto-loading another exe into processes and that System3_.exe (sometimes the name may change) is a virus component that halts any other more execution.  That is also the reason why I want you, in letter a above, to kill the first instance of Explorer.exe in the process in task manager.  Because by killing that first process, you are also killing the related processes it has loaded.  Letter b reloads a “clean” instance of Explorer which is the OS shell and that one is loaded without any extra baggage.

Now, under that shell entry, remove the extra commands. Double-click it and leave only Explorer.exe
Just to make sure that everything is cleaned, still inside the registry, go back to My Computer and hit F3 (search) and type BSQX and search for it.  Delete every occurrence.  To resume searching after it find one entry and you deleted it, hit F3 again.  When it reached the end, go back to the top by clicking My Computer and this time do not hit F3 as it will resume searching for BSQXITA.EXE.  You need to look for another this time, i.e., NETSFIGX.  To do a fresh search, press Ctrl+F.  Remove all occurences of that item.

RECAP:

a.  We have loaded a fresh clean Explorer shell
b.  We have killed processes relating to this virus
c.  We have cleaned registry entries so that virus won't be loaded again next time we logged on

All that is left is to remove the physical files in the harddrive. Those files are actuall inside Windows\System32 and \Users\Administrator (for system3_.exe).  But if you have the time, open explorer and search for those files.  Ensure that in advance, Search hidden Files and Folders is ticked.  Delete all those infections.

If for one reason or another, the system won’t allow you to delete a file, use unlocker, a tool created by Fredirick “Nitch” Collomb http://ccollomb.free.fr/unlocker/


Goodluck on your end!

Friday, November 11, 2011

ssChkBox

I actually created an ssChkBox before as shown in my TreeView To Do module but I easily got tired of its appearance that it actually was not included in the releases of my classes. Finally though, I think this appearance is really "catchy" that I decided to recreate said class, meaning from my old "dirty" approaches into a cleaner and leaner new class.


This actually works just like ssSwitch but there are those who are comfortable in having a checkbox instead of switchbox being it is very familiar to developers and end users alike.  This class caters to that "familiarization" aspect.

Like ssSwitchBox, this can have a logical value of .F. or .T.; or a numeric value of 0 or 1 (patterned after checkbox class).  Unlike ssSwitchBox though, this only have 1 theme so the parameter that needs to be passed is only two, i.e., its caption and its value.

When it is on the checked status, the caption is bold.

In addition, like an ordinary native VFP Objects, you can use its click event to do something.

Shown is the sample form given to subscribers:




Another new spice to make your forms looks "deliciously tasty".  Enjoy!

ssSwitch

ssSwitch is actually a remake of my old Switchbox class, the very first class I made and where the idea of creating several ssclasses later originated. 

For those who are not familiar with that one, SwitchBox class (as well as this one now) is an attempt to replace a checkbox with something unique.  I called this a switch because the appearance seems to switch on and off.


There really is not much difference with a checkbox and a switchbox (or ssSwitch in this case now).  Both can handle a logical values of .T. or .F., or a numeric values of 0 or 1.  Like a checkbox, you decide what you need to use.

Unlike the old Switchbox class however, this new class is cleaner, leaner and better.  I only got two original themes from Switchbox class and created 2 new themes for this one.  To use it, simple double-click it and in its Init event pass 1, 2 or 3 parameters like this:

This._settings( < Caption to use in the switchbox >, < logical or numeric value to start >, < Theme 1, 2,3 or 4 > )

Example:

This._settings("Show \  && Starts with value 1 or ON status and theme 3

Default value is a logical .F. and Theme is 1.

This is also the first class I decided to finally implement calculating the font width so the class' width can auto-adjust based on the length of the caption without developer specifying the width of the class.

And like my latest _ssclasses now, you can get its current value like this:

llValue = this._ssSwitch1.value
lnValue = this._ssSwitch1.value

when it is in the ON status, caption is bold.

In addition, like an ordinary native VFP Objects, you can use its click event to do something.

This will surely "spice-up" the appearance of your forms.

Tuesday, November 8, 2011

Pisang Bakar Virus Removal


Repost from my old site www.junblogs.com

I believe this has been in circulation for a long time as I think I have glimpsed this before on an internet caffe.  But hey, I am only renting it so I cannot properly “touch” that unit.

Today however, one of my IT guys have inserted his flash drive into one newly formatted unit here that does not have any anti-virus yet so presto, PISANG BAKAR infection.  I called one indonesian Manager and asked him what PISANG BAKAR is because I suspected that the word is indonesian and he confirmed it and said that it means banana; what a name for a virus. Well maybe the one who created this is thinking users will go banana over this one, LOL!

Cleaning this, however, is easy but not simple enough because it touches a lot of things.  Let me explain:

a.  Unlike some viruses that totally hides its components, this one is boastful as its show its presence on root drive c: under the filename pisangbakar.exe.  There is a corresponding text file (info.txt) that when opened show a lot of Indonesian words.  Other files follow:

\Windows\WinSetup.bat
\Windows\control32.ini (internal name is oyaba)
\windows\winampa.exe   (created by control32.ini via copy, the sole purpose is so it can be run later).  Winampa.exe is actually a valid name for Winamp player loader but it is never inside windows folder but in Program Files
\windows\system32\svghost.exe (resides in processes.  Use to infect further, recreates pisangbakar.exe and info.txt plus terminates attempt to run msconfig, regedit and task manager)


The standard way I am teaching here is to kill the virus component that is in the process using Task Manager.  But since this virus detects task manager among the processes and auto-kills it, then we need a 3rd party tool.  You can download DTaskManager here:  http://www.snapfiles.com/get/dtaskmanager.html.  Once you downloaded it, run it and use it to kill SVGHOST.EXE.

After SVGHOST.EXE is killed among the processes, you can then proceed with removing all those files mentioned.

b.  Additionally, it changes exe file association into your default media player.  To restore exe to its normal association, copy the codes below and paste it on a notepad.  Afterwards, rename it to any name with an extension of reg (e.g., FixExe.reg):
Source code   
Windows Registry Editor Version 5.00
 
[HKEY_CLASSES_ROOT\.EXE]
@="exefile"
"Content Type"="application/x-msdownload"
 
[HKEY_CLASSES_ROOT\.EXE\PersistentHandler]
@="{098f2470-bae0-11cd-b579-08002b30bfeb}"
 
[HKEY_CLASSES_ROOT\exefile]
@="Application"
"EditFlags"=hex:38,07,00,00
"FriendlyTypeName"=hex(2):40,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,\
00,6f,00,6f,00,74,00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,\
32,00,5c,00,73,00,68,00,65,00,6c,00,6c,00,33,00,32,00,2e,00,64,00,6c,00,6c,\
00,2c,00,2d,00,31,00,30,00,31,00,35,00,36,00,00,00
 
[HKEY_CLASSES_ROOT\exefile\DefaultIcon]
@="%1"
 
[HKEY_CLASSES_ROOT\exefile\shell]
 
[HKEY_CLASSES_ROOT\exefile\shell\open]
"EditFlags"=hex:00,00,00,00
 
[HKEY_CLASSES_ROOT\exefile\shell\open\command]
@="\"%1\" %*"
"IsolatedCommand"="\"%1\" %*"
 
[HKEY_CLASSES_ROOT\exefile\shell\runas]
 
[HKEY_CLASSES_ROOT\exefile\shell\runas\command]
@="\"%1\" %*"
"IsolatedCommand"="\"%1\" %*"
 
[HKEY_CLASSES_ROOT\exefile\shellex]
 
[HKEY_CLASSES_ROOT\exefile\shellex\DropHandler]
@="{86C86720-42A0-1069-A2E8-08002B30309D}"
 
[-HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.exe\UserChoice]

Double-click that newly created registry info so it can restore the exe association back to normal.

c.  This virus creates some more registry entries so it can load itself on boot.  Open regedit and navigate to these entries:

My Computer\HKEY_Local_Machine\SOFTWARE\Microsoft\Shared Tools\MsConfig\Startupreg (delete SVGHOST entry there)

My Computer\HKEY_Local_Machine\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell

Under Shell, entry is this:

Explorer.exe c:\windows\system32\SVGHOST.EXE

Double-click it and just retain Explorer.exe  Do that also on HKEY_USERS (every user’s own settings).

The number of HKEY_USERS entry depends on the number of users you set in your unit.  So navigate to Winlogon of each HKEY_USERS as shown above.

Tip:  If you are getting lazy, just search SVGHOST.EXE inside registry.  Also look for Winsetup.bat.

and that is it!  Reboot your computer and work normally again.

ssEditBox

Since textbox can only hold a limited maximum number of characters and will hide some entries from our eyes if it goes beyond the textbox's current width, then for longer entries we normally use an editbox. However, one thing that I don't like about editboxes is those "eat" space and sometimes it is harder to design the appearance of our forms because we have to give allowance to those.  See image below:


Solution?  Create a dropdown editbox.


This class I called ssEditBox is designed to cater for longer entries that normally requires an editbox. This class appears like an ordinary textbox and consumes space on the form much like an ordinary textbox as well.  The difference is that this can handle longer entries as once the textbox reached the nMaxChar property value (default is 15 characters) then the dropdown editbox will appear and focus will be transferred there so you can continue typing as if you really are typing there in the first place.

You may want to change the value of nMaxChar property other than 15 characters if you have resized the class (made it wider or narrower) so you can estimate the number of characters user will type before it reaches the end of the current textbox width and make it appear that suddenly the dropdown edit box will popup.

Aside from letting the class reach the nMaxChar property for dropdown editbox to appear, you can likewise force the dropdown portion to appear "any time" via pressing down arrow when the class has the focus.  Hiding it back is done either via pressing Esc key, up arrow key or when you click outside of the dropdown editbox.

By default, the dropdown editbox is wider than the textbox.  But when you drag the right edge of the class making it wider than the dropdown editbox portion, the class will auto-compensate adjusting the dropdown portion to be of equal width with the textbox portion.

So there you are, again a very simple yet unique and appealing new class added to the list of growing ssclasses family.

Enjoy!

ssGridLock

I never liked horizontal scrolling capabilities of grids because I wanted everything to be seen outright without the need to scroll.  So I never used grid column locking before and most of my classes that deals with grids is designed without horizontal scrollbar in mind like ssAnchorSizer.

But, taste and need changes and in one of my modules I am forced to put a grid where some columns are hidden and the need to scroll horizontally cannot be avoided.  And since I don't want to guess "where" I am when I scroll to the right, I need to lock columns on the left.  And with that need arises ssGridLock class.





Using it is very easy like my ssGridSorter class.  Just bind the grid you wanted to attach to that column locking capability like this (on class Init event):

This._GridName = "Grid1"

By default, it will lock the 1st column of the grid but you can adjust it to initially show more than one column locked also via init event like this:

This.Value = 2  && locks 2 columns initially

Or via its value property on the PEM window.

This class will create a lock image on the column of your grid so you will know which column is currently locked.

And since it is included with a spinner, you can change locking dynamically on run by changing the spinner value up or down or by manually keying in the  number of columns to be locked.

Like my other grid classes, the class and the grid should be on the same container.  So a grid in the form must have that class on the form as well.  If the grid is inside a container object, then the class should also be inside that container.  If the grid is inside a page, the class should also be in that same page.