Tuesday, May 20, 2014

otCalendar Library

What is otCalendar?

ot stands for OnyToo, the name used by the original contributor of this library inside Foxite.  This library, for those who are not familiar yet with this, has two control class, i.e., _calendar and _datepicker.

I actually preferred this over my own datepicker class as his approach on the dropdown portion has appealed very much to me being not constrained to the boundaries of the parent form where the datepicker will be dragged into.  So I ditched my class and use this instead on my own project.

What is new here?

I tried my best to retain the core designs of OnyToo's calendar library and just added some things that appeals to my taste now.  Here are what has been changed/added:
  • Removed the skin I added before, I also removed the extra shape that comes originally with said library.  I changed the background of the calendar control class to plain white.
  • Change of fonts from Tahoma 8 to Calibri 10 as Calibri appeals more to me these days especially on numbers
  • Made the dropdown form wider adding a portion showing the currently selected day in big number plus the day and month below it.  
  • Added capability to change/add holidays on the ply via utilizing Right-Click of the days.
  • Added capability to also include notes via Right-Click on the days as well
  • Added visual clues to diffirentiate the days

Here is the adjusted look:


Monday, May 19, 2014

Word Automation - Create Table, Merge Cells

I was pondering a question inside foxite forum about word automation because of the handicap presented by MS that when recording a macro in Word, objects cannot be clicked using mouse.

So the first solution that I can think of is to use keyboard as that is still allowed and that to customize Quick Access Toolbar to include an icon for merging so I can click (and merge cells) for later reviewing of macro recordings.  And this resulted to these codes:

Sub Macro1()
'
' Macro1 Macro
'
'
    ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=3, NumColumns:= _
        5, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
        wdAutoFitFixed
    With Selection.Tables(1)
        If .Style <> "Table Grid" Then
            .Style = "Table Grid"
        End If
        .ApplyStyleHeadingRows = True
        .ApplyStyleLastRow = False
        .ApplyStyleFirstColumn = True
        .ApplyStyleLastColumn = False
        .ApplyStyleRowBands = True
        .ApplyStyleColumnBands = False
    End With
    Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
    Selection.MoveRight Unit:=wdCharacter, Count:=2, Extend:=wdExtend
    Selection.Cells.Merge

End Sub

From there we can get the values of the constant by right-clicking on a constant word and choosing Quick Info.  Then later cleaning up the codes.  But I don't like the way it shows that we have to move this way and that so believing there is a way to reference the cells of the table directly as we do in Excel, I continued by surfing hoping to find any codes (VFP, VB, C#, etc.) that we can study, clean and convert into VFP.

Wednesday, May 14, 2014

3rd party apps within our forms - Detaching


Yesterday, I gave you the ways to place a 3rd party app inside our form.  Today though I thought "What if my users want to work on those excel file outside on its own after I have shown those inside my form?".  And so I decided to find a way to detach those back outside.

This appears to be comparatively easier because we already have the codes to bring those inside our forms.  All we need to do is ensure that we restore all those restrictions we first implemented before detaching it:

With Thisform._oexcel
      .DisplayFormulaBar = .T.
      .DisplayStatusBar = .T.
      .ActiveWindow.DisplayWorkbookTabs=.T.
      .ActiveWindow.DisplayHeadings=.T.

      .ActiveWindow.DisplayWorkbookTabs=.T.
      .ActiveWindow.WindowState = -4137  && xlMaximized
      .Application.ShowWindowsInTaskbar=.T.

      Local loRibbon
      loRibbon =.CommandBars.Item("Ribbon")
      If m.loRibbon.Height > 0
            .ExecuteExcel4Macro('Show.Toolbar("Ribbon",True)')
      Endif

Endwith

So far so good, now since we have a handle on said excel's window which is stored on a form property _nHwnd, we can do something like this:

SetParent(Thisform._nHwnd,_Screen.HWnd)

And great, Excel has been detached.  But the manipulation on Excel's window style is still in place meaning no titlebar and not resizable still.  We therefore should restore those back to its original WindowStyle as well and here are the codes:

Tuesday, May 13, 2014

3rd party apps from within our forms


It is now 1:30am and I still can't sleep again so let us make my time a bit useful.

Inspired by what Bernard Bout has shown here, I decided to see earlier today how it can be done on an excel instance.  Please read it (click on here word above) before proceeding below as I will try to break things apart for our better understanding.

The barest tools of the Trade

- a shape on our form
- SetParent
- WinExec
- FindWindow
- SetWindowPos

Bernard has given us a great starting point because the basic ingredients are already there.  And I agree and actually appreciated that Bernard has not shown all the tricks for if he has, I won't try to maybe understand some of those and simply will use the trick blindly; and I won't get a better understanding of those.

Let us start deconstruction and reconstruction:

WinExec the only way?

Monday, May 5, 2014

More Objects in a Grid Cell - Part III

I shared last time a way to show several objects within a grid's cell and I was surprised that it landed 2nd on my top posts.  Said tutorial and sample uses 4 containers, if I can recall properly, and usage of DynamicCurrentControl.  I did that when I was still in the process of experimenting on my assets masterfile module of which I use a grid with 3 columns with each columns showing different info:

Friday, May 2, 2014

Health Benefits - Super Fruits - Part I

One constant problem that I have is hypertension.  Originally I was given 5mg amlodipine (I won't name the brand) and I constantly argued with my sister who is a head nurse and my mother.. and oh plus my wife... that it does nothing to improve my condition. But one time in December last year I got really sick when I recorded an all time score of 199/113.   Yippee!!!!  Well I sometimes get a higher Diastolic such as 130 but that is the first time my Systolic reached 199 (see http://en.wikipedia.org/wiki/Blood_pressure).  Only one worm less waiting for a pen?

Anyway, that forced me to experiment increasing my intake from that 5mg to the whole 10mg on that day.  And immediately I felt better (plus 1 hour exercise over my stationary bike to sweat out whatever it is that needs to be sweat out).  Although I do not recommend that you guys do an exercise when having an HBP.  Majority cautions against it.

Improper Dosage

Saturday, April 26, 2014

GOMONTH() on an End Of Month, Beware!!!

What is GOMONTH() Function?

GOMONTH() gives us the ability to move forward/backward on a specified number of months before or after a given Date or Date/Time expression:

Create Cursor junk (xdate d)
ldBase = Date(2014,1,1)
For lnloop = 1 To 12
      Insert Into junk Values (GOMONTH(m.ldBase,1))
      ldBase = xdate
Next
Browse Normal

I have been comfortably using GOMONTH() without any thought of its known bug which is that it returns empty dates before 09/14/1752 because I definitely won't need to go way back that far for any date requirements.

However, I expect that when I perform GOMONTH() on end of month dates, that it will return the end of months of the succeeding months as well.  A fellow Foxite member Gene Wirchenko mentioned that it does not that if dates fall between 28 to 30 (February 28 & 29 plus months that ends on 30), succeeding dates will show the same day; not the end of month.   I tested now and he is right:

Related Posts Plugin for WordPress, Blogger...