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. how to display unicode without unicode built?

how to display unicode without unicode built?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
9 Posts 5 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.
  • P Offline
    P Offline
    Peter Chan 0
    wrote on last edited by
    #1

    I want to display a unicode string in my CStatic(label) control. But I don't want to bulit my application unicode(add _UNICODE/UNICODE in preprocessor). Is there any solution?

    R K K 3 Replies Last reply
    0
    • P Peter Chan 0

      I want to display a unicode string in my CStatic(label) control. But I don't want to bulit my application unicode(add _UNICODE/UNICODE in preprocessor). Is there any solution?

      R Offline
      R Offline
      Rajesh R Subramanian
      wrote on last edited by
      #2

      You can never display UNICODE text in a non-unicode application. Therefore, your only solution would be to display it as an image.


      Nobody can give you wiser advice than yourself. - Cicero

      P S 2 Replies Last reply
      0
      • R Rajesh R Subramanian

        You can never display UNICODE text in a non-unicode application. Therefore, your only solution would be to display it as an image.


        Nobody can give you wiser advice than yourself. - Cicero

        P Offline
        P Offline
        Peter Chan 0
        wrote on last edited by
        #3

        Thanks.

        1 Reply Last reply
        0
        • P Peter Chan 0

          I want to display a unicode string in my CStatic(label) control. But I don't want to bulit my application unicode(add _UNICODE/UNICODE in preprocessor). Is there any solution?

          K Offline
          K Offline
          khan
          wrote on last edited by
          #4

          I think you could use code similar to the following: ::SetWindowTextW(m_Static.m_hWnd, L"Unicode text here"); Where m_Static is your static control.

          this is this.

          P 1 Reply Last reply
          0
          • R Rajesh R Subramanian

            You can never display UNICODE text in a non-unicode application. Therefore, your only solution would be to display it as an image.


            Nobody can give you wiser advice than yourself. - Cicero

            S Offline
            S Offline
            Stephen Hewitt
            wrote on last edited by
            #5

            This is not the case. Take the following example ANSI application:

            int APIENTRY WinMain(HINSTANCE hInstance,
            HINSTANCE hPrevInstance,
            LPSTR lpCmdLine,
            int nCmdShow)
            {
            MessageBoxW(NULL, L"This string is UNICODE!", L"Unicode", MB_OK);

            return 0;
            

            }

            In this case all the UNICODE define (and related ones) does is map the macro MessageBox to either the MessageBoxA function (non-UNICODE) or the MessageBoxW function (UNICODE). By using MessageBoxW we get the UNICODE version regardless the the setting.

            Steve

            R 1 Reply Last reply
            0
            • K khan

              I think you could use code similar to the following: ::SetWindowTextW(m_Static.m_hWnd, L"Unicode text here"); Where m_Static is your static control.

              this is this.

              P Offline
              P Offline
              Peter Chan 0
              wrote on last edited by
              #6

              Yeah, I have tried that. But what it displayed only "????????????" So I think the only way is building it in unicode

              S 1 Reply Last reply
              0
              • P Peter Chan 0

                I want to display a unicode string in my CStatic(label) control. But I don't want to bulit my application unicode(add _UNICODE/UNICODE in preprocessor). Is there any solution?

                K Offline
                K Offline
                KarstenK
                wrote on last edited by
                #7

                Convert the Unicode text to ansi text. If this is not possible than you need a Unicode application.:omg:

                Greetings from Germany

                1 Reply Last reply
                0
                • P Peter Chan 0

                  Yeah, I have tried that. But what it displayed only "????????????" So I think the only way is building it in unicode

                  S Offline
                  S Offline
                  Stephen Hewitt
                  wrote on last edited by
                  #8

                  It worked perfectly when I tried it just then. Also, you may want to investigate the CCM_SETUNICODEFORMAT message.

                  Steve

                  1 Reply Last reply
                  0
                  • S Stephen Hewitt

                    This is not the case. Take the following example ANSI application:

                    int APIENTRY WinMain(HINSTANCE hInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpCmdLine,
                    int nCmdShow)
                    {
                    MessageBoxW(NULL, L"This string is UNICODE!", L"Unicode", MB_OK);

                    return 0;
                    

                    }

                    In this case all the UNICODE define (and related ones) does is map the macro MessageBox to either the MessageBoxA function (non-UNICODE) or the MessageBoxW function (UNICODE). By using MessageBoxW we get the UNICODE version regardless the the setting.

                    Steve

                    R Offline
                    R Offline
                    Rajesh R Subramanian
                    wrote on last edited by
                    #9

                    Thanks for pointing it out, I think I've been avoiding ANSI builds for all good reasons. I've never tried what you've suggested.


                    Nobody can give you wiser advice than yourself. - Cicero

                    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