Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Page.Activate and uiEnable
Message
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00847372
Message ID:
00848526
Views:
10
Bill,

There are five key events and methods to control the activation (showing) of a page. I'am including code to get you started. There's a method in the page class named AllowPageChange. This is where you would place code to validate the user has logged on. If logged on return TRUE else return FALSE. Let me know if you have any questions. I've spent much time studying pageframes and pages.

Here's the list of events and methods:

PageFrame - MouseDown
PageFrame - Click
Page - Activate
Page - Deactivate
Page - KeyPress

Here's the PageFrame code:
DEFINE CLASS _pageframe AS PAGEFRAME
  ERASEPAGE = .T.
  MEMBERCLASSLIBRARY = "sys_classes.prg"
  MEMBERCLASS = "App_Page"
  PAGECOUNT = 0
  ACTIVEPAGE = 0
  nlastactivepage = 0
  nlastpagecount = 0
  lcheckdatastateonpagechange = .T.
  NAME = "_pageframe"
  ldestroying = .F.
  ltabpagechange = .F.
  lintializeonactivatepage = .F.
  lshowonactivatepage = .F.

********************************************
****** New Procedure
********************************************
  PROCEDURE ispage
  LPARAMETERS tnPageNumber
  RETURN THIS.PAGECOUNT > 0 ;
    AND tnPageNumber > 0 ;
    AND tnPageNumber <= THIS.PAGECOUNT ;
    AND VARTYPE(THIS.PAGES(tnPageNumber))="O"
  ENDPROC

********************************************
****** New Procedure
********************************************
  PROCEDURE refreshpage
  WITH THIS
    IF .IsPage(.ACTIVEPAGE)
      .PAGES(.ACTIVEPAGE).RefreshInterface()
    ENDIF
  ENDWITH
  ENDPROC

********************************************
****** New Procedure
********************************************
  PROCEDURE MOUSEDOWN
  LPARAMETERS nButton, nShift, nXCoord, nYCoord
  THIS.nMouseDownActivePage = THIS.ACTIVEPAGE
  ENDPROC

********************************************
****** New Procedure
********************************************
  PROCEDURE CLICK
  LPARAMETERS nButton, nShift, nXCoord, nYCoord
  WITH THIS
    IF NOT .ACTIVEPAGE=.nMousedownActivePage
* We have just changed to a new page
      THISFORM.LOCKSCREEN = .F.
      THIS.RefreshPage()
    ENDIF
    .nMousedownActivePage = 0
  ENDWITH
  ENDPROC

********************************************
****** New Procedure
********************************************
  PROCEDURE initializepage
  LOCAL llReturn
  llReturn=.T.
  WITH THIS
    IF .IsPage(.ACTIVEPAGE)
      llReturn = .PAGES(.ACTIVEPAGE).InitializePage()
    ENDIF
  ENDWITH
  RETURN llReturn
  ENDPROC
ENDDEFINE
Here's the Page code:
DEFINE CLASS App_Page AS PAGE
  cError                   = ""
  lError                   = .F.
  FONTSIZE                 = 8
  OLEDROPMODE              = 2
  cStatusBarPageName       = ""
  cViewAlias               = ""
  lDestroying              = .F.
  lPageDataLoaded          = .F.
  lDataRequeryed           = .F.
  lPageInterfaceLoaded     = .F.
  lPageInitialized         = .F.
  lIntializeOnActivatePage = .F.
  lShowOnActivatePage      = .F.
  lRefreshOnShowPage       = .T.

********************************************
****** New Procedure
********************************************
  PROCEDURE GOTFOCUS
*fires after the user clicks a different page tab and that page's controls are now visible.
  WITH THIS
    THISFORM.LOCKSCREEN = .F.
    .RefreshInterface()
  ENDWITH
  ENDPROC

********************************************
****** New Procedure
********************************************
  PROCEDURE InitializePage
  WITH THIS
    IF NOT .lPageInitialized
      .lPageInitialized = .LoadData() AND .LoadInterface()
    ENDIF
  ENDWITH
  RETURN THIS.lPageInitialized
  ENDPROC

