Mail Archives: cygwin/2010/01/07/16:37:53
I noticed Lynx kept changing my window title. According to the source code it was a call to SetConsoleTitle, part of the Windows API. Rather than modifying the Lynx source code I wrote a short console program in Visual C++ which I can use after exiting Lynx. It compiled under Visual Studio 2010 demo version to a 7168 byte executable.
Then I created a version of the program to compile under GCC. I felt this version was simpler in the code because I was able to dispense with wide character handling, and I guess that's possible in Visual C++ but I think it might require changing some obscure compiler settings. The result was 9728 bytes when compiled with default gcc settings.
These may not be appropriate to use with an xterm window.
////////////////////////////////////////////////////////////////////////////////
// Visual C++ version
#include <windows.h>
#include <wchar.h>
int _tmain(int argc, _TCHAR* argv[]) {
TCHAR *field;
int i;
size_t st;
if (argc > 1) {
for (i = 1, st = 0; i < argc; i++) {
st += wcslen(argv[i]);
}
st += argc - 2;
field = (TCHAR*)malloc(st * sizeof(TCHAR));
field[0] = 0;
for (i = 1; i < argc; i++) {
wcscat(field, argv[i]);
if (i < argc - 1)
wcscat(field, _T(" "));
}
SetConsoleTitle(field);
}
else {
SetConsoleTitle(_T(""));
}
return 0;
}
////////////////////////////////////////////////////////////////////////////////
// GCC version
#include <windows.h>
int main(int argc, char **argv) {
char *field;
int i;
size_t st;
if (argc > 1) {
for (i = 1, st = 0; i < argc; i++) {
st += strlen(argv[i]);
}
st += argc - 2;
field = (char*)malloc(st);
field[0] = 0;
for (i = 0; i < argc; i++) {
strcat(field, argv[i]);
if (i < argc - 1)
strcat(field, " ");
}
SetConsoleTitle(field);
}
else {
SetConsoleTitle("");
}
return 0;
}
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
- Raw text -