Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 566979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:02:04+00:00 2026-05-13T13:02:04+00:00

HWND wndHandle; //global variable // code snipped WNDCLASSEX wcex; // code snipped wcex.lpszClassName =

  • 0
HWND wndHandle; //global variable

// code snipped

WNDCLASSEX wcex;

// code snipped

wcex.lpszClassName = (LPCWSTR) "MyTitleName";

 // code snipped

wndHandle = CreateWindow(
            (LPCWSTR)"MyTitleName",     //the window class to use
            (LPCWSTR)"MyTitleName",     //the title bar text
...
...

I am following a tutorial for Win32 Window application. The code above is used to set the name of the title bar of the window screen. The compiler yells at me : “cannot convert from ‘const char [12]’ to ‘LPCWSTR'” so okay, I typecasted my string “MyTitleName” with (LPCWSTR), and everything compiled just fine. However, during runtime, the title of the window screen turns out to be Chinese characters. I tried change the string around and the Chinese characters always change according to my string somehow. I am using XP Visual C++ 2008 Express Edition and I got English (United States) as a setting for non-unicode programs. I don’t get it. How come the string become Chinese?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T13:02:05+00:00Added an answer on May 13, 2026 at 1:02 pm

    Your application is being compiled as a unicode application (this is defined in the project settings). This means that strings you pass to Windows API functions need to be wide-character strings, specified like this: L"MyTitleName". You can’t cast to LPCWSTR because that won’t actually change the string type, it will just try to pass the string off as something it isn’t.

    This code should work:

    wcex.lpszClassName = L"MyTitleName";
    
     // code snipped
    
    wndHandle = CreateWindow(
                L"MyTitleName",     //the window class to use
                L"MyTitleName",     //the title bar text
                ...
    

    If you want to use the original code from the tutorial without modifying it, you can disable unicode mode: In the project properties go to ‘General’ tab, and set Character Set to Use Multi-Byte Character Set. Don’t do this for any program which might have to support additional languages someday.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 285k
  • Answers 285k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you just want to know the 2 things you… May 13, 2026 at 4:37 pm
  • Editorial Team
    Editorial Team added an answer On a separate thread in your application, poll a table… May 13, 2026 at 4:37 pm
  • Editorial Team
    Editorial Team added an answer For SELECTs you can use the FOUND_ROWS construct (documented here):… May 13, 2026 at 4:37 pm

Related Questions

//window is an HWND LPWSTR path = new WCHAR[1024]; DWORD size = 1024; GetWindowText(window,
If I know the hwnd of a window, could I get it's position and
I want an HWND that is transparent to clicks (i.e. passes them through to
Given a handle of type HWND is it possible to confirm that the handle
How can I cast long to HWND (C++ visual studio 8)? Long lWindowHandler; HWND

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.