//---------------------------------------------------------------------------- // ObjectWindows - (C) Copyright 1991, 1994 by Borland International // Tutorial application -- cntrl16.cpp //---------------------------------------------------------------------------- #include #include #include #include #include #include #include #include #include #include #include "step16.cxx" class TMyApp : public TApplication { public: TMyApp(): TApplication("Cntrl16") {} void InitMainWindow(); void InitInstance(); void Output(ostrstream &ostr); bool DispServer; //True if automation server should be displayed when run private: void TestAutomation(); //Routine to execute step16 TEdit *Disp; //Client window }; void TMyApp::InitMainWindow() { Disp=new TEdit(0,0,"",0,0,0,0,0,true); SetMainWindow(new TFrameWindow(0,"Step 16 Controller",Disp)); } // // Outputs ostrstream buf to client window // void TMyApp::Output(ostrstream &ostr) { char *str = ostr.str(); //Get stream buffer as char* ostr.seekp(0); //Reset stream Disp->Insert(str); Disp->Insert("\r\n"); } void TMyApp::InitInstance() { TApplication::InitInstance(); // Our windows are now created and we can output the test results TestAutomation(); } long Colors[] = { RGB(0x00, 0x00, 0x00), RGB(0xFF, 0x00, 0x00), RGB(0x00, 0xFF, 0x00), RGB(0x00, 0x00, 0xFF), RGB(0xFF, 0xFF, 0x00), RGB(0x00, 0xFF, 0xFF), RGB(0xFF, 0x00, 0xFF) }; const int NumColors = sizeof(Colors)/sizeof(Colors[0]); // // Excercises the server using the classes generated by AUTOGEN.EXE // void TMyApp::TestAutomation() { char buf[256]; ostrstream ostr(buf, sizeof buf); try { TOleAllocator allocator(0); // OLE requirement TDrawApp app; TDrawDoc doc; app.Bind("DrawPad.Application.16"); ostr << "Application name =" << (const char far*)app.GetName() << ends; Output(ostr); ostr << "Application path =" << (const char far*)app.GetFullName() << ends; Output(ostr); app.NewDocument(doc); // if there's one argument on command line, don't display the frame window. if (DispServer) { app.SetVisible(true); } else { app.SetVisible(false); } ostr << "Current automated pen size: " << doc.GetPenSize() << ends; Output(ostr); ostr << "Current automated pen color: " << doc.GetPenColor() << ends; Output(ostr); double startX = 150; double startY = 150; double radius = 0; double theta = 0; int colorIndex = 0; short penSize = 1; //Server expects a short arg in SetPenSize double x = 0; double y = 0; ostr << "Drawing in automated app ..."<