********************************************
****** New Procedure
********************************************
  PROCEDURE ShowPage
  LOCAL llReturn
  llReturn = .T.
  WITH THIS
    llReturn = .InitializePage()
    IF .lRefreshOnShowPage AND llReturn
      llReturn = .RefreshInterface()
    ENDIF
  ENDWITH
  RETURN llReturn
  ENDPROC

********************************************
****** New Procedure
********************************************
  PROCEDURE ActivatePage
** Do anything everytime a page is activated
  ENDPROC

********************************************
****** New Procedure
********************************************
  PROCEDURE ActivatePageNoShow
** Do anything everytime a page is activated
  WITH THIS
    IF .lIntializeOnActivatePage ;
        AND NOT .lPageInitialized
      .InitializePage()
    ENDIF
    IF .lPageInitialized ;
        AND .lShowOnActivatePage
      .ShowPage()
    ENDIF
  ENDWITH
  ENDPROC

********************************************
****** New Procedure
********************************************
  PROCEDURE AllowPageChange
  RETURN .T.
  ENDPROC

********************************************
****** New Procedure
********************************************
  PROCEDURE ACTIVATE
  WITH THIS
    IF NOT .lDestroying
      .ActivatePage()
      IF .PARENT.lTabPageChange ;
          OR (.PARENT.nMousedownActivePage>0 ;
          AND NOT .PARENT.nMousedownActivePage=.PARENT.ACTIVEPAGE)
* the page has been changed 
        .PARENT.lTabPageChange = .F.
        IF NOT .lPageInitialized
          .InitializePage()
        ENDIF
        IF .lPageInitialized
          .ShowPage()
        ENDIF
      ELSE
        .ActivatePageNoShow()
      ENDIF
    ENDIF
  ENDWITH
  ENDPROC

********************************************
****** New Procedure
********************************************
  PROCEDURE DEACTIVATE
  WITH THIS
    IF NOT .lDestroying
      IF .PARENT.nMousedownActivePage>0 ;
      OR .PARENT.lTabPageChange = .T. && A page tab has been clicked
* the user has clicked on a different page tab and about to turn the page
        IF NOT .AllowPageChange()
          NODEFAULT
        ELSE
          THISFORM.LOCKSCREEN = .T.
        ENDIF
      ENDIF
    ENDIF
  ENDWITH
  ENDPROC

********************************************
****** New Procedure
********************************************
  PROCEDURE KEYPRESS
  LPARAMETERS nKeyCode, nShiftAltCtrl
  WITH THIS
    IF  NOT .lDestroying
      .PARENT.lTabPageChange = .F.
      IF nKeyCode=148 OR (TYPE('THIS.ActiveControl') # 'O' ;
      AND INLIST(nKeyCode,4,19))
*The user wants to turn the page using the arrow keys or CTRL-Tab
        IF NOT .AllowPageChange()
          NODEFAULT
        ELSE
          .PARENT.lTabPageChange = .T.
        ENDIF
      ENDIF
    ENDIF
  ENDWITH
  ENDPROC
ENDDEFINE
>Hi Will,
>I'm trying to prevent access to certain pages until the user has logged into a web-site. Page1 has the Log In controls. So if the user clicks on the Page3 tab, I want a messagebox to tell them that they can't get onto that page until they have Logged In, and then put the focus on Page1 where they can Log In.
>
>I tried setting page3.enabled=.F., but then I can't put the messagebox up. Page3.Activate() seems like the most logical place to put it.
>
>
>
>>Bill,
>>
>>What are you trying to do? The page activate event and uienable event fire far too often for placing code in.
>>
>>There are only certain times you should need to enable a control on a page:
>>
>>The user clicked on a page tab to TURN a page
>>
>>or
>>
>>The cursor is sitting on a page tab and the user hits the arrow left or right key or the page down or page up key.
>>
>>These are the only times when a user is actually TURNING a page.
>>
>>>I'm using VFP 7.0
>>>
>>>Is there any difference between these 2 code samples?
>>>
>>>......Page3.Activate()
>>>  This.myControl.Enabled = Thisform.SomeProperty
>>>
>>>
>>>......Page3.myControl.UIEnable
>>>LPARAMETERS lEnable
>>>if lEnable
>>>  this.Enabled = Thisform.SomeProperty
>>>endif
>>>
Heavy Metal Pedal - click with care
Previous
Reply
Map
View

Click here to load this message in the networking platform