Corrupt Status Bar Message

When I repeatedly run the following code in VS10 debug mode, it behaves as I would expect. Right-clicking executes the expected code and the message in the status bar cycles correctly through the 2 cases. But when I run it as a release, the message is corrupted (I get a load of oriental characters). Making char* rcMess global doesn't help.

The following is the extraxt from WinProc:

switch (message)
if (++parallel==3)
//update status bar message
char* rcMess;
switch (parallel)
case 0:
rcMess="Right-click for parallel 1 execution";
case 1:
rcMess="Right-click for parallel 2 execution";
case 2:
rcMess="Right-click for serial execution";
SendMessage(GetDlgItem(hWnd,IDC_STATUS),SB_SETTEXT,2,(LPARAM) (rcMess));
InvalidateRect (hWnd,NULL,TRUE);
UpdateWindow (hWnd);

Any suggestions?
You are using ANSI text. You MUST use SendMessageA().
... or at least disable "using unicode character set" from project settings (it is enabled by default)
webJose and modoran.

Double education, thank you. Hadn't noted the different configurations between debug and release, and you both queued me to look at the implication of Unicode. I also changed char* to wchar_t* which is more appropiate I think.

Thank for your guidance, solved.
One more piece of knowledge: If you use wchar_t (or Windows API's WCHAR), you MUST use SendMessageW().

Read my reply here:

Basically, the idea is to write code that compiles no matter what the Unicode setting of your project. Your code currently compiles OK because the Unicode setting happens to match your data types. If you (or someone in your team) happens to change this for whatever reason, the code won't compile.
Top dollar, thank you.
Topic archived. No new replies allowed.