[VFPP] Include actual value in ArgumentOutofRangeException

//
// Copyright (c) XSharp B.V.  All Rights Reserved.
// Licensed under the Apache License, Version 2.0.
// See License.txt in the project root for license information.
//

USING XSharp.Internal

FUNCTION __FoxFillArray(uArray AS USUAL, uValue AS USUAL) AS USUAL
    IF IsArray(uArray)
        LOCAL oldArray := uArray AS ARRAY
        IF oldArray IS __FoxArray VAR foxArray
            foxArray:__Fill(uValue)
        ENDIF
    ENDIF
    RETURN uArray

FUNCTION __FoxRedim(uCurrent AS USUAL, nRows AS DWORD, nCols := 1 AS DWORD) AS __FoxArray
    LOCAL result := NULL AS __FoxArray
    IF IsArray(uCurrent)
        LOCAL oldArray := uCurrent AS ARRAY
        IF oldArray IS __FoxArray VAR foxArray
            result := foxArray:ReDim(nRows, nCols)
        ENDIF
    ENDIF
    IF result == NULL
        result := __FoxArray{nRows, nCols}
    ENDIF
    RETURN result

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/alen/*" />
FUNCTION ALen(a AS __FoxArray, nArrayAttribute AS LONG) AS DWORD
    SWITCH nArrayAttribute
    CASE 1
        RETURN (DWORD) a:Rows
    CASE 2
        IF a:MultiDimensional
            RETURN (DWORD) a:Columns
        ELSE
            RETURN 0
        ENDIF
    OTHERWISE
        RETURN (DWORD) a:Count
    END SWITCH

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/alen/*" />
FUNCTION ALen(a AS __FoxArray) AS DWORD
    RETURN ALen(a, 0)

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/aelement/*" />
FUNCTION AElement(ArrayName AS __FoxArray, nRowSubscript AS DWORD) AS USUAL
   IF ( nRowSubscript > 0 .AND. nRowSubscript <= ArrayName:Rows )
      RETURN nRowSubscript
   ENDIF
   THROW ArgumentOutOfRangeException { nameof(nRowSubscript),nRowSubscript, "'nRowSubscript' number is out of range"}

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/aelement/*" />
FUNCTION AElement(ArrayName AS __FoxArray, nRowSubscript AS DWORD, nColumnSubscript AS DWORD) AS USUAL
    IF ArrayName:MultiDimensional
        IF nRowSubscript == 0 .OR. nRowSubscript >  ArrayName:Rows
           THROW ArgumentOutOfRangeException { nameof(nRowSubscript), nRowSubscript, "'nRowSubscript' number is out of range" }
        ELSEIF nColumnSubscript == 0 .OR. nColumnSubscript > ArrayName:Columns
           THROW ArgumentOutOfRangeException { nameof(nColumnSubscript), nColumnSubscript, "'nColumnSubscript' number is out of range" }
        ENDIF
        nRowSubscript --
        RETURN ( nRowSubscript * ArrayName:Columns ) + nColumnSubscript
    ENDIF
THROW ArgumentException { "a one-dimensional array has no columns"}

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/adel/*" />
FUNCTION ADel(ArrayName AS __FoxArray, nElementNumber AS LONG, nDeleteType := 2 AS LONG) AS DWORD
    IF ! ArrayName:MultiDimensional
        ArrayName:Delete((LONG) nElementNumber)
    ELSE
        IF nDeleteType == 2
            ArrayName:DeleteColumn( (LONG) nElementNumber)
        ELSE
            ArrayName:DeleteRow((LONG) nElementNumber)
        ENDIF
    ENDIF
    RETURN 1

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/asubscript/*" />
FUNCTION ASubScript(ArrayName AS __FoxArray, nElementNumber AS DWORD, nSubscript := 1 AS DWORD) AS DWORD
    IF !ArrayName:MultiDimensional
        IF nSubscript == 1 .and. nElementNumber <= (DWORD) ArrayName:Count
            RETURN nElementNumber
        ENDIF
    ELSE
       IF nElementNumber <= ArrayName:Rows * ArrayName:Columns
            // assume an array of 5 * 3
            // element 3 should be on row 1, column 3
            // element 4 should be on row 2, column 1
            // max element = 15
           IF nSubscript == 1
                // calculate the row
                RETURN (DWORD) ArrayName:GetRow((LONG) nElementNumber)
           ELSE
                // calculate the column
                RETURN (DWORD) ArrayName:GetColumn((LONG) nElementNumber)
           ENDIF
        ENDIF
    ENDIF
    RETURN 0

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/ains/*" />
FUNCTION AIns(ArrayName AS __FoxArray, nElementNumber AS DWORD, nInsertType := 1 AS DWORD) AS DWORD
    IF !ArrayName:MultiDimensional
        IF nInsertType == 1 .and. nElementNumber <= (DWORD) ArrayName:Count
            ArrayName:Insert((LONG) nElementNumber)
        ENDIF
    ELSE
        IF nInsertType == 2
            ArrayName:InsertColumn( (LONG) nElementNumber)
        ELSE
            ArrayName:InsertRow((LONG) nElementNumber)
        ENDIF
    ENDIF
    RETURN 0

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/asize/*" />
FUNCTION ASize(ArrayName AS __FoxArray, nSize AS DWORD) AS __FoxArray
    ArrayName:Resize((LONG) nSize)
    RETURN ArrayName

//
// Copyright (c) XSharp B.V.  All Rights Reserved.
// Licensed under the Apache License, Version 2.0.
// See License.txt in the project root for license information.
//

USING XSharp.Internal

FUNCTION __FoxFillArray(uArray AS USUAL, uValue AS USUAL) AS USUAL
    IF IsArray(uArray)
        LOCAL oldArray := uArray AS ARRAY
        IF oldArray IS __FoxArray VAR foxArray
            foxArray:__Fill(uValue)
        ENDIF
    ENDIF
    RETURN uArray

FUNCTION __FoxRedim(uCurrent AS USUAL, nRows AS DWORD, nCols := 1 AS DWORD) AS __FoxArray
    LOCAL result := NULL AS __FoxArray
    IF IsArray(uCurrent)
        LOCAL oldArray := uCurrent AS ARRAY
        IF oldArray IS __FoxArray VAR foxArray
            result := foxArray:ReDim(nRows, nCols)
        ENDIF
    ENDIF
    IF result == NULL
        result := __FoxArray{nRows, nCols}
    ENDIF
    RETURN result

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/alen/*" />
FUNCTION ALen(a AS __FoxArray, nArrayAttribute AS LONG) AS DWORD
    SWITCH nArrayAttribute
    CASE 1
        RETURN (DWORD) a:Rows
    CASE 2
        IF a:MultiDimensional
            RETURN (DWORD) a:Columns
        ELSE
            RETURN 0
        ENDIF
    OTHERWISE
        RETURN (DWORD) a:Count
    END SWITCH

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/alen/*" />
FUNCTION ALen(a AS __FoxArray) AS DWORD
    RETURN ALen(a, 0)

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/aelement/*" />
FUNCTION AElement(ArrayName AS __FoxArray, nRowSubscript AS DWORD) AS USUAL
   IF ( nRowSubscript > 0 .AND. nRowSubscript <= ArrayName:Rows )
      RETURN nRowSubscript
   ENDIF
   THROW ArgumentOutOfRangeException { nameof(nRowSubscript),"'nRowSubscript' number is out of range"}

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/aelement/*" />
FUNCTION AElement(ArrayName AS __FoxArray, nRowSubscript AS DWORD, nColumnSubscript AS DWORD) AS USUAL
    IF ArrayName:MultiDimensional
        IF nRowSubscript == 0 .OR. nRowSubscript >  ArrayName:Rows
           THROW ArgumentOutOfRangeException { nameof(nRowSubscript),"'nRowSubscript' number is out of range" }
        ELSEIF nColumnSubscript == 0 .OR. nColumnSubscript > ArrayName:Columns
           THROW ArgumentOutOfRangeException { nameof(nColumnSubscript),"'nColumnSubscript' number is out of range" }
        ENDIF
        nRowSubscript --
        RETURN ( nRowSubscript * ArrayName:Columns ) + nColumnSubscript
    ENDIF
THROW ArgumentException { "a one-dimensional array has no columns"}

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/adel/*" />
FUNCTION ADel(ArrayName AS __FoxArray, nElementNumber AS LONG, nDeleteType := 2 AS LONG) AS DWORD
    IF ! ArrayName:MultiDimensional
        ArrayName:Delete((LONG) nElementNumber)
    ELSE
        IF nDeleteType == 2
            ArrayName:DeleteColumn( (LONG) nElementNumber)
        ELSE
            ArrayName:DeleteRow((LONG) nElementNumber)
        ENDIF
    ENDIF
    RETURN 1

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/asubscript/*" />
FUNCTION ASubScript(ArrayName AS __FoxArray, nElementNumber AS DWORD, nSubscript := 1 AS DWORD) AS DWORD
    IF !ArrayName:MultiDimensional
        IF nSubscript == 1 .and. nElementNumber <= (DWORD) ArrayName:Count
            RETURN nElementNumber
        ENDIF
    ELSE
       IF nElementNumber <= ArrayName:Rows * ArrayName:Columns
            // assume an array of 5 * 3
            // element 3 should be on row 1, column 3
            // element 4 should be on row 2, column 1
            // max element = 15
           IF nSubscript == 1
                // calculate the row
                RETURN (DWORD) ArrayName:GetRow((LONG) nElementNumber)
           ELSE
                // calculate the column
                RETURN (DWORD) ArrayName:GetColumn((LONG) nElementNumber)
           ENDIF
        ENDIF
    ENDIF
    RETURN 0

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/ains/*" />
FUNCTION AIns(ArrayName AS __FoxArray, nElementNumber AS DWORD, nInsertType := 1 AS DWORD) AS DWORD
    IF !ArrayName:MultiDimensional
        IF nInsertType == 1 .and. nElementNumber <= (DWORD) ArrayName:Count
            ArrayName:Insert((LONG) nElementNumber)
        ENDIF
    ELSE
        IF nInsertType == 2
            ArrayName:InsertColumn( (LONG) nElementNumber)
        ELSE
            ArrayName:InsertRow((LONG) nElementNumber)
        ENDIF
    ENDIF
    RETURN 0

/// <include file="VfpRuntimeDocs.xml" path="Runtimefunctions/asize/*" />
FUNCTION ASize(ArrayName AS __FoxArray, nSize AS DWORD) AS __FoxArray
    ArrayName:Resize((LONG) nSize)
    RETURN ArrayName


source/QtTest: updated

source/QtTest: updated

Modified:
source/QtTest/QTestEventList.prg

/*

  Qt4xHb - Bindings libraries for Harbour/xHarbour and Qt Framework 4

  Copyright (C) 2020 Marcos Antonio Gambeta <marcosgambeta AT outlook DOT com>

*/

/*
  DO NOT EDIT THIS FILE - the content was created using a source code generator
*/

#include "hbclass.ch"

#ifndef QT4XHB_NO_REQUESTS
#endif

CLASS QTestEventList

   DATA pointer
   DATA self_destruction INIT .F.

   METHOD new
   METHOD delete
   METHOD addDelay
   METHOD addKeyClick1
   METHOD addKeyClick2
   METHOD addKeyClick
   METHOD addKeyClicks
   METHOD addKeyPress1
   METHOD addKeyPress2
   METHOD addKeyPress
   METHOD addKeyRelease1
   METHOD addKeyRelease2
   METHOD addKeyRelease
   METHOD addMouseClick
   METHOD addMouseDClick
   METHOD addMouseMove
   METHOD addMousePress
   METHOD addMouseRelease
   METHOD clear
   METHOD simulate

   METHOD newFrom
   METHOD newFromObject
   METHOD newFromPointer
   METHOD selfDestruction
   METHOD setSelfDestruction

   DESTRUCTOR destroyObject

END CLASS

PROCEDURE destroyObject() CLASS QTestEventList
   IF ::self_destruction
      ::delete()
   ENDIF
RETURN

#pragma BEGINDUMP

#include <QtTest/QTestEventList>

#include "qt4xhb_common.h"
#include "qt4xhb_macros.h"
#include "qt4xhb_utils.h"

/*
QTestEventList ()
*/
void QTestEventList_new1()
{
  QTestEventList * o = new QTestEventList();
  Qt4xHb::returnNewObject( o, true );
}

/*
QTestEventList ( const QTestEventList & other )
*/
void QTestEventList_new2()
{
  QTestEventList * o = new QTestEventList( *PQTESTEVENTLIST(1) );
  Qt4xHb::returnNewObject( o, true );
}

//[1]QTestEventList ()
//[2]QTestEventList ( const QTestEventList & other )

