Monday, March 31, 2014

Highlighting Pageframe ActivePage

Aesthetics is something that always fall to individual tastes. Some wanted their app to simply follow the OS theme, others want it to look plain, yet others like me wants to make it a bit colorful or somewhat unique thinking it will spice up the app.

However, sometimes we tend to overdo the look.  For example, in the past I tend to create a pageframe with several pages each having its own colors (theme should be set to .F. otherwise the color will be ignored). In the first glance, things look cool to my taste but then in the end either I simply turn the theme back on because I get tired of the multitude of colors or I just retain one color for all pages with theme still set to .F.



But then, I thought we can play a bit with a colored page of a pageframe by making only the active page different in color.  The purpose is to make it simpler yet with added effect, i.e., a page changes to the selected color while the rest goes back to the standard one. This serves as a sort of beacon or a way of highlighting a pageframe's active page.  See images below to picture what I am talking about:


The trick is simple, so if you are interested to have the same, just see the sample codes.  Cheers!

Public oFrm
oFrm=Createobject("MyForm")
oFrm.Show()

Define Class MyForm As Form
      AutoCenter = .T.
      Width = 400
      Height = 140
      Caption = 'Page Highlighter'
      Add Object PgFrame1 As MyPageFrame
Enddefine

Define Class MyPageFrame As PageFrame
      PageCount=0
      Top = 10
      Left = 10
      Height = 120
      Themes = .F.
      TabStyle = 1

      Add Object Page1 As MyPage
      Add Object Page2 As MyPage
      Add Object Page3 As MyPage
      Add Object Page4 As MyPage
      Add Object Page5 As MyPage
      Add Object Page6 As MyPage
Enddefine

Define Class MyPage As Page
      Procedure Activate
            This.Parent.SetAll('Backcolor',Rgb(236,233,216),'MyPage')
            This.BackColor = Rgb(191,223,255)
      Endproc

Enddefine


2 comments: