X# 2.18 EnableCellDraw FIELDSPEC:VAL error

This forum is meant for questions and discussions about the X# language and tools
Post Reply
User avatar
Michal Rajnoha
Posts: 22
Joined: Wed Sep 29, 2021 6:57 am

X# 2.18 EnableCellDraw FIELDSPEC:VAL error

Post by Michal Rajnoha »

After upgrading from X# 2.13 to 2.18, DataColumn:EnableCellDraw stopped working with the following error:

Error message:
--------------
Description : cString is not of type STRING
Subsystem : Database
GenCode : EG_ARG Argument error
FuncSym : VAL
Severity : ES_ERROR
Can Default : False
Can Retry : False
Can Substitute : False
Argument : cString
Arguments : { 984}
Called from : VAL
Stack Trace :
FIELDSPEC:VAL (Line: 0)
DATACOLUMN:__DRAWCELLDATA (Line: 0)
__DRAWFLDDATA (Line: 0)
CALLWINDOWPROC (Line: 0)
__WCGBCHILDPROC (Line: 0)
DATABROWSER:RESTOREUPDATE (Line: 0)
DATABROWSER:USE (Line: 0)
RUNTIMEMETHODHANDLE:INVOKEMETHOD (Line: 0)
RUNTIMEMETHODINFO:UNSAFEINVOKEINTERNAL (Line: 0)
RUNTIMEMETHODINFO:INVOKE (Line: 0)
OOPHELPERS:SENDHELPER (Line: 0)
OOPHELPERS:SENDHELPER (Line: 0)
OOPHELPERS:DOSEND (Line: 0)
__INTERNALSEND (Line: 0)
TESTWINDOW:POPULATEVALUES (Line: 66)
STANDARDSHELLWINDOW:FILEOPEN (Line: 34)
RUNTIMEMETHODHANDLE:INVOKEMETHOD (Line: 0)
RUNTIMEMETHODINFO:UNSAFEINVOKEINTERNAL (Line: 0)
RUNTIMEMETHODINFO:INVOKE (Line: 0)
OOPHELPERS:SENDHELPER (Line: 0)
OOPHELPERS:SENDHELPER (Line: 0)
OOPHELPERS:DOSEND (Line: 0)
SEND (Line: 0)
WINDOW:__COMMANDFROMEVENT (Line: 0)
WINDOW:__PREMENUCOMMAND (Line: 0)
WINDOW:DISPATCH (Line: 0)
APPWINDOW:DISPATCH (Line: 0)
SHELLWINDOW:DISPATCH (Line: 0)
__WCSHELLWNDPROC (Line: 0)
CALLWINDOWPROC (Line: 0)
__WCCONTROLPROC (Line: 0)
DISPATCHMESSAGE (Line: 0)
APP:EXEC (Line: 0)
START (Line: 20)

Error Object created:
--------------------
SubSystem :Database
SubCode :0
GenCode :Argument error
OsCode :0
ArgType :NIL
FuncPtr :0
ArgNum :0
FuncSym :VAL
Severity :2
CanDefault :.F.
CanRetry :.F.
CanSubstitute :.F.
Operation :
Description :cString is not of type STRING
FileName :
Tries :0
FileHandle :0
SubCodeText :Unknown SubCode
Arg :cString
ArgTypeReq :NIL
MaxSize :0
SubstituteType :NIL
CallFuncSym :VAL



Included an example project. Simply run debug and press open file button.
Attachments
EnableCellDrawTest.zip
example project
(185.64 KiB) Downloaded 1809 times
User avatar
Chris
Posts: 4583
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: X# 2.18 EnableCellDraw FIELDSPEC:VAL error

Post by Chris »

Hi Michal,

Thanks, I see the problem with 2.18, although this does not exist in 2.19 and our current version either. Apparently it was something that was fixed later, but not sure what, will have a look into it and see if there's a workaround for 2.18.

In the meantime, can you please temporarily disable the EnableCellDraw code and check if everything else works fine for you with 2.18? How about RP?
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
User avatar
Michal Rajnoha
Posts: 22
Joined: Wed Sep 29, 2021 6:57 am

Re: X# 2.18 EnableCellDraw FIELDSPEC:VAL error

Post by Michal Rajnoha »

Chris wrote: Thu Apr 25, 2024 7:41 am In the meantime, can you please temporarily disable the EnableCellDraw code and check if everything else works fine for you with 2.18?
Yes, already did that. So far everything else works without issues, just have to sort through a hefty heap of new warnings.
User avatar
Chris
Posts: 4583
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: X# 2.18 EnableCellDraw FIELDSPEC:VAL error

Post by Chris »

Hi Michal,

OK, that's good to hear! I also found a workaround for the EnableCellDraw() problem in 2.18, please add this method in your ColorColumn class and it should work fine now:

Code: Select all

OVERRIDE METHOD __DrawCellData(hDC AS PTR, iX AS INT, iY AS INT, dwOptions AS DWORD, ptrRect AS PTR, ;
            pszData AS PSZ, dwLength AS DWORD) AS VOID STRICT
        LOCAL uValue AS USUAL
        LOCAL hBackgroundBrush AS PTR
        LOCAL ptrLogBrush IS _WINLOGBRUSH
        LOCAL dwOldCellTextColor := 0, dwOldCellBackground := 0 AS DWORD
        LOCAL lRestoreTextColor := FALSE, lRestoreBackground := FALSE AS LOGIC

        IF (oFieldSpec != NULL_OBJECT)
            uValue := oFieldSpec:Val(Psz2String(pszData))
        ELSE
            uValue := Send(oServer:FieldSpec(SELF:NameSym), #Val, Psz2String(pszData))
        ENDIF

        IF (symUserDrawMethod != NULL_SYMBOL)
            Send(SELF, symUserDrawMethod, uValue)
        ELSE
            SELF:DrawCellData(uValue)
        ENDIF

        IF (oCellTextColor != NULL_OBJECT)
            dwOldCellTextColor := SetTextColor(hDC, oCellTextColor:ColorRef)
            lRestoreTextColor := TRUE
        ENDIF

        IF (oCellBackground != NULL_OBJECT)
            hBackgroundBrush := oCellBackground:Handle()
            GetObject(hBackgroundBrush, _SIZEOF(_WINLOGBRUSH), @ptrLogBrush)
            dwOldCellBackground := SetBkColor(hDC, ptrLogBrush:lbColor)
            lRestoreBackground := TRUE
            IF (hBackgroundBrush != NULL_PTR)
                FillRect(hDC, ptrRect, hBackgroundBrush)
            ENDIF
        ENDIF

        ExtTextOut(hDC, iX, iY, dwOptions, ptrRect, pszData, dwLength, NULL_PTR)

        IF lRestoreTextColor
            SetTextColor(hDC, dwOldCellTextColor)
        ENDIF
        IF lRestoreBackground
            SetBkColor(hDC, dwOldCellBackground)
        ENDIF

        oCellTextColor := NULL_OBJECT
        oCellBackground := NULL_OBJECT
        RETURN
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
User avatar
Michal Rajnoha
Posts: 22
Joined: Wed Sep 29, 2021 6:57 am

Re: X# 2.18 EnableCellDraw FIELDSPEC:VAL error

Post by Michal Rajnoha »

Great, it works, thank you, Chris.
User avatar
robert
Posts: 4258
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Re: X# 2.18 EnableCellDraw FIELDSPEC:VAL error

Post by robert »

For others reading this: this fix is already included in 2.19.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
Post Reply