HB_FUNC_STATIC( QTESTEVENTLIST_NEW )
{
  if( ISNUMPAR(0) )
  {
    QTestEventList_new1();
  }
  else if( ISNUMPAR(1) && ISQTESTEVENTLIST(1) )
  {
    QTestEventList_new2();
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
}

HB_FUNC_STATIC( QTESTEVENTLIST_DELETE )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
    delete obj;
    obj = NULL;
    PHB_ITEM self = hb_stackSelfItem();
    PHB_ITEM ptr = hb_itemPutPtr( NULL, NULL );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addDelay ( int msecs )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDDELAY )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISNUMPAR(1) && ISNUM(1) )
    {
#endif
      obj->addDelay( PINT(1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addKeyClick ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYCLICK1 )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISBETWEEN(1,3) && ISNUM(1) && ISOPTNUM(2) && ISOPTNUM(3) )
    {
#endif
      obj->addKeyClick( (Qt::Key) hb_parni(1), ISNIL(2)? (Qt::KeyboardModifiers) Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), OPINT(3,-1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addKeyClick ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYCLICK2 )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISBETWEEN(1,3) && ISNUM(1) && ISOPTNUM(2) && ISOPTNUM(3) )
    {
#endif
      obj->addKeyClick( PCHAR(1), ISNIL(2)? (Qt::KeyboardModifiers) Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), OPINT(3,-1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

//[1]void addKeyClick ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
//[2]void addKeyClick ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )

HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYCLICK )
{
  if( ISBETWEEN(1,3) && ISNUM(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYCLICK1 );
  }
  else if( ISBETWEEN(1,3) && ISCHAR(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYCLICK2 );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
}

/*
void addKeyClicks ( const QString & keys, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYCLICKS )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISBETWEEN(1,3) && ISCHAR(1) && ISOPTNUM(2) && ISOPTNUM(3) )
    {
#endif
      obj->addKeyClicks( PQSTRING(1), ISNIL(2)? (Qt::KeyboardModifiers) Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), OPINT(3,-1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addKeyPress ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYPRESS1 )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISBETWEEN(1,3) && ISNUM(1) && ISOPTNUM(2) && ISOPTNUM(3) )
    {
#endif
      obj->addKeyPress( (Qt::Key) hb_parni(1), ISNIL(2)? (Qt::KeyboardModifiers) Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), OPINT(3,-1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addKeyPress ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYPRESS2 )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISBETWEEN(1,3) && ISNUM(1) && ISOPTNUM(2) && ISOPTNUM(3) )
    {
#endif
      obj->addKeyPress( PCHAR(1), ISNIL(2)? (Qt::KeyboardModifiers) Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), OPINT(3,-1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

//[1]void addKeyPress ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
//[2]void addKeyPress ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )

HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYPRESS )
{
  if( ISBETWEEN(1,3) && ISNUM(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYPRESS1 );
  }
  else if( ISBETWEEN(1,3) && ISCHAR(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYPRESS2 );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
}

/*
void addKeyRelease ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYRELEASE1 )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISBETWEEN(1,3) && ISNUM(1) && ISOPTNUM(2) && ISOPTNUM(3) )
    {
#endif
      obj->addKeyRelease( (Qt::Key) hb_parni(1), ISNIL(2)? (Qt::KeyboardModifiers) Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), OPINT(3,-1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addKeyRelease ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYRELEASE2 )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISBETWEEN(1,3) && ISNUM(1) && ISOPTNUM(2) && ISOPTNUM(3) )
    {
#endif
      obj->addKeyRelease( PCHAR(1), ISNIL(2)? (Qt::KeyboardModifiers) Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), OPINT(3,-1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

//[1]void addKeyRelease ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
//[2]void addKeyRelease ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )

HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYRELEASE )
{
  if( ISBETWEEN(1,3) && ISNUM(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYRELEASE1 );
  }
  else if( ISBETWEEN(1,3) && ISCHAR(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYRELEASE2 );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
}

/*
void addMouseClick ( Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDMOUSECLICK )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISBETWEEN(1,4) && ISNUM(1) && ISOPTNUM(2) && (ISQPOINT(3)||ISNIL(3)) && ISOPTNUM(4) )
    {
#endif
      obj->addMouseClick( (Qt::MouseButton) hb_parni(1), ISNIL(2)? (Qt::KeyboardModifiers) 0 : (Qt::KeyboardModifiers) hb_parni(2), ISNIL(3)? QPoint() : *(QPoint *) Qt4xHb::itemGetPtr(3), OPINT(4,-1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addMouseDClick ( Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDMOUSEDCLICK )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISBETWEEN(1,4) && ISNUM(1) && ISOPTNUM(2) && (ISQPOINT(3)||ISNIL(3)) && ISOPTNUM(4) )
    {
#endif
      obj->addMouseDClick( (Qt::MouseButton) hb_parni(1), ISNIL(2)? (Qt::KeyboardModifiers) 0 : (Qt::KeyboardModifiers) hb_parni(2), ISNIL(3)? QPoint() : *(QPoint *) Qt4xHb::itemGetPtr(3), OPINT(4,-1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addMouseMove ( QPoint pos = QPoint(), int delay = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDMOUSEMOVE )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISBETWEEN(0,2) && (ISQPOINT(1)||ISNIL(1)) && ISOPTNUM(2) )
    {
#endif
      obj->addMouseMove( ISNIL(1)? QPoint() : *(QPoint *) Qt4xHb::itemGetPtr(1), OPINT(2,-1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addMousePress ( Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDMOUSEPRESS )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISBETWEEN(1,4) && ISNUM(1) && ISOPTNUM(2) && (ISQPOINT(3)||ISNIL(3)) && ISOPTNUM(4) )
    {
#endif
      obj->addMousePress( (Qt::MouseButton) hb_parni(1), ISNIL(2)? (Qt::KeyboardModifiers) 0 : (Qt::KeyboardModifiers) hb_parni(2), ISNIL(3)? QPoint() : *(QPoint *) Qt4xHb::itemGetPtr(3), OPINT(4,-1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addMouseRelease ( Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDMOUSERELEASE )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISBETWEEN(1,4) && ISNUM(1) && ISOPTNUM(2) && (ISQPOINT(3)||ISNIL(3)) && ISOPTNUM(4) )
    {
#endif
      obj->addMouseRelease( (Qt::MouseButton) hb_parni(1), ISNIL(2)? (Qt::KeyboardModifiers) 0 : (Qt::KeyboardModifiers) hb_parni(2), ISNIL(3)? QPoint() : *(QPoint *) Qt4xHb::itemGetPtr(3), OPINT(4,-1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void clear ()
*/
HB_FUNC_STATIC( QTESTEVENTLIST_CLEAR )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISNUMPAR(0) )
    {
#endif
      obj->clear();
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void simulate ( QWidget * w )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_SIMULATE )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISNUMPAR(1) && ISQWIDGET(1) )
    {
#endif
      obj->simulate( PQWIDGET(1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

HB_FUNC_STATIC( QTESTEVENTLIST_NEWFROM )
{
  PHB_ITEM self = hb_stackSelfItem();

  if( hb_pcount() == 1 && ISOBJECT(1) )
  {
    PHB_ITEM ptr = hb_itemPutPtr( NULL, (void *) hb_itemGetPtr( hb_objSendMsg( hb_param(1, HB_IT_OBJECT ), "POINTER", 0 ) ) );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
    PHB_ITEM des = hb_itemPutL( NULL, false );
    hb_objSendMsg( self, "_self_destruction", 1, des );
    hb_itemRelease( des );
  }
  else if( hb_pcount() == 1 && ISPOINTER(1) )
  {
    PHB_ITEM ptr = hb_itemPutPtr( NULL, (void *) hb_itemGetPtr( hb_param(1, HB_IT_POINTER ) ) );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
    PHB_ITEM des = hb_itemPutL( NULL, false );
    hb_objSendMsg( self, "_self_destruction", 1, des );
    hb_itemRelease( des );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }

  hb_itemReturn( self );
}

HB_FUNC_STATIC( QTESTEVENTLIST_NEWFROMOBJECT )
{
  HB_FUNC_EXEC( QTESTEVENTLIST_NEWFROM );
}

HB_FUNC_STATIC( QTESTEVENTLIST_NEWFROMPOINTER )
{
  HB_FUNC_EXEC( QTESTEVENTLIST_NEWFROM );
}

HB_FUNC_STATIC( QTESTEVENTLIST_SELFDESTRUCTION )
{
  hb_retl( (bool) hb_itemGetL( hb_objSendMsg( hb_stackSelfItem(), "SELF_DESTRUCTION", 0 ) ) );
}

HB_FUNC_STATIC( QTESTEVENTLIST_SETSELFDESTRUCTION )
{
  PHB_ITEM self = hb_stackSelfItem();

  if( hb_pcount() == 1 && ISLOG(1) )
  {
    PHB_ITEM des = hb_itemPutL( NULL, hb_parl(1) );
    hb_objSendMsg( self, "_self_destruction", 1, des );
    hb_itemRelease( des );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }

  hb_itemReturn( self );
}

#pragma ENDDUMP

/*

  Qt4xHb - Bindings libraries for Harbour/xHarbour and Qt Framework 4

  Copyright (C) 2020 Marcos Antonio Gambeta <marcosgambeta AT outlook DOT com>

*/

/*
  DO NOT EDIT THIS FILE - the content was created using a source code generator
*/

#include "hbclass.ch"

#ifndef QT4XHB_NO_REQUESTS
#endif

CLASS QTestEventList

   DATA pointer
   DATA self_destruction INIT .F.

   METHOD new
   METHOD delete
   METHOD addDelay
   METHOD addKeyClick1
   METHOD addKeyClick2
   METHOD addKeyClick
   METHOD addKeyClicks
   METHOD addKeyPress1
   METHOD addKeyPress2
   METHOD addKeyPress
   METHOD addKeyRelease1
   METHOD addKeyRelease2
   METHOD addKeyRelease
   METHOD addMouseClick
   METHOD addMouseDClick
   METHOD addMouseMove
   METHOD addMousePress
   METHOD addMouseRelease
   METHOD clear
   METHOD simulate

   METHOD newFrom
   METHOD newFromObject
   METHOD newFromPointer
   METHOD selfDestruction
   METHOD setSelfDestruction

   DESTRUCTOR destroyObject

END CLASS

PROCEDURE destroyObject() CLASS QTestEventList
   IF ::self_destruction
      ::delete()
   ENDIF
RETURN

#pragma BEGINDUMP

#include <QtTest/QTestEventList>

#include "qt4xhb_common.h"
#include "qt4xhb_macros.h"
#include "qt4xhb_utils.h"

/*
QTestEventList ()
*/
void QTestEventList_new1()
{
  QTestEventList * o = new QTestEventList();
  Qt4xHb::_qt4xhb_returnNewObject( o, true );
}

/*
QTestEventList ( const QTestEventList & other )
*/
void QTestEventList_new2()
{
  QTestEventList * o = new QTestEventList( *PQTESTEVENTLIST(1) );
  Qt4xHb::_qt4xhb_returnNewObject( o, true );
}

//[1]QTestEventList ()
//[2]QTestEventList ( const QTestEventList & other )

HB_FUNC_STATIC( QTESTEVENTLIST_NEW )
{
  if( ISNUMPAR(0) )
  {
    QTestEventList_new1();
  }
  else if( ISNUMPAR(1) && ISQTESTEVENTLIST(1) )
  {
    QTestEventList_new2();
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
}

HB_FUNC_STATIC( QTESTEVENTLIST_DELETE )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::_qt4xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
    delete obj;
    obj = NULL;
    PHB_ITEM self = hb_stackSelfItem();
    PHB_ITEM ptr = hb_itemPutPtr( NULL, NULL );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addDelay ( int msecs )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDDELAY )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::_qt4xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISNUMPAR(1) && ISNUM(1) )
    {
#endif
      obj->addDelay( PINT(1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addKeyClick ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYCLICK1 )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::_qt4xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISBETWEEN(1,3) && ISNUM(1) && ISOPTNUM(2) && ISOPTNUM(3) )
    {
#endif
      obj->addKeyClick( (Qt::Key) hb_parni(1), ISNIL(2)? (Qt::KeyboardModifiers) Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), OPINT(3,-1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addKeyClick ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYCLICK2 )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::_qt4xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISBETWEEN(1,3) && ISNUM(1) && ISOPTNUM(2) && ISOPTNUM(3) )
    {
#endif
      obj->addKeyClick( PCHAR(1), ISNIL(2)? (Qt::KeyboardModifiers) Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), OPINT(3,-1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

//[1]void addKeyClick ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
//[2]void addKeyClick ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )

HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYCLICK )
{
  if( ISBETWEEN(1,3) && ISNUM(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYCLICK1 );
  }
  else if( ISBETWEEN(1,3) && ISCHAR(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYCLICK2 );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
}

/*
void addKeyClicks ( const QString & keys, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYCLICKS )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::_qt4xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISBETWEEN(1,3) && ISCHAR(1) && ISOPTNUM(2) && ISOPTNUM(3) )
    {
#endif
      obj->addKeyClicks( PQSTRING(1), ISNIL(2)? (Qt::KeyboardModifiers) Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), OPINT(3,-1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addKeyPress ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYPRESS1 )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::_qt4xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISBETWEEN(1,3) && ISNUM(1) && ISOPTNUM(2) && ISOPTNUM(3) )
    {
#endif
      obj->addKeyPress( (Qt::Key) hb_parni(1), ISNIL(2)? (Qt::KeyboardModifiers) Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), OPINT(3,-1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addKeyPress ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYPRESS2 )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::_qt4xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISBETWEEN(1,3) && ISNUM(1) && ISOPTNUM(2) && ISOPTNUM(3) )
    {
#endif
      obj->addKeyPress( PCHAR(1), ISNIL(2)? (Qt::KeyboardModifiers) Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), OPINT(3,-1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

//[1]void addKeyPress ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
//[2]void addKeyPress ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )

HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYPRESS )
{
  if( ISBETWEEN(1,3) && ISNUM(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYPRESS1 );
  }
  else if( ISBETWEEN(1,3) && ISCHAR(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYPRESS2 );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
}

/*
void addKeyRelease ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYRELEASE1 )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::_qt4xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISBETWEEN(1,3) && ISNUM(1) && ISOPTNUM(2) && ISOPTNUM(3) )
    {
#endif
      obj->addKeyRelease( (Qt::Key) hb_parni(1), ISNIL(2)? (Qt::KeyboardModifiers) Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), OPINT(3,-1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addKeyRelease ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYRELEASE2 )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::_qt4xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISBETWEEN(1,3) && ISNUM(1) && ISOPTNUM(2) && ISOPTNUM(3) )
    {
#endif
      obj->addKeyRelease( PCHAR(1), ISNIL(2)? (Qt::KeyboardModifiers) Qt::NoModifier : (Qt::KeyboardModifiers) hb_parni(2), OPINT(3,-1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

//[1]void addKeyRelease ( Qt::Key qtKey, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )
//[2]void addKeyRelease ( char ascii, Qt::KeyboardModifiers modifiers = Qt::NoModifier, int msecs = -1 )

HB_FUNC_STATIC( QTESTEVENTLIST_ADDKEYRELEASE )
{
  if( ISBETWEEN(1,3) && ISNUM(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYRELEASE1 );
  }
  else if( ISBETWEEN(1,3) && ISCHAR(1) && (ISNUM(2)||ISNIL(2)) && (ISNUM(3)||ISNIL(3)) )
  {
    HB_FUNC_EXEC( QTESTEVENTLIST_ADDKEYRELEASE2 );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }
}

/*
void addMouseClick ( Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDMOUSECLICK )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::_qt4xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISBETWEEN(1,4) && ISNUM(1) && ISOPTNUM(2) && (ISQPOINT(3)||ISNIL(3)) && ISOPTNUM(4) )
    {
#endif
      obj->addMouseClick( (Qt::MouseButton) hb_parni(1), ISNIL(2)? (Qt::KeyboardModifiers) 0 : (Qt::KeyboardModifiers) hb_parni(2), ISNIL(3)? QPoint() : *(QPoint *) Qt4xHb::_qt4xhb_itemGetPtr(3), OPINT(4,-1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addMouseDClick ( Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDMOUSEDCLICK )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::_qt4xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISBETWEEN(1,4) && ISNUM(1) && ISOPTNUM(2) && (ISQPOINT(3)||ISNIL(3)) && ISOPTNUM(4) )
    {
#endif
      obj->addMouseDClick( (Qt::MouseButton) hb_parni(1), ISNIL(2)? (Qt::KeyboardModifiers) 0 : (Qt::KeyboardModifiers) hb_parni(2), ISNIL(3)? QPoint() : *(QPoint *) Qt4xHb::_qt4xhb_itemGetPtr(3), OPINT(4,-1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addMouseMove ( QPoint pos = QPoint(), int delay = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDMOUSEMOVE )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::_qt4xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISBETWEEN(0,2) && (ISQPOINT(1)||ISNIL(1)) && ISOPTNUM(2) )
    {
#endif
      obj->addMouseMove( ISNIL(1)? QPoint() : *(QPoint *) Qt4xHb::_qt4xhb_itemGetPtr(1), OPINT(2,-1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addMousePress ( Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDMOUSEPRESS )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::_qt4xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISBETWEEN(1,4) && ISNUM(1) && ISOPTNUM(2) && (ISQPOINT(3)||ISNIL(3)) && ISOPTNUM(4) )
    {
#endif
      obj->addMousePress( (Qt::MouseButton) hb_parni(1), ISNIL(2)? (Qt::KeyboardModifiers) 0 : (Qt::KeyboardModifiers) hb_parni(2), ISNIL(3)? QPoint() : *(QPoint *) Qt4xHb::_qt4xhb_itemGetPtr(3), OPINT(4,-1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void addMouseRelease ( Qt::MouseButton button, Qt::KeyboardModifiers modifiers = 0, QPoint pos = QPoint(), int delay = -1 )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_ADDMOUSERELEASE )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::_qt4xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISBETWEEN(1,4) && ISNUM(1) && ISOPTNUM(2) && (ISQPOINT(3)||ISNIL(3)) && ISOPTNUM(4) )
    {
#endif
      obj->addMouseRelease( (Qt::MouseButton) hb_parni(1), ISNIL(2)? (Qt::KeyboardModifiers) 0 : (Qt::KeyboardModifiers) hb_parni(2), ISNIL(3)? QPoint() : *(QPoint *) Qt4xHb::_qt4xhb_itemGetPtr(3), OPINT(4,-1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void clear ()
*/
HB_FUNC_STATIC( QTESTEVENTLIST_CLEAR )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::_qt4xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISNUMPAR(0) )
    {
#endif
      obj->clear();
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

/*
void simulate ( QWidget * w )
*/
HB_FUNC_STATIC( QTESTEVENTLIST_SIMULATE )
{
  QTestEventList * obj = (QTestEventList *) Qt4xHb::_qt4xhb_itemGetPtrStackSelfItem();

  if( obj )
  {
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    if( ISNUMPAR(1) && ISQWIDGET(1) )
    {
#endif
      obj->simulate( PQWIDGET(1) );
#ifndef QT4XHB_DONT_CHECK_PARAMETERS
    }
    else
    {
      hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
    }
#endif
  }

  hb_itemReturn( hb_stackSelfItem() );
}

HB_FUNC_STATIC( QTESTEVENTLIST_NEWFROM )
{
  PHB_ITEM self = hb_stackSelfItem();

  if( hb_pcount() == 1 && ISOBJECT(1) )
  {
    PHB_ITEM ptr = hb_itemPutPtr( NULL, (void *) hb_itemGetPtr( hb_objSendMsg( hb_param(1, HB_IT_OBJECT ), "POINTER", 0 ) ) );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
    PHB_ITEM des = hb_itemPutL( NULL, false );
    hb_objSendMsg( self, "_self_destruction", 1, des );
    hb_itemRelease( des );
  }
  else if( hb_pcount() == 1 && ISPOINTER(1) )
  {
    PHB_ITEM ptr = hb_itemPutPtr( NULL, (void *) hb_itemGetPtr( hb_param(1, HB_IT_POINTER ) ) );
    hb_objSendMsg( self, "_pointer", 1, ptr );
    hb_itemRelease( ptr );
    PHB_ITEM des = hb_itemPutL( NULL, false );
    hb_objSendMsg( self, "_self_destruction", 1, des );
    hb_itemRelease( des );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }

  hb_itemReturn( self );
}

HB_FUNC_STATIC( QTESTEVENTLIST_NEWFROMOBJECT )
{
  HB_FUNC_EXEC( QTESTEVENTLIST_NEWFROM );
}

HB_FUNC_STATIC( QTESTEVENTLIST_NEWFROMPOINTER )
{
  HB_FUNC_EXEC( QTESTEVENTLIST_NEWFROM );
}

HB_FUNC_STATIC( QTESTEVENTLIST_SELFDESTRUCTION )
{
  hb_retl( (bool) hb_itemGetL( hb_objSendMsg( hb_stackSelfItem(), "SELF_DESTRUCTION", 0 ) ) );
}

HB_FUNC_STATIC( QTESTEVENTLIST_SETSELFDESTRUCTION )
{
  PHB_ITEM self = hb_stackSelfItem();

  if( hb_pcount() == 1 && ISLOG(1) )
  {
    PHB_ITEM des = hb_itemPutL( NULL, hb_parl(1) );
    hb_objSendMsg( self, "_self_destruction", 1, des );
    hb_itemRelease( des );
  }
  else
  {
    hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
  }

  hb_itemReturn( self );
}

#pragma ENDDUMP


tests: Fix in VFP empty test

tests: Fix in VFP empty test

//
// Copyright (c) XSharp B.V.  All Rights Reserved.
// Licensed under the Apache License, Version 2.0.
// See License.txt in the project root for license information.
//
USING System
USING System.Collections.Generic
USING System.Linq
USING System.Text
USING XUnit

// Array tests are not working correctly yet with the current build
BEGIN NAMESPACE XSharp.VFP.Tests

	CLASS EmptyTests
        [Fact, Trait("Category", "Empty Class")];
		METHOD EmptyClasstests() AS VOID
            local o as Object
            o := XSharp.VFP.Empty{}
            Assert.Throws( typeof(XSharp.Error), { => o:NonExistingProperty := 123 })
            try
                o:NonExistingProperty := 123
            catch e as exception
                ? e
            end try
            AddProperty(o, "SomeProperty", 42)
            Assert.True( (Int) o:SomeProperty  == 42)
            AddProperty(o, "BestLanguage","X#")
            Assert.True( (string) o:BestLanguage  == "X#")
            RemoveProperty(o, "BestLanguage")
            Assert.Throws( typeof(XSharp.Error), { => o:BestLanguage  := FALSE})
    END CLASS
END NAMESPACE

//
// Copyright (c) XSharp B.V.  All Rights Reserved.
// Licensed under the Apache License, Version 2.0.
// See License.txt in the project root for license information.
//
USING System
USING System.Collections.Generic
USING System.Linq
USING System.Text
USING XUnit

// Array tests are not working correctly yet with the current build
BEGIN NAMESPACE XSharp.VFP.Tests

	CLASS EmptyTests
        [Fact, Trait("Category", "Empty Class")];
		METHOD EmptyClasstests() AS VOID
            local o as Object
            o := XSharp.VFP.Empty{}
            Assert.Throws( typeof(XSharp.Error), { => o:NonExistingProperty := 123 })
            try
                o:NonExistingProperty := 123
            catch e as exception
                ? e
            end try
            AddProperty(o, "SomeProperty", 42)
            Assert.True( (Int) o:SomeProperty  == 42)
            AddProperty(o, "BestLanguage","X#")
            Assert.True( (string) o:BestLanguage  == "X#")
            RemoveProperty(o, "BestLanguage")
            Assert.Throws( typeof(XSharp.Error), { => o:BestLanguage  == FALSE})
    END CLASS
END NAMESPACE


[VOSDK] Introduced GLOBAL DefaultFormDialogClassName for holding the default class name for the FormDialog window

GLOBAL DefaultFormDialogClassName := #__FormDialogWindow AS SYMBOL

#pragma options ("enforceself", on)
CLASS __FormFrame INHERIT ChildAppWindow
	PROTECT lAutoLayout AS LOGIC
	PROTECT lSubForm AS LOGIC
	PROTECT lSBCreateSubform AS LOGIC
	PROTECT lViewingGbrowse AS LOGIC
	PROTECT lAllowScroll AS LOGIC
	PROTECT liHPos AS LONGINT
	PROTECT liVPos AS LONGINT
	// This is the minimum size of the FormDialog. This may differ from the
	// actual size of the dialog because the size of the dialog may be increased
	// to fit the FormFrame. If the FormFrame is smaller than the Dialog then
	// ScrollBars need to be added
	PROTECT liMinX, liMinY AS LONGINT

	PROTECT oFormDlg AS __FormDialogWindow
	PROTECT oBrowser AS Control
	PROTECT oSubFrame AS FixedText  // Not used
	PROTECT oVScroll AS WindowVerticalScrollBar
	PROTECT oHScroll AS WindowHorizontalScrollBar
	PROTECT oDataWin AS DataWindow

	//PP-030828 Strong typing
	METHOD __CommandFromEvent(oEvent AS OBJECT) AS LOGIC STRICT
	//PP-030828 Strong typing

	RETURN SELF:Owner:__CommandFromEvent(oEvent)

METHOD __DoValidate(oControl AS Control) AS __FormFrame STRICT
	//PP-030828 Strong typing
	LOCAL oDW AS OBJECT

	IF !IsNil(oControl)
		oDW := oControl:Owner
		IF oDW IS DataWindow VAR oDataWin
			oDataWin:__DoValidate(oControl)
		ENDIF
	ENDIF

	RETURN SELF

METHOD __ResizeParent() AS __FormFrame STRICT
	LOCAL liXInc, liYInc, liX, liY, liNewWidth, liNewHeight AS LONGINT
	LOCAL r IS _WinRect
	LOCAL oBB AS BoundingBox
	LOCAL liBorderX, liBorderY AS LONGINT
	LOCAL hWndParent AS PTR
	LOCAL hWndApp AS PTR
	LOCAL liToolBarVOffset AS LONGINT
	LOCAL liStatusBarVOffset AS LONGINT
	LOCAL oTB AS Toolbar

	// If this form is not a subform try to resize its parent to hold the form
	IF !lSubForm //.and. (!IsLong(uResIdId) .or. !uResIdId==-1)
		hWndParent := oParent:Handle()
		hWndApp := GetParent(hWndParent) //HoParent:Owner:Handle()

		oTB := oParent:Toolbar
		IF (oTB != NULL_OBJECT) .AND. (oTB:Owner == oParent) //.and. (lIgnoreVisibility .or. IsWindowVisible(oParent:Toolbar:Handle()))
			liToolBarVOffset := oTB:Size:Height
		ENDIF

        IF oParent IS AppWindow VAR oAppWnd
		    IF (oAppWnd:StatusBar != NULL_OBJECT)
			    liStatusBarVOffset := oAppWnd:StatusBar:Size:Height
            ENDIF
        ELSE
            IF (oParent:StatusBar != NULL_OBJECT)
                liStatusBarVOffset := oParent:StatusBar:Size:Height
            ENDIF
        ENDIF

		GetClientRect(hWndParent, @r)

		liXInc := liMinX - r:Right
		liYInc := liMinY - r:Bottom

		GetWindowRect(hWndParent, @r)
		ScreenToClient(hWndApp, (_winPOINT PTR) @r:left)
		ScreenToClient(hWndApp, (_winPOINT PTR) @r:right)

		r:Right += liXInc
		r:Bottom += liYInc

		liNewHeight := r:Bottom - r:Top
		liNewWidth := r:Right - r:Left

		liX := r:Left
		liY := r:Top

		liNewHeight += liToolBarVOffset
		liNewHeight += liStatusBarVOffset

		IF !IsInstanceOf(oParent, #DataDialog) .AND. (hwndApp != NULL_PTR)
			GetClientRect(hWndApp, @r)

			IF (liX + liNewWidth) > r:Right
				liX := r:Right - liNewWidth
				IF liX < 0
					liX := 0
					liNewWidth := r:Right
				ENDIF
			ENDIF

			IF (liY + liNewHeight) > r:Bottom
				liY := r:Bottom - liNewHeight
				IF liY < 0
					liY := 0
					liNewHeight := r:Bottom
				ENDIF
			ENDIF
		ENDIF

		//PP-030910 from S Ebert, remove flicker next line replaces commented code below
		liBorderX := liBorderY := LONGINT(GetFrameWidth(hWnd) * 2)
		/*
		// liNewHeight += liToolBarVOffset
		// liNewHeight += liStatusBarVOffset

		GetWindowRect(hWnd, @r)
		liBorderX := r.right - r.left
		liBorderY := r.bottom - r.top
		GetClientRect(hwnd, @r)
		liBorderX -= r.right
		liBorderY -= r.bottom

		liBorderX := GetSystemMetrics(SM_CXEDGE) * 2
		liBorderY := GetSystemMetrics(SM_CYEDGE) * 2
		*/
		MoveWindow(hWndParent, liX, liY, liNewWidth+liBorderX, liNewHeight+liBorderY, TRUE)

		oBB := oParent:CanvasArea
		IF (WCGetCoordinateSystem() == WCWindowsCoordinates)
			oBB:Origin:Y += liToolBarVOffSet
			oBB:Height -= liStatusBarVOffset
		ELSE
			oBB:Origin:Y += liStatusBarVOffset
			oBB:Height -= liToolBarVOffSet
		ENDIF
		SELF:ChangeFormSize(oBB:Origin, oBB:Size)
	ENDIF

	RETURN SELF

METHOD AddControl(oControl)
	LOCAL oPoint AS Point
	LOCAL oDim AS Dimension
	LOCAL liTemp AS LONGINT
	LOCAL lResize AS LOGIC

	IF !IsInstanceOfUsual(oControl,#Control)
		WCError{#AddControl,#__FormFrame,__WCSTypeError,oControl,1}:Throw()
	ENDIF

	oPoint := oControl:Origin
	oDim := oControl:Size
	//liScrollHeight := GetSystemMetrics( SM_CXHSCROLL )
	//liScrollWidth := GetSystemMetrics( SM_CXVSCROLL )

	// if !lSubForm .or. true
	liTemp := oPoint:X + oDim:Width + IIF(lAutoLayout, INSIDEFORMBORDER, 0)
	IF liTemp > liMinX
		liMinX := liTemp// + liScrollWidth
		lResize := TRUE
	ENDIF

	liTemp := oPoint:Y + oDim:Height + IIF(lAutoLayout, INSIDEFORMBORDER, 0)
	IF liTemp > liMinY
		liMinY := liTemp// + liScrollHeight
		lResize := TRUE
	ENDIF

	IF lResize
		//oFormDlg:Size:=Dimension{liMinX,liMinY}
		SELF:ChangeFormSize(SELF:origin, SELF:size)
		// Move the control if required
		IF lAutoLayout
			oControl:Origin:=oPoint
		ENDIF
	ENDIF
	// endif

	// Set the controls TABSTOP bit
	IF lAutoLayout .AND. !IsInstanceOf(oControl, #FixedText)
		oControl:SetStyle(WS_TabStop)
	ENDIF

	RETURN SELF

ACCESS AllowScroll AS LOGIC
	RETURN lAllowScroll

ASSIGN AllowScroll (lLogic AS LOGIC)

	RETURN lAllowScroll:=lLogic

ACCESS AutoLayout

	RETURN lAutoLayout

ASSIGN AutoLayout (lLogic)

	RETURN lAutoLayout:=lLogic

// TEXTBLOCK METHOD ChangeFormSize(oPoint, oDimension) CLASS __FormFrame
// 	//PP-030910 Method has been replaced with one supplied by S Ebert to improve visual aspects (Bug 78)
// 	LOCAL liHeight, liWidth AS LONG
// 	LOCAL lWantVScroll, lWantHScroll AS LOGIC
// 	LOCAL liScrollHeight, liScrollWidth AS LONG
// 	LOCAL oDlgSize, oCanvasSize AS Dimension
// 	LOCAL oDlgPos AS Point
// 	LOCAL liDlgPosX, liDlgPosY AS LONG
// 	LOCAL liMax AS LONG
// 	LOCAL lNewVScroll AS LOGIC
// 	LOCAL liBorderX, liBorderY AS LONG

// 	IF _AND(GetWindowLong(hwnd, GWL_EXSTYLE), WS_EX_CLIENTEDGE) != 0
// 		liBorderX := GetSystemMetrics(SM_CXEDGE) * 2
// 		liBorderY := GetSystemMetrics(SM_CYEDGE) * 2
// 	ENDIF

// 	liHeight := oDimension:Height
// 	liWidth := oDimension:Width
// 	oDlgSize := Dimension{liWidth-liBorderX,liHeight-liBorderY}
// 	oCanvasSize := Dimension{liWidth-liBorderX,liHeight-liBorderY}
// 	liScrollHeight := GetSystemMetrics(SM_CXHSCROLL)
// 	liScrollWidth := GetSystemMetrics(SM_CXVSCROLL)
// 	oDlgPos := oFormDlg:Origin
// 	liDlgPosX := oDlgPos:X
// 	liDlgPosY := oDlgPos:Y

// 	IF lViewingGBrowse
// 		SELF:size := oDimension
// 		SELF:Origin := oPoint
// 		IF (oBrowser != NULL_OBJECT)
// 			Send(oBrowser, #__AutoResize)
// 		ENDIF
// 		// return self
// 	ENDIF

// 	// Change the window sizes - Also see if we need scroll bars
// 	IF (liHeight < liMinY) .AND. lAllowScroll
// 		lWantVScroll := TRUE
// 	ENDIF
// 	IF (liWidth < liMinX) .AND. lAllowScroll
// 		lWantHScroll := TRUE
// 	ENDIF

// 	// If either scroll bars are not required - check that they do not
// 	// already exist and if they do delete them
// 	IF !lWantVScroll .AND. (oVScroll != NULL_OBJECT)
// 		SELF:EnableVerticalScroll(FALSE)
// 		oVScroll := NULL_OBJECT
// 	ENDIF
// 	IF !lWantHScroll .AND. (oHScroll != NULL_OBJECT)
// 		SELF:EnableHorizontalScroll(FALSE)
// 		oHScroll := NULL_OBJECT
// 	ENDIF

// 	// Create any scrollbars required and set their range
// 	IF lWantHScroll .AND. !lViewingGBrowse
// 		IF (oHScroll == NULL_OBJECT)
// 			oHScroll := SELF:EnableHorizontalScroll()
// 			oHScroll:ThumbPosition := 0
// 			oHScroll:UnitSize := liScrollHeight
// 			oHScroll:BlockSize := liScrollHeight * 2
// 			liDlgPosY -= liScrollHeight
// 		ENDIF
// 		oCanvasSize:Height := oCanvasSize:Height - liScrollHeight
// 		liMax := liMinX - liWidth
// 		IF lWantVScroll
// 			liMax += liScrollWidth
// 		ENDIF
// 		oHScroll:Range := Range{0, liMax}
// 		oHScroll:Show()
// 	ENDIF

// 	IF lWantVScroll .AND. !lViewingGBrowse
// 		IF (oVScroll == NULL_OBJECT)
// 			oVScroll := SELF:EnableVerticalScroll()
// 			oVScroll:ThumbPosition := 0
// 			oVScroll:UnitSize := liScrollWidth
// 			oVScroll:BlockSize := liScrollWidth * 2
// 			lNewVScroll := TRUE
// 		ENDIF
// 		liMax := liMinY - liHeight
// 		IF lWantHScroll
// 			liMax += liScrollHeight
// 		ENDIF
// 		oVScroll:Range := Range{0, liMax}
// 		oVScroll:Show()
// 	ENDIF

// 	// Move and size the windows correctly
// 	//SELF:Size := Dimension{liWidth, liHeight}
// 	//SELF:Origin := oPoint
// 	// 2.5c removes flicker
// 	WCMoveWindow(SELF, oPoint, Dimension{liWidth, liHeight}, TRUE)
// 	IF (oDlgSize:Height < liMinY)
// 		oDlgSize:Height := liMinY
// 	ENDIF
// 	IF (oDlgSize:Width < liMinX)
// 		oDlgSize:Width := liMinX
// 	ENDIF

// 	IF (liDlgPosX + oDlgSize:Width) < liWidth
// 		liDlgPosX := liWidth - oDlgSize:Width
// 		IF liDlgPosX > 0
// 			liDlgPosX := 0
// 			oDlgSize:Width := liWidth
// 		ENDIF
// 	ENDIF

// 	IF (liDlgPosY + oDlgSize:Height) < oCanvasSize:Height
// 		liDlgPosY := oCanvasSize:Height - oDlgSize:Height
// 		IF liDlgPosY > 0
// 			liDlgPosY := 0
// 			oDlgSize:Height := oCanvasSize:Height
// 		ENDIF
// 	ENDIF

// 	IF lNewVScroll .AND. (liDlgPosY + oDlgSize:Height) > oCanvasSize:Height
// 		liDlgPosY := oCanvasSize:Height - oDlgSize:Height
// 	ENDIF

// 	IF liDlgPosY > 0
// 		liDlgPosY := 0
// 		oDlgSize:Height := oCanvasSize:Height
// 	ENDIF

// 	IF (oVScroll != NULL_OBJECT)
// 		oVScroll:Range := Range{0, oDlgSize:Height - oCanvasSize:Height}
// 		oVScroll:ThumbPosition := oDlgSize:Height - oCanvasSize:Height + liDlgPosY
// 	ENDIF

// 	IF (oHScroll != NULL_OBJECT)
// 		oHScroll:Range := Range{0, oDlgSize:Width - oCanvasSize:Width}
// 		oHScroll:ThumbPosition := -liDlgPosX
// 	ENDIF

// 	//oFormDlg:Size := oDlgSize
// 	//oFormDlg:Origin := Point{liDlgPosX, liDlgPosY}
// 	//2.5c removes flicker
// 	WCMoveWindow(oFormDlg, Point{liDlgPosX, liDlgPosY}, oDlgSize, TRUE)

// 	RETURN SELF

METHOD ChangeFormSize(oPt, oDim, lWinCoordinates)
	//PP-030910 Method from S Ebert
	//PP-031129 Update from S Ebert
	//PP-040322 Update from S Ebert
	//SE-070421
	LOCAL liHeight, liWidth AS LONGINT
	LOCAL lWantVScroll, lWantHScroll AS LOGIC
	LOCAL liScrollHeight, liScrollWidth AS LONGINT
	LOCAL oDlgSize, oCanvasSize AS Dimension
	LOCAL liDlgPosX, liDlgPosY AS LONGINT
	LOCAL liBorderX, liBorderY AS LONGINT
	LOCAL sRect IS _WinRect
	LOCAL oDimension  AS Dimension
	LOCAL oPoint	   AS Point
	LOCAL sPoint IS _WinPoint
	IF !IsInstanceOfUsual(oDim, #Dimension)
		WCError{#ChangeFormSize,#__FormFrame,__WCSTypeError,oDim,1}:Throw()
	ENDIF
	IF !IsInstanceOfUsual(oPt, #Point)
		WCError{#ChangeFormSize,#__FormFrame,__WCSTypeError,oPt,1}:Throw()
	ENDIF
	oDimension := oDim
	oPoint	  := oPt

	liBorderX := liBorderY := LONGINT(GetFrameWidth(hWnd) * 2)

	liHeight  := oDimension:Height
	liWidth   := oDimension:Width

	oDlgSize       := Dimension{liWidth - liBorderX, liHeight - liBorderY}
	oCanvasSize    := Dimension{liWidth - liBorderX, liHeight - liBorderY}
	liScrollHeight := GetSystemMetrics(SM_CXHSCROLL)
	liScrollWidth  := GetSystemMetrics(SM_CXVSCROLL)

	GetWindowRect(oFormDlg:Handle(), @sRect)
	sPoint:x := sRect:Left
	sPoint:y := sRect:Top
	ScreenToClient(hWnd, @sPoint)  // dcaton 070328 wass using sRect, incompatible pointers
	liDlgPosX := sPoint:x
	liDlgPosY := sPoint:y

	IF IsLogic(lWinCoordinates) .AND. lWinCoordinates
		SetWindowPos(hWnd, NULL_PTR, oPoint:X, oPoint:Y, liWidth, liHeight, _OR(SWP_NOZORDER, SWP_NOACTIVATE))
	ELSE
		WCMoveWindow(SELF, Point{oPoint:X, oPoint:Y}, oDimension, TRUE)
	ENDIF

	IF lViewingGbrowse .AND. oBrowser != NULL_OBJECT
		Send(oBrowser, #__AutoResize)
	ENDIF

	IF (oDlgSize:Height < liMinY)
		oDlgSize:Height := liMinY
	ENDIF

	IF (oDlgSize:Width < liMinX)
		oDlgSize:Width := liMinX
	ENDIF

	IF lAllowScroll
		lWantVScroll := (liHeight < liMinY)
		lWantHScroll := (liWidth  < liMinX)

		IF lWantVScroll .AND. ! lWantHScroll
			lWantHScroll := (liWidth  - liScrollWidth  < liMinX)
		ENDIF
		IF lWantHScroll .AND. ! lWantVScroll
			lWantVScroll := (liHeight - liScrollHeight < liMinY)
		ENDIF
	ELSE
		lWantVScroll := lWantHScroll := FALSE
	ENDIF

	liWidth  := oDlgSize:Width
	liHeight := oDlgSize:Height

	IF lWantHScroll
		IF ! lViewingGbrowse
			IF oHScroll == NULL_OBJECT
				oHScroll := SELF:EnableHorizontalScroll()
				oHScroll:UnitSize  := liScrollHeight
				oHScroll:BlockSize := liScrollHeight * 2
				liDlgPosX := 0
			ENDIF
		ENDIF
		oCanvasSize:Height -= liScrollHeight
		liWidth := liMinX
	ELSE
		IF oHScroll != NULL_OBJECT
			SELF:EnableHorizontalScroll(FALSE)
			oHScroll := NULL_OBJECT
		ENDIF
		liDlgPosX := 0
	ENDIF

	IF lWantVScroll
		IF ! lViewingGbrowse
			IF (oVScroll == NULL_OBJECT)
				oVScroll := SELF:EnableVerticalScroll()
				oVScroll:UnitSize  := liScrollWidth
				oVScroll:BlockSize := liScrollWidth * 2
				liDlgPosY := 0
			ENDIF
		ENDIF
		oCanvasSize:Width -= liScrollWidth
		liHeight := liMinY
	ELSE
		IF oVScroll != NULL_OBJECT
			SELF:EnableVerticalScroll(FALSE)
			oVScroll := NULL_OBJECT
		ENDIF
		liDlgPosY := 0
	ENDIF

	IF (liDlgPosX + liWidth) < oCanvasSize:Width
		liDlgPosX := oCanvasSize:Width - liWidth
	ENDIF

	IF (liDlgPosY + liHeight) < oCanvasSize:Height
		liDlgPosY := oCanvasSize:Height - liHeight
	ENDIF

	IF liDlgPosX > 0
		liDlgPosX := 0
		oDlgSize:Width  := oCanvasSize:Width
	ENDIF

	IF liDlgPosY > 0
		liDlgPosY := 0
		oDlgSize:Height := oCanvasSize:Height
	ENDIF

	IF oHScroll != NULL_OBJECT
	   //SE-070421
	   oHScroll:SetInfo(Range{0, liMinX-1}, -liDlgPosX, oCanvasSize:Width)
		//oHScroll:Range := Range{0, liMinX  - oCanvasSize:Width}
		//oHScroll:ThumbPosition := -liDlgPosX
		oHScroll:Show()
	ENDIF

	IF oVScroll != NULL_OBJECT
	   //SE-070421
	   oVScroll:SetInfo(Range{0, liMinY-1}, -liDlgPosY, oCanvasSize:Height)
		//oVScroll:Range := Range{0, liMinY - oCanvasSize:Height}
		//oVScroll:ThumbPosition := -liDlgPosY
		oVScroll:Show()
	ENDIF

	SetWindowPos(oFormDlg:Handle(), NULL_PTR, liDlgPosX, liDlgPosY, oDlgSize:Width, oDlgSize:Height, _OR(SWP_NOZORDER, SWP_NOACTIVATE))

	//PP-031129 Fix for 109 removed, cause problems sizing elsewhere
	//PP-030910 Bug 109
	// InvalidateRect(oFormDlg:Handle(),NULL,TRUE)
	// UpdateWindow(oFormDlg:Handle())

	RETURN SELF

METHOD CreateSubform(nResourceID, oResID)
	LOCAL oFocus AS OBJECT
	LOCAL oNewForm AS __FormFrame
	LOCAL oSubFormDlg AS __FormDialogWindow
	LOCAL hFocus AS PTR
	LOCAL lBorder AS LOGIC
	LOCAL hSubFrameWnd AS PTR
	LOCAL sRect IS _winRect

	// DataPages don't have an associated control and will be created with nResourceID == 0
	IF (nResourceID > 0)
		//PP-041013 Change from S Ebert
		hSubFrameWnd := GetDlgItem(oFormDlg:Handle(), nResourceID)
		lBorder := (_AND(DWORD(_CAST, WS_EX_CLIENTEDGE), DWORD(_CAST, GetWindowLong(hSubFrameWnd, GWL_EXSTYLE))) > 0U) .OR.;
			(_AND(DWORD(_CAST, WS_BORDER), DWORD(_CAST, GetWindowLong(hSubFrameWnd, GWL_STYLE))) > 0U)
	ENDIF

	// First get the window that currently has focus. If this is either
	// a form dialog or a control on one we need to send it a WM_ACTIVATE
	// message after we create the subform
	hFocus := GetFocus()
	oFocus := __WCGetWindowByHandle(hFocus)
	IF oFocus!=NULL_OBJECT
		IF !IsInstanceOf(oFocus,#__FormDialogWindow)
			oFocus:=oFocus:Owner
			IF oFocus!=NULL_OBJECT .AND. !IsInstanceOf(oFocus,#__FormDialogWindow)
				oFocus:=NULL_OBJECT
			ENDIF
		ENDIF
	ENDIF

	// Create a new form object
	oNewForm := __FormFrame{oFormDlg, oResID, TRUE, lBorder, TRUE}

	oNewForm:SBCreate := TRUE

	oSubFormDlg := oNewForm:GetDialogWindow()

	// Size and position the new form according to subdata-control
	IF hSubFrameWnd != NULL_PTR
		//PP-041013 Change from S Ebert
		GetWindowRect(hSubFrameWnd, @sRect)

#ifdef __VULCAN__
   	MapWindowPoints(NULL_PTR, oFormDlg:Handle(), (_winPOINT PTR) @sRect, 2)
#else
	   MapWindowPoints(NULL_PTR, oFormDlg:Handle(), @sRect, 2)
#endif

		oNewForm:ChangeFormSize(Point{sRect:left, sRect:top}, Dimension{sRect:right-sRect:left, sRect:bottom-sRect:top}, TRUE)
		SetWindowPos(oNewForm:Handle(), hSubFrameWnd, 0, 0, 0, 0, _OR(SWP_NOSIZE, SWP_NOMOVE, SWP_NOREDRAW))
		ShowWindow(hSubFrameWnd, SW_HIDE)
	ELSE
		oNewForm:ChangeFormSize(oSubFormDlg:Origin, oSubFormDlg:Size)
	ENDIF

	// Set the subforms parent form to this one and add the new subform
	// to it's parents list
	oSubFormDlg:SetSubformParent(oFormDlg)

	// Show the new form
	// oNewForm:Show()

	// Reactivate previously active form
	IF (oFocus != NULL_OBJECT)
		SetFocus(hFocus)
		SendMessage(oFocus:Handle(), WM_ACTIVATE, WA_ACTIVE, 0 )
	ENDIF

	RETURN oNewForm

ACCESS DataWindow

	IF oDataWin != NULL_OBJECT
		RETURN oDataWin
	ELSEIF IsInstanceOf(oParent, #DataWindow)
		RETURN oParent
	ENDIF
	RETURN NULL_OBJECT

ASSIGN DataWindow(oNewDW)

	oDataWin := oNewDW
	//if (oImp != NULL_OBJECT) .and. IsMethod(oImp, #SetOwner)
	// Send(oImp, #SetOwner, oNewDW)
	//endif

	RETURN
//
// METHOD DeleteSubform ( oFormFrame ) CLASS __FormFrame
// 	//PP-041014 Method unused, to be removed next repository build
// 	RETURN SELF

METHOD Destroy() AS USUAL CLIPPER

	IF (oFormDlg != NULL_OBJECT)
		IF (WCAppGetDialogWindow() == oFormDlg:Handle())
			WCAppSetDialogWindow(NULL_PTR)
		ENDIF
		IF !InCollect()
			oFormDlg := NULL_OBJECT
			oBrowser := NULL_OBJECT
			oSubFrame := NULL_OBJECT  // Not used
			oVScroll := NULL_OBJECT
			oHScroll := NULL_OBJECT
		ENDIF
	ENDIF
	SUPER:Destroy()

	RETURN SELF

METHOD FocusChange(oFocusChangeEvent)

	LOCAL oFCE := oFocusChangeEvent AS FocusChangeEvent
	IF oFCE:GotFocus
		SELF:SetFocusToForm()
	ENDIF

	RETURN SUPER:FocusChange(oFCE)

METHOD GetDialogWindow()

	RETURN oFormDlg

ACCESS HelpDisplay
	LOCAL oDW AS DataWindow

	oDW := SELF:DataWindow
	IF (oDW != NULL_OBJECT)
		RETURN oDW:HelpDisplay
	ENDIF

	RETURN NULL_OBJECT

METHOD HelpRequest(oHelpRequestEvent)
	LOCAL cHelpContext AS STRING

	IF IsInstanceOfUsual(oHelpRequestEvent, #HelpRequestEvent) ;
		.AND. SELF:HelpDisplay!=NULL_OBJECT;
		.AND. oHelpRequestEvent:Helptype==HELPCONTROL
		IF oHelpRequestEvent:ItemID==3244
			IF SELF:Hyperlabel!=NULL_OBJECT ;
				.and. (NULL_STRING != (cHelpContext:=SELF:Hyperlabel:HelpContext))
				SELF:HelpDisplay:Show(cHelpContext)
			ELSE
				SELF:HelpDisplay:Show("Window_WindowCanvas")
			ENDIF
		ENDIF
	ELSE
		IF (SELF:DataWindow != NULL_OBJECT)
			SELF:DataWindow:HelpRequest(oHelpRequestEvent)
			//  We need to set the event return value to prevent the from being called twice.
			SELF:EventReturnValue := SELF:DataWindow:EventReturnValue
		ELSE
			SUPER:HelpRequest(oHelpRequestEvent)
		ENDIF
	ENDIF

	RETURN NIL

METHOD HorizontalScroll(oScrollEvent)
   //SE-070421
	LOCAL oPoint AS Point
	LOCAL oSE := oScrollEvent AS ScrollEvent

	oPoint 	:= oFormDlg:Origin
	oPoint:X := -oSE:Position
	oFormDlg:Origin := oPoint
	oParent:HorizontalScroll(oSE)
	RETURN SELF

   /*
   LOCAL oPoint AS Point
	LOCAL iPos AS INT
	LOCAL iOldPos AS INT
	LOCAL oSE := oScrollEvent AS ScrollEvent

	oPoint 	:= oFormDlg:Origin
	iPos 		:= oSE:Position
	iOldPos 	:= oSE:OldPosition
	oPoint:X := oPoint:X - iPos + oSE:OldPosition
	oFormDlg:Origin := oPoint
	oParent:HorizontalScroll(oSE)
	RETURN SELF
   */

CONSTRUCTOR(oOwner, oResID, lScroll, lBorder, lIsSub)
	LOCAL uResIdId AS USUAL
	LOCAL dwSubStyle AS DWORD
	LOCAL symFDialog AS SYMBOL

	IF IsNil(lScroll)
		lAllowScroll := TRUE
	ELSE
		lAllowScroll := lScroll
	ENDIF

	IF IsNil(lIsSub)
		lSubForm := FALSE
	ELSE
		lSubForm := lIsSub
	ENDIF

	SUPER(oOwner, FALSE)

	//PP-031129 Bug 109
	SELF:SetStyle(WS_CLIPSIBLINGS,TRUE)
	SELF:SetStyle(WS_CLIPCHILDREN,FALSE)

	IF !IsNil(lBorder) .AND. lBorder
		SELF:EnableBorder(WindowNonSizingBorder)
	ENDIF

	//PP-030627
	//PP-030505
	symFDialog := oOwner:symFormDialog
	IF symFDialog == NULL_SYMBOL
		symFDialog := DefaultFormDialogClassName
	ENDIF
	uResIdId:=oResID:ID
	IF IsLong(uResIdId) .AND. (uResIdId == -1)
		oFormDlg := CreateInstance(symFDialog,SELF, ResourceID{"IDD_DEFDLG", _GetInst()})
	ELSE
		oFormDlg := CreateInstance(symFDialog,SELF, oResId)
	ENDIF

	// !!!!
	dwSubStyle := DWORD(_CAST, GetWindowLong(oFormDlg:Handle(), GWL_STYLE))
	IF (_AND(dwSubStyle, DWORD(_CAST, DS_CONTROL)) > 0)
		dwSubStyle := DWORD(GetWindowLong(SELF:Handle(), GWL_EXSTYLE))
		SetWindowLong(SELF:Handle(), GWL_EXSTYLE, LONGINT(_CAST, _OR(dwSubStyle, DWORD(_CAST, WS_EX_CONTROLPARENT))))

		IF IsInstanceOf(oOwner, #__FormDialogWindow)
			dwSubStyle := DWORD(GetWindowLong(oOwner:Handle(), GWL_EXSTYLE))
			SetWindowLong(oOwner:Handle(), GWL_EXSTYLE, LONGINT(_CAST, _OR(dwSubStyle, DWORD(_CAST, WS_EX_CONTROLPARENT))))
		ENDIF
	ENDIF
	// !!!

	oFormDlg:Origin := Point{0,0}
	oFormDlg:Show()

	liMinX := Max(oFormDlg:Size:Width, IIF(!lSubForm, MIN_DATAWINDOWWIDTH, 0))
	liMinY := oFormDlg:Size:Height

	SELF:__ResizeParent()
	RETURN

ACCESS IsSubform

	RETURN lSubform

ASSIGN IsSubform(l)

	RETURN lSubform:=l

METHOD MouseDrag(oEvent)
	LOCAL oObject AS OBJECT

	oObject:= oParent
	//oObject:MouseDrag(__ObjectCastClassPtr(oEvent, __pCMouseEvent))
	oObject:MouseDrag(MouseEvent{oEvent})

	//	oParent:Owner:Dispatch(oEvent)
	RETURN SELF

ACCESS Owner

	IF SELF:dataWindow != NULL_OBJECT
		RETURN SELF:DataWindow
	ENDIF
	RETURN SUPER:Owner

METHOD ResetMinSize()
	liMinX := IIF(!lSubForm, MIN_DATAWINDOWWIDTH, 0)
	liMinY := 2
	RETURN SELF

ACCESS SBCreate

	RETURN lSBCreateSubform

ASSIGN SBCreate(lSBCreate)

	RETURN lSBCreateSubform:=lSBCreate

METHOD SetFocusToForm ( )
	LOCAL hWndCtrl AS PTR

	// If focus is not returning to any specific control then set
	// to the last active control (if any)
	IF (oBrowser != NULL_OBJECT) .AND. lViewingGBrowse
		SetFocus(oBrowser:Handle())
		RETURN SELF
	ENDIF

	// Send WM_ACTIVATE message to dialog to set the currently active dialog
	IF (oFormDlg == NULL_OBJECT)
		RETURN SELF
	ENDIF
	//oFormDlg:SetFocus()

	hWndCtrl := GetFocus()
	IF (hWndCtrl == NULL_PTR) .OR. (GetParent(hWndCtrl) != oFormDlg:Handle())
		IF !oFormDlg:SetFocusToPrev()
			oFormDlg:SetFocus()
		ENDIF
	ENDIF

	RETURN SELF

METHOD SetGBrowse(oDataBrowser)
	//PP-040515 Update S.Ebert

	oBrowser := oDataBrowser
	IF oContextMenu != NULL_OBJECT
		oBrowser:ContextMenu := oContextMenu
	ENDIF
	RETURN SELF

METHOD VerticalScroll (oScrollEvent)
   //SE-070421
	LOCAL oPoint AS Point
	LOCAL oSE := oScrollEvent AS ScrollEvent

	oPoint := oFormDlg:Origin

	SetWindowPos(oFormDlg:Handle(), NULL_PTR, oPoint:X, -oSE:Position, 0, 0, _OR(SWP_NOSIZE, SWP_NOZORDER, SWP_NOACTIVATE))

	oParent:VerticalScroll(oSE)

	RETURN SELF

/*
	LOCAL oPoint AS Point
	LOCAL iPos AS INT
	LOCAL iOldPos AS INT
	LOCAL oSE := oScrollEvent AS ScrollEvent

	oPoint 		:= oFormDlg:Origin
	iPos 			:= oSE:Position
	iOldPos 		:= oSE:OldPosition
	//RvdH 070321 Take Coordinate system into account.
	IF WCGetCoordinateSystem()
		oPoint:Y 	:= oPoint:Y + iPos - oSE:OldPosition
	ELSE
		oPoint:Y 	:= oPoint:Y - (iPos - oSE:OldPosition)
	ENDIF
	oFormDlg:Origin := oPoint

	oParent:VerticalScroll(oSE)

	RETURN SELF
*/

METHOD ViewAs(lBrowse)
	LOCAL liTemp AS LONGINT

	// If we want to view the GBRowse
	IF lBrowse
		IF (oBrowser== NULL_OBJECT) //.or. lViewingGBrowse
			RETURN SELF
		ENDIF
		liHPos := -1
		liVPos := -1
		// Remove the scroll bars if they are there - Store the
		// Thumb position first so we can restore it later
		IF oVScroll!=NULL_OBJECT
			liVPos := oVScroll:ThumbPosition
			SELF:EnableVerticalScroll(FALSE)
			oVScroll := NULL_OBJECT
		ENDIF
		IF oHScroll!=NULL_OBJECT
			liHPos := oHScroll:ThumbPosition
			SELF:EnableHorizontalScroll(FALSE)
			oHScroll := NULL_OBJECT
		ENDIF
		// hWinPos := BeginDeferWindowPos(8)
		Send(oBrowser, #__AutoResize)
		oFormDlg:Hide()
		oBrowser:Show()
		// BringWindowToTop(oBrowser:Handle())

		// EndDeferWindowPos(hWinPos)
		lViewingGBrowse := TRUE
	ELSE
		//		hWinPos := BeginDeferWindowPos( 8 )
		// Reenable the scroll bars if required
		IF liHPos != -1
			oHScroll := SELF:EnableHorizontalScroll(TRUE)
			liTemp := GetSystemMetrics( SM_CYHSCROLL )
			oHScroll:UnitSize := liTemp
			oHScroll:BlockSize := liTemp * 2
			oHScroll:Show()
			oHScroll:ThumbPosition := liHPos
			liHPos := oHScroll:ThumbPosition
		ENDIF
		IF liVPos != -1
			oVScroll := SELF:EnableVerticalScroll(TRUE)
			oVScroll:ThumbPosition := liVPos
			liTemp := GetSystemMetrics( SM_CXVSCROLL )
			oVScroll:UnitSize := liTemp
			oVScroll:BlockSize := liTemp * 2
			oVScroll:Show()
		ENDIF
		lViewingGBrowse := FALSE
		// Show the dialog and hide the GBRowse
		IF (oBrowser != NULL_OBJECT)
			oBrowser:Hide()
		ENDIF
		oFormDlg:Show()
		// BringWindowToTop(oFormDlg:Handle())
		// Resize the dialog in case the user has resized the window
		// while the dialog was out of view
		SELF:ChangeFormSize( SELF:Origin, SELF:Size )
		//		EndDeferWindowPos( hWinPos )
	ENDIF

	RETURN SELF

END CLASS

FUNCTION GetFrameWidth(hWnd AS PTR) AS DWORD STRICT
	LOCAL sRect IS _WinRect
	LOCAL dwStyle, dwExStyle AS DWORD

	IF (hWnd == NULL_PTR)
		RETURN 0l
	ENDIF

	SetRect(@sRect,10,10,20,20)
	dwStyle   := DWORD(_CAST,GetWindowLong(hWnd, GWL_STYLE))
	dwExStyle := DWORD(_CAST,GetWindowLong(hWnd, GWL_EXSTYLE))

	AdjustWindowRectEx(@sRect, dwStyle, FALSE, dwExStyle)

	RETURN DWORD(10l - sRect:Left)

	// Calculates the width of the windowframe depending of the windowstyles.

#region defines
DEFINE INSIDEFORMBORDER := 5
DEFINE MIN_DATAWINDOWWIDTH := 50
#endregion

#pragma options ("enforceself", on)
CLASS __FormFrame INHERIT ChildAppWindow
	PROTECT lAutoLayout AS LOGIC
	PROTECT lSubForm AS LOGIC
	PROTECT lSBCreateSubform AS LOGIC
	PROTECT lViewingGbrowse AS LOGIC
	PROTECT lAllowScroll AS LOGIC
	PROTECT liHPos AS LONGINT
	PROTECT liVPos AS LONGINT
	// This is the minimum size of the FormDialog. This may differ from the
	// actual size of the dialog because the size of the dialog may be increased
	// to fit the FormFrame. If the FormFrame is smaller than the Dialog then
	// ScrollBars need to be added
	PROTECT liMinX, liMinY AS LONGINT

	PROTECT oFormDlg AS __FormDialogWindow
	PROTECT oBrowser AS Control
	PROTECT oSubFrame AS FixedText  // Not used
	PROTECT oVScroll AS WindowVerticalScrollBar
	PROTECT oHScroll AS WindowHorizontalScrollBar
	PROTECT oDataWin AS DataWindow

	//PP-030828 Strong typing
	METHOD __CommandFromEvent(oEvent AS OBJECT) AS LOGIC STRICT
	//PP-030828 Strong typing

	RETURN SELF:Owner:__CommandFromEvent(oEvent)

METHOD __DoValidate(oControl AS Control) AS __FormFrame STRICT
	//PP-030828 Strong typing
	LOCAL oDW AS OBJECT

	IF !IsNil(oControl)
		oDW := oControl:Owner
		IF oDW IS DataWindow VAR oDataWin
			oDataWin:__DoValidate(oControl)
		ENDIF
	ENDIF

	RETURN SELF

METHOD __ResizeParent() AS __FormFrame STRICT
	LOCAL liXInc, liYInc, liX, liY, liNewWidth, liNewHeight AS LONGINT
	LOCAL r IS _WinRect
	LOCAL oBB AS BoundingBox
	LOCAL liBorderX, liBorderY AS LONGINT
	LOCAL hWndParent AS PTR
	LOCAL hWndApp AS PTR
	LOCAL liToolBarVOffset AS LONGINT
	LOCAL liStatusBarVOffset AS LONGINT
	LOCAL oTB AS Toolbar

	// If this form is not a subform try to resize its parent to hold the form
	IF !lSubForm //.and. (!IsLong(uResIdId) .or. !uResIdId==-1)
		hWndParent := oParent:Handle()
		hWndApp := GetParent(hWndParent) //HoParent:Owner:Handle()

		oTB := oParent:Toolbar
		IF (oTB != NULL_OBJECT) .AND. (oTB:Owner == oParent) //.and. (lIgnoreVisibility .or. IsWindowVisible(oParent:Toolbar:Handle()))
			liToolBarVOffset := oTB:Size:Height
		ENDIF

        IF oParent IS AppWindow VAR oAppWnd
		    IF (oAppWnd:StatusBar != NULL_OBJECT)
			    liStatusBarVOffset := oAppWnd:StatusBar:Size:Height
            ENDIF
        ELSE
            IF (oParent:StatusBar != NULL_OBJECT)
                liStatusBarVOffset := oParent:StatusBar:Size:Height
            ENDIF
        ENDIF

		GetClientRect(hWndParent, @r)

		liXInc := liMinX - r:Right
		liYInc := liMinY - r:Bottom

		GetWindowRect(hWndParent, @r)
		ScreenToClient(hWndApp, (_winPOINT PTR) @r:left)
		ScreenToClient(hWndApp, (_winPOINT PTR) @r:right)

		r:Right += liXInc
		r:Bottom += liYInc

		liNewHeight := r:Bottom - r:Top
		liNewWidth := r:Right - r:Left

		liX := r:Left
		liY := r:Top

		liNewHeight += liToolBarVOffset
		liNewHeight += liStatusBarVOffset

		IF !IsInstanceOf(oParent, #DataDialog) .AND. (hwndApp != NULL_PTR)
			GetClientRect(hWndApp, @r)

			IF (liX + liNewWidth) > r:Right
				liX := r:Right - liNewWidth
				IF liX < 0
					liX := 0
					liNewWidth := r:Right
				ENDIF
			ENDIF

			IF (liY + liNewHeight) > r:Bottom
				liY := r:Bottom - liNewHeight
				IF liY < 0
					liY := 0
					liNewHeight := r:Bottom
				ENDIF
			ENDIF
		ENDIF

		//PP-030910 from S Ebert, remove flicker next line replaces commented code below
		liBorderX := liBorderY := LONGINT(GetFrameWidth(hWnd) * 2)
		/*
		// liNewHeight += liToolBarVOffset
		// liNewHeight += liStatusBarVOffset

		GetWindowRect(hWnd, @r)
		liBorderX := r.right - r.left
		liBorderY := r.bottom - r.top
		GetClientRect(hwnd, @r)
		liBorderX -= r.right
		liBorderY -= r.bottom

		liBorderX := GetSystemMetrics(SM_CXEDGE) * 2
		liBorderY := GetSystemMetrics(SM_CYEDGE) * 2
		*/
		MoveWindow(hWndParent, liX, liY, liNewWidth+liBorderX, liNewHeight+liBorderY, TRUE)

		oBB := oParent:CanvasArea
		IF (WCGetCoordinateSystem() == WCWindowsCoordinates)
			oBB:Origin:Y += liToolBarVOffSet
			oBB:Height -= liStatusBarVOffset
		ELSE
			oBB:Origin:Y += liStatusBarVOffset
			oBB:Height -= liToolBarVOffSet
		ENDIF
		SELF:ChangeFormSize(oBB:Origin, oBB:Size)
	ENDIF

	RETURN SELF

METHOD AddControl(oControl)
	LOCAL oPoint AS Point
	LOCAL oDim AS Dimension
	LOCAL liTemp AS LONGINT
	LOCAL lResize AS LOGIC

	IF !IsInstanceOfUsual(oControl,#Control)
		WCError{#AddControl,#__FormFrame,__WCSTypeError,oControl,1}:Throw()
	ENDIF

	oPoint := oControl:Origin
	oDim := oControl:Size
	//liScrollHeight := GetSystemMetrics( SM_CXHSCROLL )
	//liScrollWidth := GetSystemMetrics( SM_CXVSCROLL )

	// if !lSubForm .or. true
	liTemp := oPoint:X + oDim:Width + IIF(lAutoLayout, INSIDEFORMBORDER, 0)
	IF liTemp > liMinX
		liMinX := liTemp// + liScrollWidth
		lResize := TRUE
	ENDIF

	liTemp := oPoint:Y + oDim:Height + IIF(lAutoLayout, INSIDEFORMBORDER, 0)
	IF liTemp > liMinY
		liMinY := liTemp// + liScrollHeight
		lResize := TRUE
	ENDIF

	IF lResize
		//oFormDlg:Size:=Dimension{liMinX,liMinY}
		SELF:ChangeFormSize(SELF:origin, SELF:size)
		// Move the control if required
		IF lAutoLayout
			oControl:Origin:=oPoint
		ENDIF
	ENDIF
	// endif

	// Set the controls TABSTOP bit
	IF lAutoLayout .AND. !IsInstanceOf(oControl, #FixedText)
		oControl:SetStyle(WS_TabStop)
	ENDIF

	RETURN SELF

ACCESS AllowScroll AS LOGIC
	RETURN lAllowScroll

ASSIGN AllowScroll (lLogic AS LOGIC)

	RETURN lAllowScroll:=lLogic

ACCESS AutoLayout

	RETURN lAutoLayout

ASSIGN AutoLayout (lLogic)

	RETURN lAutoLayout:=lLogic

// TEXTBLOCK METHOD ChangeFormSize(oPoint, oDimension) CLASS __FormFrame
// 	//PP-030910 Method has been replaced with one supplied by S Ebert to improve visual aspects (Bug 78)
// 	LOCAL liHeight, liWidth AS LONG
// 	LOCAL lWantVScroll, lWantHScroll AS LOGIC
// 	LOCAL liScrollHeight, liScrollWidth AS LONG
// 	LOCAL oDlgSize, oCanvasSize AS Dimension
// 	LOCAL oDlgPos AS Point
// 	LOCAL liDlgPosX, liDlgPosY AS LONG
// 	LOCAL liMax AS LONG
// 	LOCAL lNewVScroll AS LOGIC
// 	LOCAL liBorderX, liBorderY AS LONG

// 	IF _AND(GetWindowLong(hwnd, GWL_EXSTYLE), WS_EX_CLIENTEDGE) != 0
// 		liBorderX := GetSystemMetrics(SM_CXEDGE) * 2
// 		liBorderY := GetSystemMetrics(SM_CYEDGE) * 2
// 	ENDIF

// 	liHeight := oDimension:Height
// 	liWidth := oDimension:Width
// 	oDlgSize := Dimension{liWidth-liBorderX,liHeight-liBorderY}
// 	oCanvasSize := Dimension{liWidth-liBorderX,liHeight-liBorderY}
// 	liScrollHeight := GetSystemMetrics(SM_CXHSCROLL)
// 	liScrollWidth := GetSystemMetrics(SM_CXVSCROLL)
// 	oDlgPos := oFormDlg:Origin
// 	liDlgPosX := oDlgPos:X
// 	liDlgPosY := oDlgPos:Y

// 	IF lViewingGBrowse
// 		SELF:size := oDimension
// 		SELF:Origin := oPoint
// 		IF (oBrowser != NULL_OBJECT)
// 			Send(oBrowser, #__AutoResize)
// 		ENDIF
// 		// return self
// 	ENDIF

// 	// Change the window sizes - Also see if we need scroll bars
// 	IF (liHeight < liMinY) .AND. lAllowScroll
// 		lWantVScroll := TRUE
// 	ENDIF
// 	IF (liWidth < liMinX) .AND. lAllowScroll
// 		lWantHScroll := TRUE
// 	ENDIF

// 	// If either scroll bars are not required - check that they do not
// 	// already exist and if they do delete them
// 	IF !lWantVScroll .AND. (oVScroll != NULL_OBJECT)
// 		SELF:EnableVerticalScroll(FALSE)
// 		oVScroll := NULL_OBJECT
// 	ENDIF
// 	IF !lWantHScroll .AND. (oHScroll != NULL_OBJECT)
// 		SELF:EnableHorizontalScroll(FALSE)
// 		oHScroll := NULL_OBJECT
// 	ENDIF

// 	// Create any scrollbars required and set their range
// 	IF lWantHScroll .AND. !lViewingGBrowse
// 		IF (oHScroll == NULL_OBJECT)
// 			oHScroll := SELF:EnableHorizontalScroll()
// 			oHScroll:ThumbPosition := 0
// 			oHScroll:UnitSize := liScrollHeight
// 			oHScroll:BlockSize := liScrollHeight * 2
// 			liDlgPosY -= liScrollHeight
// 		ENDIF
// 		oCanvasSize:Height := oCanvasSize:Height - liScrollHeight
// 		liMax := liMinX - liWidth
// 		IF lWantVScroll
// 			liMax += liScrollWidth
// 		ENDIF
// 		oHScroll:Range := Range{0, liMax}
// 		oHScroll:Show()
// 	ENDIF

// 	IF lWantVScroll .AND. !lViewingGBrowse
// 		IF (oVScroll == NULL_OBJECT)
// 			oVScroll := SELF:EnableVerticalScroll()
// 			oVScroll:ThumbPosition := 0
// 			oVScroll:UnitSize := liScrollWidth
// 			oVScroll:BlockSize := liScrollWidth * 2
// 			lNewVScroll := TRUE
// 		ENDIF
// 		liMax := liMinY - liHeight
// 		IF lWantHScroll
// 			liMax += liScrollHeight
// 		ENDIF
// 		oVScroll:Range := Range{0, liMax}
// 		oVScroll:Show()
// 	ENDIF

// 	// Move and size the windows correctly
// 	//SELF:Size := Dimension{liWidth, liHeight}
// 	//SELF:Origin := oPoint
// 	// 2.5c removes flicker
// 	WCMoveWindow(SELF, oPoint, Dimension{liWidth, liHeight}, TRUE)
// 	IF (oDlgSize:Height < liMinY)
// 		oDlgSize:Height := liMinY
// 	ENDIF
// 	IF (oDlgSize:Width < liMinX)
// 		oDlgSize:Width := liMinX
// 	ENDIF

// 	IF (liDlgPosX + oDlgSize:Width) < liWidth
// 		liDlgPosX := liWidth - oDlgSize:Width
// 		IF liDlgPosX > 0
// 			liDlgPosX := 0
// 			oDlgSize:Width := liWidth
// 		ENDIF
// 	ENDIF

// 	IF (liDlgPosY + oDlgSize:Height) < oCanvasSize:Height
// 		liDlgPosY := oCanvasSize:Height - oDlgSize:Height
// 		IF liDlgPosY > 0
// 			liDlgPosY := 0
// 			oDlgSize:Height := oCanvasSize:Height
// 		ENDIF
// 	ENDIF

// 	IF lNewVScroll .AND. (liDlgPosY + oDlgSize:Height) > oCanvasSize:Height
// 		liDlgPosY := oCanvasSize:Height - oDlgSize:Height
// 	ENDIF

// 	IF liDlgPosY > 0
// 		liDlgPosY := 0
// 		oDlgSize:Height := oCanvasSize:Height
// 	ENDIF

// 	IF (oVScroll != NULL_OBJECT)
// 		oVScroll:Range := Range{0, oDlgSize:Height - oCanvasSize:Height}
// 		oVScroll:ThumbPosition := oDlgSize:Height - oCanvasSize:Height + liDlgPosY
// 	ENDIF

// 	IF (oHScroll != NULL_OBJECT)
// 		oHScroll:Range := Range{0, oDlgSize:Width - oCanvasSize:Width}
// 		oHScroll:ThumbPosition := -liDlgPosX
// 	ENDIF

// 	//oFormDlg:Size := oDlgSize
// 	//oFormDlg:Origin := Point{liDlgPosX, liDlgPosY}
// 	//2.5c removes flicker
// 	WCMoveWindow(oFormDlg, Point{liDlgPosX, liDlgPosY}, oDlgSize, TRUE)

// 	RETURN SELF

METHOD ChangeFormSize(oPt, oDim, lWinCoordinates)
	//PP-030910 Method from S Ebert
	//PP-031129 Update from S Ebert
	//PP-040322 Update from S Ebert
	//SE-070421
	LOCAL liHeight, liWidth AS LONGINT
	LOCAL lWantVScroll, lWantHScroll AS LOGIC
	LOCAL liScrollHeight, liScrollWidth AS LONGINT
	LOCAL oDlgSize, oCanvasSize AS Dimension
	LOCAL liDlgPosX, liDlgPosY AS LONGINT
	LOCAL liBorderX, liBorderY AS LONGINT
	LOCAL sRect IS _WinRect
	LOCAL oDimension  AS Dimension
	LOCAL oPoint	   AS Point
	LOCAL sPoint IS _WinPoint
	IF !IsInstanceOfUsual(oDim, #Dimension)
		WCError{#ChangeFormSize,#__FormFrame,__WCSTypeError,oDim,1}:Throw()
	ENDIF
	IF !IsInstanceOfUsual(oPt, #Point)
		WCError{#ChangeFormSize,#__FormFrame,__WCSTypeError,oPt,1}:Throw()
	ENDIF
	oDimension := oDim
	oPoint	  := oPt

	liBorderX := liBorderY := LONGINT(GetFrameWidth(hWnd) * 2)

	liHeight  := oDimension:Height
	liWidth   := oDimension:Width

	oDlgSize       := Dimension{liWidth - liBorderX, liHeight - liBorderY}
	oCanvasSize    := Dimension{liWidth - liBorderX, liHeight - liBorderY}
	liScrollHeight := GetSystemMetrics(SM_CXHSCROLL)
	liScrollWidth  := GetSystemMetrics(SM_CXVSCROLL)

	GetWindowRect(oFormDlg:Handle(), @sRect)
	sPoint:x := sRect:Left
	sPoint:y := sRect:Top
	ScreenToClient(hWnd, @sPoint)  // dcaton 070328 wass using sRect, incompatible pointers
	liDlgPosX := sPoint:x
	liDlgPosY := sPoint:y

	IF IsLogic(lWinCoordinates) .AND. lWinCoordinates
		SetWindowPos(hWnd, NULL_PTR, oPoint:X, oPoint:Y, liWidth, liHeight, _OR(SWP_NOZORDER, SWP_NOACTIVATE))
	ELSE
		WCMoveWindow(SELF, Point{oPoint:X, oPoint:Y}, oDimension, TRUE)
	ENDIF

	IF lViewingGbrowse .AND. oBrowser != NULL_OBJECT
		Send(oBrowser, #__AutoResize)
	ENDIF

	IF (oDlgSize:Height < liMinY)
		oDlgSize:Height := liMinY
	ENDIF

	IF (oDlgSize:Width < liMinX)
		oDlgSize:Width := liMinX
	ENDIF

	IF lAllowScroll
		lWantVScroll := (liHeight < liMinY)
		lWantHScroll := (liWidth  < liMinX)

		IF lWantVScroll .AND. ! lWantHScroll
			lWantHScroll := (liWidth  - liScrollWidth  < liMinX)
		ENDIF
		IF lWantHScroll .AND. ! lWantVScroll
			lWantVScroll := (liHeight - liScrollHeight < liMinY)
		ENDIF
	ELSE
		lWantVScroll := lWantHScroll := FALSE
	ENDIF

	liWidth  := oDlgSize:Width
	liHeight := oDlgSize:Height

	IF lWantHScroll
		IF ! lViewingGbrowse
			IF oHScroll == NULL_OBJECT
				oHScroll := SELF:EnableHorizontalScroll()
				oHScroll:UnitSize  := liScrollHeight
				oHScroll:BlockSize := liScrollHeight * 2
				liDlgPosX := 0
			ENDIF
		ENDIF
		oCanvasSize:Height -= liScrollHeight
		liWidth := liMinX
	ELSE
		IF oHScroll != NULL_OBJECT
			SELF:EnableHorizontalScroll(FALSE)
			oHScroll := NULL_OBJECT
		ENDIF
		liDlgPosX := 0
	ENDIF

	IF lWantVScroll
		IF ! lViewingGbrowse
			IF (oVScroll == NULL_OBJECT)
				oVScroll := SELF:EnableVerticalScroll()
				oVScroll:UnitSize  := liScrollWidth
				oVScroll:BlockSize := liScrollWidth * 2
				liDlgPosY := 0
			ENDIF
		ENDIF
		oCanvasSize:Width -= liScrollWidth
		liHeight := liMinY
	ELSE
		IF oVScroll != NULL_OBJECT
			SELF:EnableVerticalScroll(FALSE)
			oVScroll := NULL_OBJECT
		ENDIF
		liDlgPosY := 0
	ENDIF

	IF (liDlgPosX + liWidth) < oCanvasSize:Width
		liDlgPosX := oCanvasSize:Width - liWidth
	ENDIF

	IF (liDlgPosY + liHeight) < oCanvasSize:Height
		liDlgPosY := oCanvasSize:Height - liHeight
	ENDIF

	IF liDlgPosX > 0
		liDlgPosX := 0
		oDlgSize:Width  := oCanvasSize:Width
	ENDIF

	IF liDlgPosY > 0
		liDlgPosY := 0
		oDlgSize:Height := oCanvasSize:Height
	ENDIF

	IF oHScroll != NULL_OBJECT
	   //SE-070421
	   oHScroll:SetInfo(Range{0, liMinX-1}, -liDlgPosX, oCanvasSize:Width)
		//oHScroll:Range := Range{0, liMinX  - oCanvasSize:Width}
		//oHScroll:ThumbPosition := -liDlgPosX
		oHScroll:Show()
	ENDIF

	IF oVScroll != NULL_OBJECT
	   //SE-070421
	   oVScroll:SetInfo(Range{0, liMinY-1}, -liDlgPosY, oCanvasSize:Height)
		//oVScroll:Range := Range{0, liMinY - oCanvasSize:Height}
		//oVScroll:ThumbPosition := -liDlgPosY
		oVScroll:Show()
	ENDIF

	SetWindowPos(oFormDlg:Handle(), NULL_PTR, liDlgPosX, liDlgPosY, oDlgSize:Width, oDlgSize:Height, _OR(SWP_NOZORDER, SWP_NOACTIVATE))

	//PP-031129 Fix for 109 removed, cause problems sizing elsewhere
	//PP-030910 Bug 109
	// InvalidateRect(oFormDlg:Handle(),NULL,TRUE)
	// UpdateWindow(oFormDlg:Handle())

	RETURN SELF

METHOD CreateSubform(nResourceID, oResID)
	LOCAL oFocus AS OBJECT
	LOCAL oNewForm AS __FormFrame
	LOCAL oSubFormDlg AS __FormDialogWindow
	LOCAL hFocus AS PTR
	LOCAL lBorder AS LOGIC
	LOCAL hSubFrameWnd AS PTR
	LOCAL sRect IS _winRect

	// DataPages don't have an associated control and will be created with nResourceID == 0
	IF (nResourceID > 0)
		//PP-041013 Change from S Ebert
		hSubFrameWnd := GetDlgItem(oFormDlg:Handle(), nResourceID)
		lBorder := (_AND(DWORD(_CAST, WS_EX_CLIENTEDGE), DWORD(_CAST, GetWindowLong(hSubFrameWnd, GWL_EXSTYLE))) > 0U) .OR.;
			(_AND(DWORD(_CAST, WS_BORDER), DWORD(_CAST, GetWindowLong(hSubFrameWnd, GWL_STYLE))) > 0U)
	ENDIF

	// First get the window that currently has focus. If this is either
	// a form dialog or a control on one we need to send it a WM_ACTIVATE
	// message after we create the subform
	hFocus := GetFocus()
	oFocus := __WCGetWindowByHandle(hFocus)
	IF oFocus!=NULL_OBJECT
		IF !IsInstanceOf(oFocus,#__FormDialogWindow)
			oFocus:=oFocus:Owner
			IF oFocus!=NULL_OBJECT .AND. !IsInstanceOf(oFocus,#__FormDialogWindow)
				oFocus:=NULL_OBJECT
			ENDIF
		ENDIF
	ENDIF

	// Create a new form object
	oNewForm := __FormFrame{oFormDlg, oResID, TRUE, lBorder, TRUE}

	oNewForm:SBCreate := TRUE

	oSubFormDlg := oNewForm:GetDialogWindow()

	// Size and position the new form according to subdata-control
	IF hSubFrameWnd != NULL_PTR
		//PP-041013 Change from S Ebert
		GetWindowRect(hSubFrameWnd, @sRect)

#ifdef __VULCAN__
   	MapWindowPoints(NULL_PTR, oFormDlg:Handle(), (_winPOINT PTR) @sRect, 2)
#else
	   MapWindowPoints(NULL_PTR, oFormDlg:Handle(), @sRect, 2)
#endif

		oNewForm:ChangeFormSize(Point{sRect:left, sRect:top}, Dimension{sRect:right-sRect:left, sRect:bottom-sRect:top}, TRUE)
		SetWindowPos(oNewForm:Handle(), hSubFrameWnd, 0, 0, 0, 0, _OR(SWP_NOSIZE, SWP_NOMOVE, SWP_NOREDRAW))
		ShowWindow(hSubFrameWnd, SW_HIDE)
	ELSE
		oNewForm:ChangeFormSize(oSubFormDlg:Origin, oSubFormDlg:Size)
	ENDIF

	// Set the subforms parent form to this one and add the new subform
	// to it's parents list
	oSubFormDlg:SetSubformParent(oFormDlg)

	// Show the new form
	// oNewForm:Show()

	// Reactivate previously active form
	IF (oFocus != NULL_OBJECT)
		SetFocus(hFocus)
		SendMessage(oFocus:Handle(), WM_ACTIVATE, WA_ACTIVE, 0 )
	ENDIF

	RETURN oNewForm

ACCESS DataWindow

	IF oDataWin != NULL_OBJECT
		RETURN oDataWin
	ELSEIF IsInstanceOf(oParent, #DataWindow)
		RETURN oParent
	ENDIF
	RETURN NULL_OBJECT

ASSIGN DataWindow(oNewDW)

	oDataWin := oNewDW
	//if (oImp != NULL_OBJECT) .and. IsMethod(oImp, #SetOwner)
	// Send(oImp, #SetOwner, oNewDW)
	//endif

	RETURN
//
// METHOD DeleteSubform ( oFormFrame ) CLASS __FormFrame
// 	//PP-041014 Method unused, to be removed next repository build
// 	RETURN SELF

METHOD Destroy() AS USUAL CLIPPER

	IF (oFormDlg != NULL_OBJECT)
		IF (WCAppGetDialogWindow() == oFormDlg:Handle())
			WCAppSetDialogWindow(NULL_PTR)
		ENDIF
		IF !InCollect()
			oFormDlg := NULL_OBJECT
			oBrowser := NULL_OBJECT
			oSubFrame := NULL_OBJECT  // Not used
			oVScroll := NULL_OBJECT
			oHScroll := NULL_OBJECT
		ENDIF
	ENDIF
	SUPER:Destroy()

	RETURN SELF

METHOD FocusChange(oFocusChangeEvent)

	LOCAL oFCE := oFocusChangeEvent AS FocusChangeEvent
	IF oFCE:GotFocus
		SELF:SetFocusToForm()
	ENDIF

	RETURN SUPER:FocusChange(oFCE)

METHOD GetDialogWindow()

	RETURN oFormDlg

ACCESS HelpDisplay
	LOCAL oDW AS DataWindow

	oDW := SELF:DataWindow
	IF (oDW != NULL_OBJECT)
		RETURN oDW:HelpDisplay
	ENDIF

	RETURN NULL_OBJECT

METHOD HelpRequest(oHelpRequestEvent)
	LOCAL cHelpContext AS STRING

	IF IsInstanceOfUsual(oHelpRequestEvent, #HelpRequestEvent) ;
		.AND. SELF:HelpDisplay!=NULL_OBJECT;
		.AND. oHelpRequestEvent:Helptype==HELPCONTROL
		IF oHelpRequestEvent:ItemID==3244
			IF SELF:Hyperlabel!=NULL_OBJECT ;
				.and. (NULL_STRING != (cHelpContext:=SELF:Hyperlabel:HelpContext))
				SELF:HelpDisplay:Show(cHelpContext)
			ELSE
				SELF:HelpDisplay:Show("Window_WindowCanvas")
			ENDIF
		ENDIF
	ELSE
		IF (SELF:DataWindow != NULL_OBJECT)
			SELF:DataWindow:HelpRequest(oHelpRequestEvent)
			//  We need to set the event return value to prevent the from being called twice.
			SELF:EventReturnValue := SELF:DataWindow:EventReturnValue
		ELSE
			SUPER:HelpRequest(oHelpRequestEvent)
		ENDIF
	ENDIF

	RETURN NIL

METHOD HorizontalScroll(oScrollEvent)
   //SE-070421
	LOCAL oPoint AS Point
	LOCAL oSE := oScrollEvent AS ScrollEvent

	oPoint 	:= oFormDlg:Origin
	oPoint:X := -oSE:Position
	oFormDlg:Origin := oPoint
	oParent:HorizontalScroll(oSE)
	RETURN SELF

   /*
   LOCAL oPoint AS Point
	LOCAL iPos AS INT
	LOCAL iOldPos AS INT
	LOCAL oSE := oScrollEvent AS ScrollEvent

	oPoint 	:= oFormDlg:Origin
	iPos 		:= oSE:Position
	iOldPos 	:= oSE:OldPosition
	oPoint:X := oPoint:X - iPos + oSE:OldPosition
	oFormDlg:Origin := oPoint
	oParent:HorizontalScroll(oSE)
	RETURN SELF
   */

CONSTRUCTOR(oOwner, oResID, lScroll, lBorder, lIsSub)
	LOCAL uResIdId AS USUAL
	LOCAL dwSubStyle AS DWORD
	LOCAL symFDialog AS SYMBOL

	IF IsNil(lScroll)
		lAllowScroll := TRUE
	ELSE
		lAllowScroll := lScroll
	ENDIF

	IF IsNil(lIsSub)
		lSubForm := FALSE
	ELSE
		lSubForm := lIsSub
	ENDIF

	SUPER(oOwner, FALSE)

	//PP-031129 Bug 109
	SELF:SetStyle(WS_CLIPSIBLINGS,TRUE)
	SELF:SetStyle(WS_CLIPCHILDREN,FALSE)

	IF !IsNil(lBorder) .AND. lBorder
		SELF:EnableBorder(WindowNonSizingBorder)
	ENDIF

	//PP-030627
	//PP-030505
	symFDialog := oOwner:symFormDialog
	IF symFDialog == NULL_SYMBOL
		symFDialog := #__FormDialogWindow
	ENDIF
	uResIdId:=oResID:ID
	IF IsLong(uResIdId) .AND. (uResIdId == -1)
		oFormDlg := CreateInstance(symFDialog,SELF, ResourceID{"IDD_DEFDLG", _GetInst()})
	ELSE
		oFormDlg := CreateInstance(symFDialog,SELF, oResId)
	ENDIF

	// !!!!
	dwSubStyle := DWORD(_CAST, GetWindowLong(oFormDlg:Handle(), GWL_STYLE))
	IF (_AND(dwSubStyle, DWORD(_CAST, DS_CONTROL)) > 0)
		dwSubStyle := DWORD(GetWindowLong(SELF:Handle(), GWL_EXSTYLE))
		SetWindowLong(SELF:Handle(), GWL_EXSTYLE, LONGINT(_CAST, _OR(dwSubStyle, DWORD(_CAST, WS_EX_CONTROLPARENT))))

		IF IsInstanceOf(oOwner, #__FormDialogWindow)
			dwSubStyle := DWORD(GetWindowLong(oOwner:Handle(), GWL_EXSTYLE))
			SetWindowLong(oOwner:Handle(), GWL_EXSTYLE, LONGINT(_CAST, _OR(dwSubStyle, DWORD(_CAST, WS_EX_CONTROLPARENT))))
		ENDIF
	ENDIF
	// !!!

	oFormDlg:Origin := Point{0,0}
	oFormDlg:Show()

	liMinX := Max(oFormDlg:Size:Width, IIF(!lSubForm, MIN_DATAWINDOWWIDTH, 0))
	liMinY := oFormDlg:Size:Height

	SELF:__ResizeParent()
	RETURN

ACCESS IsSubform

	RETURN lSubform

ASSIGN IsSubform(l)

	RETURN lSubform:=l

METHOD MouseDrag(oEvent)
	LOCAL oObject AS OBJECT

	oObject:= oParent
	//oObject:MouseDrag(__ObjectCastClassPtr(oEvent, __pCMouseEvent))
	oObject:MouseDrag(MouseEvent{oEvent})

	//	oParent:Owner:Dispatch(oEvent)
	RETURN SELF

ACCESS Owner

	IF SELF:dataWindow != NULL_OBJECT
		RETURN SELF:DataWindow
	ENDIF
	RETURN SUPER:Owner

METHOD ResetMinSize()
	liMinX := IIF(!lSubForm, MIN_DATAWINDOWWIDTH, 0)
	liMinY := 2
	RETURN SELF

ACCESS SBCreate

	RETURN lSBCreateSubform

ASSIGN SBCreate(lSBCreate)

	RETURN lSBCreateSubform:=lSBCreate

METHOD SetFocusToForm ( )
	LOCAL hWndCtrl AS PTR

	// If focus is not returning to any specific control then set
	// to the last active control (if any)
	IF (oBrowser != NULL_OBJECT) .AND. lViewingGBrowse
		SetFocus(oBrowser:Handle())
		RETURN SELF
	ENDIF

	// Send WM_ACTIVATE message to dialog to set the currently active dialog
	IF (oFormDlg == NULL_OBJECT)
		RETURN SELF
	ENDIF
	//oFormDlg:SetFocus()

	hWndCtrl := GetFocus()
	IF (hWndCtrl == NULL_PTR) .OR. (GetParent(hWndCtrl) != oFormDlg:Handle())
		IF !oFormDlg:SetFocusToPrev()
			oFormDlg:SetFocus()
		ENDIF
	ENDIF

	RETURN SELF

METHOD SetGBrowse(oDataBrowser)
	//PP-040515 Update S.Ebert

	oBrowser := oDataBrowser
	IF oContextMenu != NULL_OBJECT
		oBrowser:ContextMenu := oContextMenu
	ENDIF
	RETURN SELF

METHOD VerticalScroll (oScrollEvent)
   //SE-070421
	LOCAL oPoint AS Point
	LOCAL oSE := oScrollEvent AS ScrollEvent

	oPoint := oFormDlg:Origin

	SetWindowPos(oFormDlg:Handle(), NULL_PTR, oPoint:X, -oSE:Position, 0, 0, _OR(SWP_NOSIZE, SWP_NOZORDER, SWP_NOACTIVATE))

	oParent:VerticalScroll(oSE)

	RETURN SELF

/*
	LOCAL oPoint AS Point
	LOCAL iPos AS INT
	LOCAL iOldPos AS INT
	LOCAL oSE := oScrollEvent AS ScrollEvent

	oPoint 		:= oFormDlg:Origin
	iPos 			:= oSE:Position
	iOldPos 		:= oSE:OldPosition
	//RvdH 070321 Take Coordinate system into account.
	IF WCGetCoordinateSystem()
		oPoint:Y 	:= oPoint:Y + iPos - oSE:OldPosition
	ELSE
		oPoint:Y 	:= oPoint:Y - (iPos - oSE:OldPosition)
	ENDIF
	oFormDlg:Origin := oPoint

	oParent:VerticalScroll(oSE)

	RETURN SELF
*/

METHOD ViewAs(lBrowse)
	LOCAL liTemp AS LONGINT

	// If we want to view the GBRowse
	IF lBrowse
		IF (oBrowser== NULL_OBJECT) //.or. lViewingGBrowse
			RETURN SELF
		ENDIF
		liHPos := -1
		liVPos := -1
		// Remove the scroll bars if they are there - Store the
		// Thumb position first so we can restore it later
		IF oVScroll!=NULL_OBJECT
			liVPos := oVScroll:ThumbPosition
			SELF:EnableVerticalScroll(FALSE)
			oVScroll := NULL_OBJECT
		ENDIF
		IF oHScroll!=NULL_OBJECT
			liHPos := oHScroll:ThumbPosition
			SELF:EnableHorizontalScroll(FALSE)
			oHScroll := NULL_OBJECT
		ENDIF
		// hWinPos := BeginDeferWindowPos(8)
		Send(oBrowser, #__AutoResize)
		oFormDlg:Hide()
		oBrowser:Show()
		// BringWindowToTop(oBrowser:Handle())

		// EndDeferWindowPos(hWinPos)
		lViewingGBrowse := TRUE
	ELSE
		//		hWinPos := BeginDeferWindowPos( 8 )
		// Reenable the scroll bars if required
		IF liHPos != -1
			oHScroll := SELF:EnableHorizontalScroll(TRUE)
			liTemp := GetSystemMetrics( SM_CYHSCROLL )
			oHScroll:UnitSize := liTemp
			oHScroll:BlockSize := liTemp * 2
			oHScroll:Show()
			oHScroll:ThumbPosition := liHPos
			liHPos := oHScroll:ThumbPosition
		ENDIF
		IF liVPos != -1
			oVScroll := SELF:EnableVerticalScroll(TRUE)
			oVScroll:ThumbPosition := liVPos
			liTemp := GetSystemMetrics( SM_CXVSCROLL )
			oVScroll:UnitSize := liTemp
			oVScroll:BlockSize := liTemp * 2
			oVScroll:Show()
		ENDIF
		lViewingGBrowse := FALSE
		// Show the dialog and hide the GBRowse
		IF (oBrowser != NULL_OBJECT)
			oBrowser:Hide()
		ENDIF
		oFormDlg:Show()
		// BringWindowToTop(oFormDlg:Handle())
		// Resize the dialog in case the user has resized the window
		// while the dialog was out of view
		SELF:ChangeFormSize( SELF:Origin, SELF:Size )
		//		EndDeferWindowPos( hWinPos )
	ENDIF

	RETURN SELF

END CLASS

FUNCTION GetFrameWidth(hWnd AS PTR) AS DWORD STRICT
	LOCAL sRect IS _WinRect
	LOCAL dwStyle, dwExStyle AS DWORD

	IF (hWnd == NULL_PTR)
		RETURN 0l
	ENDIF

	SetRect(@sRect,10,10,20,20)
	dwStyle   := DWORD(_CAST,GetWindowLong(hWnd, GWL_STYLE))
	dwExStyle := DWORD(_CAST,GetWindowLong(hWnd, GWL_EXSTYLE))

	AdjustWindowRectEx(@sRect, dwStyle, FALSE, dwExStyle)

	RETURN DWORD(10l - sRect:Left)

	// Calculates the width of the windowframe depending of the windowstyles.

#region defines
DEFINE INSIDEFORMBORDER := 5
DEFINE MIN_DATAWINDOWWIDTH := 50
#endregion