WndCreateError

WndCreateError

Postby pieter » Tue Mar 24, 2015 10:17 am

I am trying to implement pBrowse in my companies main application

pBrowse inherits kBrowse and kBrowse inherit twbrowse. In the testapplication pBrowse(which inherit kBrowse) works fine(even with ado and SQL:D, see post: viewtopic.php?f=3&t=30404), but in the companies main application it gives a runtime error. I only changed KBROWSE in PBROWSE in one place to to test if that works (Still DBF based, so without SetAdo etc). Maybe there is a problem with the inheritence construction.

Below is a part of the error description.

Error description: Error FiveWin/6 Cannot create window or control:
Class: PBROWSE
Caption:
System Error: Cannot find window class.

Called from WNDCREATEERROR(917)
Called from PBROWSE:CREATE(898)
Called from KBROWSE:NEW(283)
Called from PBROWSE:NEW(73)

(I found function WndCreateError in C:\Pieter\fhw\source\classes\window.prg)

pbrowse.prg
Code: Select all  Expand view

** Class definition
CLASS pBrowse FROM kBrowse
    METHOD New( nRow, nCol, nWidth, nHeight, bLine, aHeaders, ;
                aColSizes, oWnd, cField, uVal1, uVal2, bChange,;
                bLDblClick, bRClick, oFont, oCursor, nClrFore,;
                nForeBack, cMsg, lUpdate, cAlias, lPixel, bWhen,;
                lDesign, bValid, bLClick, aActions, nStyle ) CONSTRUCTOR
   
    METHOD SetAdo()
   
               
ENDCLASS


METHOD New( nRow, nCol, nWidth, nHeight, bLine, aHeaders, aColSizes, oWnd,;
            cField, uVal1, uVal2, bChange, bLDblClick, bRClick,;
            oFont, oCursor, nClrFore, nClrBack, cMsg, lUpdate, cAlias,;
            lPixel, bWhen, lDesign, bValid, bLClick, aActions, ;
            nStyle ) CLASS pBrowse
       
        Super:New( nRow, nCol, nWidth, nHeight, bLine, aHeaders, aColSizes, oWnd,;
            cField, uVal1, uVal2, bChange, bLDblClick, bRClick,;
            oFont, oCursor, nClrFore, nClrBack, cMsg, lUpdate, cAlias,;
            lPixel, bWhen, lDesign, bValid, bLClick, aActions, ;
            nStyle )

RETURN Self


METHOD SetAdo( oRs, cAlias ) CLASS pBrowse

       ::cAlias    = cAlias
       ::bLogicLen = {|| oRs:RecordCount() }
       ::bGoTop    = {|| If( oRs:RecordCount() > 0, oRs:MoveFirst(), nil ) }
       ::bGoBottom := {|| If( oRs:RecordCount() > 0, oRs:MoveLast(), nil )  }
       ::bSkip     := {| n | AdoSkip( oRs, IfNil( n, 1 ) ) }

return nil

function AdoSkip( oRs, n )

   LOCAL nRec

   if oRs:RecordCount() == 0
      return 0
   endif

   nRec := oRs:AbsolutePosition
   If( oRs:Eof, oRs:MoveLast(), If( oRs:Bof, oRs:MoveFirst(),) )
   oRs:Move( n )
   If( oRs:Eof, oRs:MoveLast(), If( oRs:Bof, oRs:MoveFirst(),) )

return oRs:AbsolutePosition - nRec
 


