c++ - SetWindowText crashes program when printing wchar_t -


Why do not I print text in my window when I use SetWindowText () can? This is my window creation code that looks like this:

  game_board [i] = CreateWindowEx (0, L "static", board_ elements [i], WS_HCLD | WS_VISIBLE | WS_BORDER, 0, 0, 0, 0, HWD, (HMEU) IDCJMTI + I + 1, HINT, Faucet);  

And when I write something:

  wchar_t c; For (i = 0; i <-15; i ++) {c = 'a' + i; Setwindotext (game_board [i], c); UpdateWindow (game_board [i]); }  

My program crashes after triggering my event.

If I use SetWindowText (game_board [i], L "TEXT"); then this text usually prints everywhere.

I need to de-emphasize all these issues and why I do not know why.

I am using VS13 and the Windows app written in project C ++ if I copy the code into codeboxes, then it will pop an error for every artist created in VS And when I remove all of them, then it works normally.

Why? Can anyone help me fix this?

Hopefully someone is a pointer to the null-terminated string but you try to give it the same letter are doing.

As a commentator is mentioned, this code should not be compiled too. You mention something about "Everything you need to buy". This is a problem that the casting is saying to the compiler "Do not worry about it, I know what I'm doing". But in this case, you do not, compiler errors were trying to save you from making mistakes, you should have heard.

Change the code to look like this:

  // Announce a character array Stack, which you can use to create an //c-style faucet-terminated string , As expected by the API function. Wchar_t str [2]; // Proceed and finish the string, because it will not change for each // loop iteration. Nool Terminator is always the last character in the string. Str [1] = l '\ 0'; For (i = 0; i  

Note L prefix. This indicates to the compiler that you are using a detailed character / string-required type for the wchar_t type.


Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -