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

  • SEARCH
  • Home
  • 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

Related Questions

This is the code I have: HWND WebformCreate(HWND hParent, UINT id) { return CreateWindowEx(0,
I'm using one 3rd party SDK which get hwnd (window handle) and paints something
I have got a crash at calling function Clearrendertargetview(). Below is the code: HWND
To sum it up, I need to do this: 12345(hWnd) -> C:\setup.exe Right now,
Regarding: PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) If hWnd is NULL, PeekMessage retrieves messages for
Which is preferred, method 1 or method 2? Method 1: LRESULT CALLBACK wpMainWindow(HWND hwnd,
I am creating a window which opens to a dynamic title. I would like
Ok so I'm working with vectors today yaya! well im also working with getcursorpos()
I have a C++/CLI based install application which needs to close another app I've
I'm trying to copy a file from one location to another using SHFileOperation: SHFILEOPSTRUCT

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.