TC
Brian Vanderburg II
BrianVanderburg2 at aim.com
Sun Dec 2 07:22:45 PST 2007
My msg didn't get send it seems. IPC should send the data 'as-is' from
on end to the next, without any special conversions. TCP has no
problem. I think DDE has no problem execpt for XTYP_EXECUTE. I think
the reason is, for the other types (poke, etc), the data is considered
data, and the format flag is specified and unmodified (a unicode program
can poke wxIPC_TEXT ansi and the unicode server should get wxIPC_TEXT
ansi), but for execute, MSW does not consider it data, but a comand
'string', and so make sure it is converted to the format the program is
compiled in.
My idea is to just make execute support a string:
wxConnection::Execute(const wxString& command), and nothing more, and
the callback wxConnection::OnExecute(const wxString& topic, const
wxString& command)
When sending:
TCP - Convert it to utf8 always, send with strlen(str) + 1, no need to
send the format
DDE - Convert it to ansi in ansi builds/unicode in unicode builds and send
TCPServer::Execute(wxString& command)
{
wxUTF8Buf buf = command.utf8_str)
size = strlen(buf) + 1
send(wxIPC_EXECUTE)
write32(size)
write(buf, size)
}
DDEServer::Execute(...)
{
wxCStrData cstr = command.c_str();
#if wxUSE_UNICODE
wchar_t* realData = (wchar*_t)command;
realSize = (wcslen(realData) + 1) * sizeof(wchar_t)
#else
char* realData = (char*)command
realSIze = strlen(realData) + 1
#endif
DdeClientTransaction((LPBYTE)realData, realSize, ...)
}
On the receiving end:
DDE - Receive in correct for, remove terminator so it does not become
'part' of the string,
TCP, - Receive as utf8 and convert
DDECallback(...)
{
...
wxString cmd = wxEmptyString
#if wxUSE_UNICODE)
if(len >= sizeof(wchar_t)
{
len /= sizeof(wchar_t);
len -= 1; // So the null doesn't become 'embedded' as part of
the string
cmd = wxString((wchar_t*)data, len);
}
#else
if(len >= sizeof(char))
{
len /= sizeof(char)
len -= 1
wxString cmd((char*), size)
}
#endif
connection->OnExecute(cmd)
}
TCP Callback
...
size = read32()
read (data, size)
// input is utf8
wxString cmd = wxEmptyString;
if(size >= sizeof(char))
{
size /= sizeof(char)
size -= 1
cmd = wxString(data, wxConvUTF8, size)
}
connection->OnExecute(cmd)
Brian Vanderburg II
More information about the wx-dev
mailing list