Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Use of ASCII seperators for Windows 98 systems

Use of ASCII seperators for Windows 98 systems

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    J B 0
    wrote on last edited by
    #1

    Hi guys, I'm looking for some ASCII characters that can be used as some sort of separator delimiters. For example, I have few string fields I'd concatenate into one long string and put into CListBox. Then I'd need to be able to retrieve the string and break them up back to original fields. So ideally, those separators should be invisible on the display.

    (S)Hi, The(E)(S) Code (E)(S)Project is Cool!(E)
    

    would display as

    Hi, The Code project is Cool!
    

    where (S) is invisible start delimiter and (E) is the end delimiter. I tried "Unit Separator" and "Record Separator" (0x1F and 0x1E respectively), they work fine in Windows XP, where these are not displayed. However, when I moved the app to Windows 98, they are shown visibly as rectangle blocks. I'm wondering if the difference is due to the uses of unicode and not. If so, are there any ASCII I can use for my purpose? Thanks alot!

    J 1 Reply Last reply
    0
    • J J B 0

      Hi guys, I'm looking for some ASCII characters that can be used as some sort of separator delimiters. For example, I have few string fields I'd concatenate into one long string and put into CListBox. Then I'd need to be able to retrieve the string and break them up back to original fields. So ideally, those separators should be invisible on the display.

      (S)Hi, The(E)(S) Code (E)(S)Project is Cool!(E)
      

      would display as

      Hi, The Code project is Cool!
      

      where (S) is invisible start delimiter and (E) is the end delimiter. I tried "Unit Separator" and "Record Separator" (0x1F and 0x1E respectively), they work fine in Windows XP, where these are not displayed. However, when I moved the app to Windows 98, they are shown visibly as rectangle blocks. I'm wondering if the difference is due to the uses of unicode and not. If so, are there any ASCII I can use for my purpose? Thanks alot!

      J Offline
      J Offline
      Johan Rosengren
      wrote on last edited by
      #2

      There are no characters you can use for non-UNICODE, the ANSI-fonts are supposed to show a "dummy"-character for codes they don't define. So, yes, you are right, this is a question of UNICODE and non-UNICODE :-) What I would have done would be to create an owner-drawn listbox (which is not at all difficult once you've done it once or twice, if you hesitate). There, I would have split the strings according to some of me defined delimiter.

      J 1 Reply Last reply
      0
      • J Johan Rosengren

        There are no characters you can use for non-UNICODE, the ANSI-fonts are supposed to show a "dummy"-character for codes they don't define. So, yes, you are right, this is a question of UNICODE and non-UNICODE :-) What I would have done would be to create an owner-drawn listbox (which is not at all difficult once you've done it once or twice, if you hesitate). There, I would have split the strings according to some of me defined delimiter.

        J Offline
        J Offline
        J B 0
        wrote on last edited by
        #3

        Thanks alot Johan, I'm trying to think very hard to how Owner Draw on CListCtrl (it's actually CCtrlList I'm using) can help me. But you were right. Since I haven't done this before, I have trouble to figure out a way. I'd really appreciate some hints here :) Do you mean that I could somehow display the string and "hide" those delimiters? My understanding to Owner Draw is being able to draw images and customise text. I don't really know how it can help in my case. Thanks again

        J 1 Reply Last reply
        0
        • J J B 0

          Thanks alot Johan, I'm trying to think very hard to how Owner Draw on CListCtrl (it's actually CCtrlList I'm using) can help me. But you were right. Since I haven't done this before, I have trouble to figure out a way. I'd really appreciate some hints here :) Do you mean that I could somehow display the string and "hide" those delimiters? My understanding to Owner Draw is being able to draw images and customise text. I don't really know how it can help in my case. Thanks again

          J Offline
          J Offline
          Johan Rosengren
          wrote on last edited by
          #4

          Consider a listbox containing the string

          Alpha|beta

          In a draw handler, we get the string, and want to use the bar as a delimiter.

          // str contains the current line we are drawing

          CString left;
          CString right;
          int found = str.Find( _TCHAR( "|" );
          if( found != -1 )
          {
          left = str.Left( find );
          right = str.Right( str.GetLength() - ( found + 1 ) );

          // Now we can draw left and right to screen, delimited
          // a line or another character or just some spacing

          dc->TextOut( left, ... // will contain "Alpha"
          dc->TextOut( right, ... // will contain "Beta"

          }

          You might want to check the articles in http://www.codeproject.com/listctrl/[^], I notice that the very first one discusses owner-drawing.

          J 1 Reply Last reply
          0
          • J Johan Rosengren

            Consider a listbox containing the string

            Alpha|beta

            In a draw handler, we get the string, and want to use the bar as a delimiter.

            // str contains the current line we are drawing

            CString left;
            CString right;
            int found = str.Find( _TCHAR( "|" );
            if( found != -1 )
            {
            left = str.Left( find );
            right = str.Right( str.GetLength() - ( found + 1 ) );

            // Now we can draw left and right to screen, delimited
            // a line or another character or just some spacing

            dc->TextOut( left, ... // will contain "Alpha"
            dc->TextOut( right, ... // will contain "Beta"

            }

            You might want to check the articles in http://www.codeproject.com/listctrl/[^], I notice that the very first one discusses owner-drawing.

            J Offline
            J Offline
            J B 0
            wrote on last edited by
            #5

            Thanks again, Johan, As I understand, it is to use the Owner Draw to customise the display of the text on list box. In your example, the text Alpha|beta can get shown as Alpha beta. And so supposedly, when I retrieve the text from the list box using GetText(), it should still return Alpha|beta? The actual content is not changed, just displayed differently on screen? Is it how this works? Thanks.

            J 1 Reply Last reply
            0
            • J J B 0

              Thanks again, Johan, As I understand, it is to use the Owner Draw to customise the display of the text on list box. In your example, the text Alpha|beta can get shown as Alpha beta. And so supposedly, when I retrieve the text from the list box using GetText(), it should still return Alpha|beta? The actual content is not changed, just displayed differently on screen? Is it how this works? Thanks.

              J Offline
              J Offline
              Johan Rosengren
              wrote on last edited by
              #6

              Exactly!

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups