別のウィンドウのテキストボックスに wchar_t を送信しようとしていますが、コンソールに出力すると正しく表示される理由がわかりませんが、テキストボックスに送信すると「????????」が追加されます。最後に。
// MyTest.h の関数
static HWND GetEditWindow()
{
HWND winmx = WinMX::GetWinMXWindow();
if(winmx == NULL) return NULL;
// Check for inner window
HWND inner = FindWindowEx(winmx, NULL, NULL, NULL);
while(inner != NULL)
{
TCHAR title[100];
GetWindowText(inner, title, 100);
if(wcsstr(title, L"WinMX Peer Network") != NULL && wcsstr(title, L"on WinMX Peer Network") == NULL)
return inner;
inner = FindWindowEx(winmx, inner, NULL, NULL);
}
// Check for floating window
HWND channels = FindWindowEx(NULL, NULL, NULL, NULL);
while(channels != NULL)
{
TCHAR title[100];
GetWindowText(channels, title, 100);
if(wmemcmp(title, L"WinMX Peer Network", 18) == 0)
return channels;
channels = FindWindowEx(NULL, channels, NULL, NULL);
}
// Failed
return NULL;
}
static map<wchar_t*, HWND> GetOpenWindows()
{
map<wchar_t*, HWND> results;
HWND winmx = WinMX::GetWinMXWindow();
if (winmx == NULL) return results;
// Check for inner chat windows.
HWND inner = FindWindowEx(winmx, NULL, NULL, NULL);
while(inner != NULL)
{
TCHAR title[100];
GetWindowText(inner, title, 100);
if(wcsstr(title, L" on WinMX Peer Network") != NULL)
{
wchar_t* newtitle = new wchar_t[wcslen(title) - 22];
wmemcpy(newtitle, title, wcslen(title) - 22);
results.insert(pair<wchar_t*,HWND>(newtitle, inner));
}
inner = FindWindowEx(winmx, inner, NULL, NULL);
}
// Check for floating chat windows.
HWND top = FindWindowEx(NULL, NULL, NULL, NULL);
while(top != NULL)
{
TCHAR title[100];
GetWindowText(top, title, 100);
if(wcsstr(title, L"on WinMX Peer Network") != NULL)
{
wchar_t* newtitle = new wchar_t[wcslen(title) - 22];
wmemcpy(newtitle, title, wcslen(title) - 22);
results.insert(pair<wchar_t*,HWND>(newtitle, top));
}
top = FindWindowEx(NULL, top, NULL, NULL);
}
return results;
}
// Main.cpp
#include <stdio.h>
#include "MyTest.h"
using namespace std;
void main()
{
map<wchar_t*, HWND> Wins = Api::GetOpenWindows();
HWND editwindow = Api::GetEditWindow();
HWND filterbar = FindWindowEx(editwindow, NULL, L"edit", NULL);
for(map<wchar_t*, HWND>::iterator it = Wins.begin(); it != Wins.end(); ++it)
{
wcout << it->first << "\n";
SendMessage(filterbar, WM_SETTEXT, NULL, (LPARAM)it->first);
}
getchar();
}
// Output:
// WindowNameHere_334334
// TextBox SetText OutPut:
// WindowNameHere_334334????????