Wednesday, November 30, 2016

RTF Keyword Highlighting

In 2009 I started playing with an RTF control and I created one organizer for my own need to store articles and any other useful info I can find in the web for later offline reading and reference.  I decided to do that because most of the time we don't have good internet here.

Well I was reworking the previous days on that old DevOrg app which consisted of a treeview and an RTF activeX controls as I decided to finally give it a filtering capability, insertion of image with rescaling and quality reduction, reworking the icon panel to look like a ribbon, etc.; and along the way, I thought of allowing it to highlight the words I typed to filter the threads and nodes of treeview.  So I can see outright where those are, like this:

The trick is to work behind the scene on its RTF codes. Here is the method I created for that:

*_HighLight Method

Lparameters cWord
LOCAL lcTable
lcTable = thisform._currenttable
   * Insert highlight color
   lcRTFSource = Strtran(rtftext,'}}','}}'+Chr(13)+'{\colortbl ;\red0\green255\blue0;}')
   * Add new highlightings.  Check proper, small, all caps
   lcRTFSource = Strtran(m.lcRTFSource,m.cWord,'\highlight1 '+m.cWord+'\highlight0 ')
   lcRTFSource = Strtran(m.lcRTFSource,Upper(m.cWord),'\highlight1 '+Upper(m.cWord)+'\highlight0 ')
   lcRTFSource = Strtran(m.lcRTFSource,Lower(m.cWord),'\highlight1 '+Lower(m.cWord)+'\highlight0 ')
   lcRTFSource = Strtran(m.lcRTFSource,Proper(m.cWord),'\highlight1 '+Proper(m.cWord)+'\highlight0 ')
   Thisform.corTF.olerTF.textRTF = rtftext

If you notice, I have used three (3) possible cases, i.e., UPPER(), LOWER() and PROPER().  The problem is I can't force the RTF codes to any of these cases alone to ensure I can highlight everything as that will also affect the output.  So say I filter threads for entries with the word "javascript", then it can find and highlight words with javascript, JAVASCRIPT and Javascript.  But not JavaScript.

While I can instruct it with another function/method to look for any other transmutation of the word like JavaScript, JAvascript, jaVaScript, etc., I think that is an overkill for this simple need of mine.

So anyway, I am just showing here the trick on how to achieve that in case you use and RTF tool on your end and wanted to have the same on your end.  Cheers!

Monday, November 14, 2016

HoverButton Class

Another button class for my need which may come handy to my subscribers as well.

So why make another one?  What is the main difference with this one vs say ButtonX?

On my BizCore ERP app, I use TreeView for my menu as I can easily control there what can be shown per user by hiding/removing nodes they should not be of concern.  See ERP app below:

However, for comparably smaller app like my Gift Voucher one, my GUI approach is different where I use background images plus images representing as button icons.  Why this design?  First, I want to give my users the capability to change wallpaper via a simple double-click.  That adds to user satisfaction because they won't be tied up with an appearance that they may not like as each user has his/her own taste.  Another is to make the app look bigger, LOL!  Here is that app showing different look impact by simply changing wallpapers.

And for that design, I need to have a button that will appear transparent and so this new control class.  ButtonX can be made transparent too via making nTheme parameter 0 (zero) and nLineSpecialEffect = 3.  However, when you do that, you won't see any hover effect (glowing blue) I did on MouseEnter here because that is tied up on the theme image which we ignored for transparency sake.   And so it is a bit harder to see where you are except on relying on the mouse pointer.

Unlike my other button classes, I made this one simpler via allowing the use of PEM instead of us typing This._setting(....) inside the class init.  So you can go to PEM and change its Picture, Caption, Enabled and ToolTipText.   Speaking of Enabled, when the class is toggled to disable, then these two (2) properties will have an effect on its appearance:

1.  _noHighlight (Default is .T.)  - When the class gets disabled, you won't see the hover effect of that glowing blue background.  Turn it to .F. to show that hover effect even if the class is disabled.

2.  _ShowLock (Default is .T.) - When the class gets disabled, a lock icon will appear on its top as additional visual guide.  If you don't want this, turn this property into .F.

Well that is it!  This is now part of ssUltimate.  Visit What's on ssUltimate Library for the list of classes inside ssUltimate.

Thursday, November 10, 2016

Tick/Untick Checkboxes on Grid with AllowCellSelection = .F. - Part II

