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. UNICODE STRING IN one col of LISTCTRL

UNICODE STRING IN one col of LISTCTRL

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 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
    Jetli Jerry
    wrote on last edited by
    #1

    Hi all, I want have DLG application, which is not compiled with _UNICODE ( means it is not UNICODE ,right?). In that I am having one list control to display certaing strings. In perticular, I want to display strings in UNICODE (WCHAR) in say 2nd col of list ctrl for all rows, Is it possible to do this anyhow? Without compiling application to as unicode!!! Any suggestion? Jetli Constant Thing In World Is Change.

    M 1 Reply Last reply
    0
    • J Jetli Jerry

      Hi all, I want have DLG application, which is not compiled with _UNICODE ( means it is not UNICODE ,right?). In that I am having one list control to display certaing strings. In perticular, I want to display strings in UNICODE (WCHAR) in say 2nd col of list ctrl for all rows, Is it possible to do this anyhow? Without compiling application to as unicode!!! Any suggestion? Jetli Constant Thing In World Is Change.

      M Offline
      M Offline
      mark novak
      wrote on last edited by
      #2

      This is tricky but you can actually mix unicode and ansi windows within an Application. When you define _UNICODE all the macros get mapped their *W functions. So SendMessage becomes SendMessageW, etc. Windows converts between unicode and ansi between windows your behalf so that if you call SetWindowText from an ansi program to a unicode program, the recieving program will get unicode from the ansi that the sender sent. Windows tells if a window is unicode or not by how it was created. So RegisterClassA would be an window procedure expecting ansi and RegisterClassW excepts unicode. You can change this by calling SetWindowLongPtrW and passing GCLP_WNDPROC with a new WndProc. Make sure to end your new WndProc with CallWindowProcA because the original accepts ansi. This will however make the entire control unicode. If your really want to save every character you can and only want that column's strings in Unicode you can try a combination of LVS_OWNERDATA and LVS_OWNERDRAWFIXED to manage your own strings and drawing.

      J 1 Reply Last reply
      0
      • M mark novak

        This is tricky but you can actually mix unicode and ansi windows within an Application. When you define _UNICODE all the macros get mapped their *W functions. So SendMessage becomes SendMessageW, etc. Windows converts between unicode and ansi between windows your behalf so that if you call SetWindowText from an ansi program to a unicode program, the recieving program will get unicode from the ansi that the sender sent. Windows tells if a window is unicode or not by how it was created. So RegisterClassA would be an window procedure expecting ansi and RegisterClassW excepts unicode. You can change this by calling SetWindowLongPtrW and passing GCLP_WNDPROC with a new WndProc. Make sure to end your new WndProc with CallWindowProcA because the original accepts ansi. This will however make the entire control unicode. If your really want to save every character you can and only want that column's strings in Unicode you can try a combination of LVS_OWNERDATA and LVS_OWNERDRAWFIXED to manage your own strings and drawing.

        J Offline
        J Offline
        Jetli Jerry
        wrote on last edited by
        #3

        Many thanks for valuable reply. Mark Petrik Sosa wrote: If your really want to save every character you can and only want that column's strings in Unicode you can try a combination of LVS_OWNERDATA and LVS_OWNERDRAWFIXED to manage your own strings and drawing. Can u spread more lights on this.... Any sample how to do this.... And also after doing some look-search i found that if i call directly SendMessageW(). in that we pass Unicode params... i want to know whcih message internally passed when we call BOOL CListCtrl::SetItemText( int nItem, int nSubItem, LPTSTR lpszText ); Can this be done like this??? Thanks in advance. Jetli Constant Thing In World Is Change.

        M 1 Reply Last reply
        0
        • J Jetli Jerry

          Many thanks for valuable reply. Mark Petrik Sosa wrote: If your really want to save every character you can and only want that column's strings in Unicode you can try a combination of LVS_OWNERDATA and LVS_OWNERDRAWFIXED to manage your own strings and drawing. Can u spread more lights on this.... Any sample how to do this.... And also after doing some look-search i found that if i call directly SendMessageW(). in that we pass Unicode params... i want to know whcih message internally passed when we call BOOL CListCtrl::SetItemText( int nItem, int nSubItem, LPTSTR lpszText ); Can this be done like this??? Thanks in advance. Jetli Constant Thing In World Is Change.

          M Offline
          M Offline
          mark novak
          wrote on last edited by
          #4

          SetItemText is just a wrapper for LVM_SETITEMTEXT, which will be sent using SendMessageA because _UNICODE is not set. Be aware however that even if you send "unicode" messages to a window, windows will automatically convert them to ansi if the window is not unicode window. There are no samples that I know of, the easiest thing would be just to make the entire application unicode.

          J 1 Reply Last reply
          0
          • M mark novak

            SetItemText is just a wrapper for LVM_SETITEMTEXT, which will be sent using SendMessageA because _UNICODE is not set. Be aware however that even if you send "unicode" messages to a window, windows will automatically convert them to ansi if the window is not unicode window. There are no samples that I know of, the easiest thing would be just to make the entire application unicode.

            J Offline
            J Offline
            Jetli Jerry
            wrote on last edited by
            #5

            Many thanks. I will look for that. Jetli Constant Thing In World Is Change.

            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