.ch file:
Code: Select all  Expand view
#xcommand @ <nRow>, <nCol> PBROWSE [ <oBrw> ] FIELDS [<Flds,...>] ;
               [ ALIAS <cAlias> ] ;
               [ <sizes:FIELDSIZES, SIZES, COLSIZES> <aColSizes,...> ] ;
               [ <head:HEAD,HEADER,HEADERS,TITLE> <aHeaders,...> ] ;
               [ SIZE <nWidth>, <nHeigth> ] ;
               [ <dlg:OF,DIALOG> <oDlg> ] ;
               [ SELECT <cField> FOR <uValue1> [ TO <uValue2> ] ] ;
               [ ON CHANGE <uChange> ] ;
               [ ON [ LEFT ] CLICK <uLClick> ] ;
               [ ON [ LEFT ] DBLCLICK <uLDblClick> ] ;
               [ ON RIGHT CLICK <uRClick> ] ;
               [ FONT <oFont> ] ;
               [ CURSOR <oCursor> ] ;
               [ <color: COLOR, COLORS> <nClrFore> [,<nClrBack>] ] ;
               [ MESSAGE <cMsg> ] ;
               [ <update: UPDATE> ] ;
               [ <pixel: PIXEL> ] ;
               [ WHEN <uWhen> ] ;
               [ <design: DESIGN> ] ;
               [ VALID <uValid> ] ;
               [ ACTION <uAction,...> ] ;
               [ STYLE <nStyle> ] ;
      => ;
          [ <oBrw> := ] pBrowse():New( <nRow>, <nCol>, <nWidth>, <nHeigth>,;
                           [<Flds>], ;
                           [<aHeaders>], ;
                           [<aColSizes>], ;
                           <oDlg>, <(cField)>, <uValue1>, <uValue2>,;
                           [<{uChange}>],;
                           [\{|nRow,nCol,nFlags|<uLDblClick>\}],;
                           [\{|nRow,nCol,nFlags|<uRClick>\}],;
                           <oFont>, <oCursor>, <nClrFore>, <nClrBack>, <cMsg>,;
                           <.update.>, <cAlias>, <.pixel.>, <{uWhen}>,;
                           <.design.>, <{uValid}>, <{uLClick}>,;
                           [\{<{uAction}>\}], <nStyle> )
 


Anybody Ideas?

Best regards,

Pieter
User avatar
pieter
 
Posts: 117
Joined: Thu Jan 08, 2015 9:27 am

Re: WndCreateError

Postby AntoninoP » Tue Mar 24, 2015 10:30 am

Hello,
every TWindow derived class must have a class data lRegistered and call ::Register method.

Code: Select all  Expand view
CLASS pBrowse FROM kBrowse

    CLASSDATA lRegistered AS LOGICAL

    METHOD New( nRow, nCol, nWidth, nHeight, bLine, aHeaders, ;
                aColSizes, oWnd, cField, uVal1, uVal2, bChange,;
                bLDblClick, bRClick, oFont, oCursor, nClrFore,;
                nForeBack, cMsg, lUpdate, cAlias, lPixel, bWhen,;
                lDesign, bValid, bLClick, aActions, nStyle ) CONSTRUCTOR
   
    METHOD SetAdo()
   
               
ENDCLASS


METHOD New( nRow, nCol, nWidth, nHeight, bLine, aHeaders, aColSizes, oWnd,;
            cField, uVal1, uVal2, bChange, bLDblClick, bRClick,;
            oFont, oCursor, nClrFore, nClrBack, cMsg, lUpdate, cAlias,;
            lPixel, bWhen, lDesign, bValid, bLClick, aActions, ;
            nStyle ) CLASS pBrowse
           
        ::Register( nOR( CS_VREDRAW, CS_HREDRAW ) )
       
        Super:New( nRow, nCol, nWidth, nHeight, bLine, aHeaders, aColSizes, oWnd,;
            cField, uVal1, uVal2, bChange, bLDblClick, bRClick,;
            oFont, oCursor, nClrFore, nClrBack, cMsg, lUpdate, cAlias,;
            lPixel, bWhen, lDesign, bValid, bLClick, aActions, ;
            nStyle )

RETURN Self


Regards,
Antonino
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: WndCreateError

Postby pieter » Tue Mar 24, 2015 10:59 am

Hello Antonio,

Wow!, it works:D, thank you very much.

Pieter
User avatar
pieter
 
Posts: 117
Joined: Thu Jan 08, 2015 9:27 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Silvio.Falconi and 88 guests