Why are rectangles instead of cyrillic characters displayed in the statusbar of the Win32 C++ application?

  • Thread starter Thread starter Purple_Apple
  • Start date Start date
P

Purple_Apple

Guest
Hello. I have now the following problem. When I display messages in Cyrillic in the application status bar, when I first launch the application, they are displayed normally:

1594543.png

But at subsequent launches of the application, no matter what triangulation is performed, rectangles are displayed instead of Cyrillic characters. (Here I deliberately set up another triangulation, but could have Greenland, the effect would have been the same.)

1594544.png

Below is a bit of source code. In .h - file where class definition is:

class DelaunayWriteToFile
{
public:
DelaunayWriteToFile();
~DelaunayWriteToFile();
. . . . . . . . . . .
// Write sorted triangles vertex in output file *.node.
void WriteNodes(HWND hWnd, Mesh* m, Configuration* b, wstring nodeFileName, cancellation_token token);
// Write created triangles in output file *.ele.
void WriteElements(HWND hWnd, Mesh* m, Configuration* b, wstring eleFileName, cancellation_token token);
// Write triangles edges in output filr *.edge.
void WriteEdges(HWND hWnd, Mesh* m, Configuration* b, wstring edgeFileName, cancellation_token token);
// Write the neighbors of each triangles in output file *.neigh.
void WriteNeighbors(HWND hWnd, Mesh* m, Configuration* b, wstring neighborFileName, cancellation_token token);
private:
// Points to information message text.
wchar_t* pInfoMessage;
. . . . . . . . . . . .
}


In .cpp - file:

DelaunayWriteToFile::~DelaunayWriteToFile()
{
delete[] pInfoMessage;
}

void DelaunayWriteToFile::WriteNodes(HWND hWnd, Mesh* m, Configuration* b, wstring nodeFileName, cancellation_token token)
{
. . . . . . . . . . . . .
wstring message = L"Запись узлов триангуляционной сетки в файл \"" + nodeFileName + L"\"";
pInfoMessage = _wcsdup(message.c_str());
PostMessage(hWnd, WM_WRITESTATUSTEXT, (WPARAM)pInfoMessage, 0L);
. . . . . . . . . . . . .
}

void DelaunayWriteToFile::WriteElements(HWND hWnd, Mesh * m, Configuration * b, wstring eleFileName, cancellation_token token)
{
. . . . . . . . . . . . . .
wstring message = L"Запись сформированных треугольников в файл \"" + eleFileName + L"\"";
pInfoMessage = _wcsdup(message.c_str());
PostMessage(hWnd, WM_WRITESTATUSTEXT, (WPARAM)pInfoMessage, 0L);
. . . . . . . . . . . . . .
}

void DelaunayWriteToFile::WriteEdges(HWND hWnd, Mesh* m, Configuration* b, wstring edgeFileName, cancellation_token token)
{
. . . . . . . . . . . . . .
wstring message = L"Запись рёбер сформированных треугольников в файл \"" + edgeFileName + L"\"";
pInfoMessage = _wcsdup(message.c_str());
PostMessage(hWnd, WM_WRITESTATUSTEXT, (WPARAM)pInfoMessage, 0L);
. . . . . . . . . . . . . .
}

void DelaunayWriteToFile::WriteNeighbors(HWND hWnd, Mesh* m, Configuration* b, wstring neighborFileName, cancellation_token token)
{
. . . . . . . . . . . . . .
wstring message = L"Запись треугольников-соседей в файл \"" + neighborFileName + L"\"";
pInfoMessage = /*message.data();*/_wcsdup(message.c_str());
PostMessage(hWnd, WM_WRITESTATUSTEXT, (WPARAM)pInfoMessage, 0L);
. . . . . . . . . . . . . .
}
And in the main application file where in particular wWinMain() function is, these messages are being received:

. . . . . . . . . . .
// Points to received information message
wchar_t* pInfoMessage = nullptr;
. . . . . . . . . . .
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
. . . . . . . . . . .
case WM_WRITESTATUSTEXT: // Display an informational message in the application status bar.
pInfoMessage = (wchar_t*)wParam;
SendMessage(g_hWndStatusbar, SB_SETTEXTW, 0, (LPARAM)pInfoMessage);
break;
. . . . . . . . . . .
}
}
Please tell me why in the second, third, and so on tenth run, instead of cyrillic characters, rectangles are displayed? How to fix this defect? I hope for your help. Thank you very much in advance.

Continue reading...
 
Back
Top