Artist Guest
|
Posted: Sun Jun 27, 2004 9:13 pm Post subject: TMemo Displays Differently with CreateProcess() |
|
|
I have written a program that displays command line strings as a
debugging aid for another program using CreateProcess(). This debugging
aid uses a TMemo object to display the strings. The relevant portion of
the code is pasted below.
The TMemo displays differently when run in the IDE in debug mode than
when its exe file is invoked using CreateProcess() from another program.
When CreateProcess() is used the WordWrap property has no effect. In
spite of being set true the words are not wrapped. Setting ScrollBars to
ssBoth likewise has no effect. The Scroll Bars do not appear in spite of
characters being outside the display area. Also, in spite of using the
Append() method many times, all appended characters appear in one line.
Where the new lines should have been there were several vertical lines
instead. It is as if the TMemo object were set to substitute these
vertical lines for white space characters instead of act on them.
As a test I put some test characters in Run | Parameters. When the
program is run within the IDE these characters as well as "This is A
Test" characters hard coded in are displayed in separate lines as expected.
What is causing this difference?
I am using CBuilder5 Professional. I would like to upgrade but I am
confused as to the many upgrade options now available for CBuilder.
Recommendations for upgrade are welcome.
**** File "CommandLinsDisplay.cpp" ****
USEFORM("MainForm.cpp", Form1);
LPSTR lpCmdLineG; // Global Variable
//---------------------------------------------------------------------------
WINAPI WinMain
(HINSTANCE hCurInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int
nCmdShow)
//(HINSTANCE, HINSTANCE, LPSTR, int)
{ lpCmdLineG = lpCmdLine;
try
{
Application->Initialize();
Application->CreateForm(__classid(TForm1), &Form1);
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
return 0;
}
**** File "MainForm.cpp" ****
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
AnsiString Line;
Display->Text = "";
Display->Lines->Append( "This is" );
Display->Lines->Append( "A" );
Display->Lines->Append( "Test" );
Display->Lines->Append( Line.sprintf( "%d Parameters:", ParamCount() ));
Display->Lines->Append( Line.sprintf( "lpCmdLine = '%s'", lpCmdLineG ));
int i;
for( i=0; i<=ParamCount(); i++)
{ Display->Lines->Append( Line.sprintf("ParamStr[%d]:", i ));
Display->Lines->Append( Line.sprintf("'%s'", ParamStr(i).c_str() ));
}
}
--
If sj. appears in my email address remove it to respond.
It is a spam jammer.
|
|