Announcement

Collapse
No announcement yet.

Interesting MCase$ Effect

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Interesting MCase$ Effect

    In an app using a virtual ListView I have these two lines of code that place a value from a string array into the ListView. But some of the items in the ListView are displayed incorrectly - similar to other issues I've seen in the past when displaying Unicode text in a ListView. Unicode=1 is used in the code.

    Code:
    tmp$$ = MCase$(Chapters(iRow).title)  
    @pLVDI.item.pszText = StrPtr(tmp$$) 'text sent to ListView
    But if I remove the MCase$(), the text in the ListView is displayed correctly.

    This workaround also seems to work.

    Code:
    tmp$$ = Chapters(iRow).title
    tmp$$ = MCase$(tmp$$)
    Applying MCase$() to the original string array Chapter$() also works.

    I'll try to extract a compilable example from the larger code that demonstrates the problem. In my first attempt, just using a virtual-ListView snippet from my library, I don't see the same result.

  • #2
    It might be mcase$ , when used a certain combination it messes up.

    I had trouble using ListView_GetItemText macro. Hard coded a wide version it appears to work. Looking at the includes, it appears it should work if using %unicode and it does not. Thinking if there is 'a' mistake or mistakes, it would be noticed by now. I have had trouble with other things uncode with listview, just don't recall what they all are.
    A dozen what.

    Comment


    • #3
      Tested with small virtual ListView testcode and can't repeat the problem either. Did you try it with UCase$ or LCase$? I guess Chapters(iRow).title is a fixed length WString or WStringZ?

      Comment


      • #4
        Originally posted by Gary Beene View Post
        Code:
        tmp$$ = MCase$(Chapters(iRow).title)
        @pLVDI.item.pszText = StrPtr(tmp$$) 'text sent to ListView
        But if I remove the MCase$(), the text in the ListView is displayed correctly.

        This workaround also seems to work.

        Code:
        tmp$$ = Chapters(iRow).title
        tmp$$ = MCase$(tmp$$)
        Applying MCase$() to the original string array Chapter$() also works.
        What is UDT definition?
        Where does the data come from. Is it STRING, WSTRING (or UTF-8) originally?

        Comment


        • #5
          I can't get it to fail, went as far as putting imbedded nuls in the source string. Thinking maybe MCase$ might choke on them and it did not care.





          A dozen what.

          Comment


          • #6
            Should not spoken so soon , this exhibits your problem to a tee. Works without mcase$ and using it it looks like an unicode issue.

            Removed subitem adjustment.



            Code:
            CASE %LVN_GetDispInfoW ' virtual ListView asks for Item text
            pLVDI = CB.LPARAM
            LOCAL arry AS STRING
            LOCAL sz AS WSTRING
            arry = "ok"
            sz = MCASE$(arry)
            ' sz = "ok"
            
            
            IF (@pLVDI.item.mask AND %LVIF_TEXT) THEN
            wszName = PARSE$(gFiles(@pLVDI.item.iItem), $TAB, @pLVDI.item.iSubItem +1 )  <<<< removed +1
            @pLVDI.item.pszText = STRPTR(sz)
            END IF
            A dozen what.

            Comment


            • #7
              Could it have something to do with the use/nonuse of the optional "ANSI|OEM" argument in the MCASE$() function? (I honestly don't know)
              Syntax s$ = MCASE$(string_expression [,ANSI | OEM])
              Remarks MCASE$ returns a string equivalent to string_expression, except that the first letter of each word is capitalized, while the remaining characters are forced to lowercase. A word is considered to be a consecutive series of letters. The optional ANSI or OEM parameter specifies whether the conversion is made using the ANSI charset for the system, or the original IBM OEM charset. If no charset is specified, PowerBASIC for Windows uses the system ANSI charset, while PB/CC uses the IBM OEM charset. Only "International" characters in the range of CHR$(128) to CHR$(255) are affected by this parameter.
              Michael Mattias
              Tal Systems (retired)
              Port Washington WI USA
              [email protected]
              http://www.talsystems.com

              Comment


              • #8
                Michael,
                good point. This caught my eye because I have had bad way to go with Listview and Unicode. With that in mind . I took and rewrote it in C++ and well it works. Make of that what you will.
                A dozen what.

                Comment

                Working...
                X