Last time I have shown how to employ ticking/unticking of checkboxes on Grid with AllowCellSelection = .F. via utilizing MouseDown event of Grid.  So what makes this different than the first trick?  The first trick relies on Relative Column of Grid.  And this poses a problem when the columns are reordered via dragging into new position as Relative Column  will then change.

So it is not that foolproof and only will work when you don't rearrange the column orders.  This one though fixes that as this is no longer based on the relative column's position but will be basing on the ControlSource of that column.

Here is the sample code:

Local oForm
Read Events

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

      Add Object grid1 As Grid With ;
            GridLines = 0, ;
            Height = 380, ;
            Left = 10, ;
            Top = 70, ;
            Width = 390,;
            GridLines = 3,;
            DeleteMark = .F.,;
            ScrollBars = 2,;
            ColumnCount = 4,;
            AllowCellSelection = .F.

      Add Object label2 As Label With ;
            top = 10,;
            left = 15,;
            Height = 46,;
            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 = 370,;
            Forecolor = RGB(255,0,0)

      Procedure Load
      Close Databases All
      Create Cursor junk (Products C(10), PickedUp L, Sold L, Returned L)
      Insert Into junk (Products) Values ('Apple')
      Insert Into junk (Products) Values ('Orange')
      Insert Into junk (Products) Values ('Mango')
      Insert Into junk (Products) Values ('Guava')
      Insert Into junk (Products) Values ('Banana')
      Go Top

      Procedure grid1.Init
      Local lnloop, lcColumn
      With This
            .RecordSourceType = 1
            .RecordSource = 'junk'
            .Column1.Header1.Caption = 'PRODUCTS'

            For lnloop = 2 To 4
               lcColumn = '.Column'+TRANSFORM(m.lnloop)
               WITH EVALUATE(m.lcColumn)
                        .CurrentControl = "check1"
                        .Sparse = .F.
                        .check1.Caption = ''
                        .check1.Visible = .T.
                        .Alignment = 2
                        .Width = 93
                        .Header1.Caption = FIELD(m.lnloop)
                        .Header1.Alignment = 2

      Procedure grid1.MouseDown
      Lparameters nButton, nShift, nXCoord, nYCoord

      Local lnWhere, lnRelRow, lnRelCol, loColumnsControl, lcSource, loColumn

      lcSource = ''
      For Each loColumn In This.Columns
            If loColumn.ColumnOrder = m.lnRelCol
                  lcSource = Upper(Getwordnum(loColumn.ControlSource,2,'.'))
            Do Case
                  Case m.lcSource = "PICKEDUP"
                        Replace PickedUp With !PickedUp
                        WAIT WINDOW 'You toggled Pickedup Column' NOWAIT
                  Case m.lcSource = "SOLD"
                        Replace Sold With !Sold
                        WAIT WINDOW 'You toggled Sold Column' NOWAIT
                  Case m.lcSource = "RETURNED"
                        Replace Returned With !Returned
                        WAIT WINDOW 'You toggled Returned Column' NOWAIT

      Procedure Destroy
      Clear Events


I have added a WAIT WINDOW here so you can visually see that it does change the proper underlying field.  Hope this comes useful to you!  Cheers!

Monday, October 31, 2016


Sorry, this is not about software developing.  I just wanted to create this entry here for my latest hobby which is pencil drawings.

When I was young (in elementary and highschool), I used to draw using a ballpen.  Then I stopped as my focus went elsewhere.  That was 29 years ago.

Last month, for whatever reason I decided to see if my hands are still there.  So I ordered a pastel color pencil in ebay and started making some sketches where immediately after completion, I posted it on my wall.  And while I deem my output as elementary, my friends say they love those.

Since I realize I don't have the patience required of a real artist as I want to draw and finish whatever I am working within just a few hours, I put aside my pastel (I realize that requires patience) and  I decided to work on pure pencils as making shadows there are easier.  While I do not have the proper grades (I lack 7b, 8b and 9b for darker ones), my friends also loved those as well so they started requesting I draw them.  And I did.

One time I decided to draw my departed brother.  Heck if I can take time to draw my friends, I will spend time to draw my loved ones too.  I have to draw him twice before I believe I got an acceptable output.  Today I decided to see how it will look like when in color.... so Photoshop color layering.  Below is the source pencil and photoshop output

Well I think I have done good here.

Wednesday, May 18, 2016

Why I am never a Loyalist (a Political Issue)

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.
Related Posts Plugin for WordPress, Blogger...