int NaClChromeMainStart(struct NaClApp *nap, struct NaClChromeMainArgs *args, int *exit_status) { int load_ok = LOAD_OK == LoadApp(nap, args); if (load_ok) { *exit_status = StartApp(nap, args); } free(args); return load_ok; }
// -------------------------------------------------------------------------- // Create all files necessary for application // MYAPP.CPP FApp // RESOURCE.RC RESOURCE.H FRes // MAINDLG.CPP MAINDLG.H FMain // MAINWIN.H MAINWIN.CPP FMain // ABOUT.H ABOUT.CPP FAbout // -------------------------------------------------------------------------- int CreateApplication(TWindow *Win, int Flags,char *FApp,char *FMain,char *FAbout,char *FRes) { strlwr(FApp); strlwr(FMain); strlwr(FAbout); strlwr(FRes); ////////////////// ForceExt(FApp,".cpp"); // char FMainH[80+1]; char FMainCPP[80+1]; strcpy(FMainH,FMain); strcpy(FMainCPP,FMain); ForceExt(FMainCPP,".cpp"); ForceExt(FMainH,".h"); // char FAboutH[80+1]; char FAboutCPP[80+1]; strcpy(FAboutH,FAbout); strcpy(FAboutCPP,FAbout); ForceExt(FAboutH,".h"); ForceExt(FAboutCPP,".cpp"); // char FResH[80+1]; char FResRC[80+1]; strcpy(FResH,FRes); strcpy(FResRC,FRes); ForceExt(FResH,".h"); ForceExt(FResRC,".rc"); // /// int decorated = (Flags & ( NEWAPPFLAG_CONTROLBAR | NEWAPPFLAG_STATUSBAR ) ); int retCode = 0; // // FILE *fMyApp = fopen(FApp,"wt"); if(!fMyApp) { return 1; } fprintf(fMyApp,"#include <%s\\owlpch.h>\n",UserSetup.OwlPath); fprintf(fMyApp,"#include <%s\\applicat.h>\n",UserSetup.OwlPath); if(decorated) { if(Flags & NEWAPPFLAG_STATUSBAR) { fprintf(fMyApp,"#include <%s\\statusba.h>\n",UserSetup.OwlPath); } if(Flags & NEWAPPFLAG_CONTROLBAR) { fprintf(fMyApp,"#include <%s\\controlb.h>\n",UserSetup.OwlPath); fprintf(fMyApp,"#include <%s\\buttonga.h>\n",UserSetup.OwlPath); } fprintf(fMyApp,"#include <%s\\decframe.h>\n",UserSetup.OwlPath); } else // non decorated { fprintf(fMyApp,"#include <%s\\framewin.h>\n",UserSetup.OwlPath); } fprintf(fMyApp,"#include \"%s\"\n",FResH); fprintf(fMyApp,"#include <%s\\dialog.h>\n",UserSetup.OwlPath); // fprintf(fMyApp,"#include \"%s\"\n",FMainH); fprintf(fMyApp,"#include \"%s\"\n",FAboutH); fprintf(fMyApp,"//\n"); fprintf(fMyApp,"//\n"); fprintf(fMyApp,"// My Application Class\n"); fprintf(fMyApp,"//\n"); fprintf(fMyApp,"class TMyApp : public TApplication\n"); fprintf(fMyApp,"{\n"); fprintf(fMyApp,"public:\n"); fprintf(fMyApp,"%sTMyApp(void);\n",UserSetup.Tabs); fprintf(fMyApp,"protected:\n"); fprintf(fMyApp,"%svoid InitMainWindow(void);\n",UserSetup.Tabs); fprintf(fMyApp,"};\n\n\n"); /// fprintf(fMyApp,"// My Application Constructor\n"); fprintf(fMyApp,"TMyApp::TMyApp(void) : TApplication()\n"); fprintf(fMyApp,"{\n"); fprintf(fMyApp,"}\n\n"); // fprintf(fMyApp,"void TMyApp::InitMainWindow(void)\n"); fprintf(fMyApp,"{\n"); if(decorated) { // USE DECORATED FRAME if(Flags & NEWAPPFLAG_DIALOG) fprintf(fMyApp,"%sTDecoratedFrame *Frame = new TDecoratedFrame(0, \"My Decorated Frame Application\", new MainDlg((TWindow*)0));\n",UserSetup.Tabs); if(Flags & NEWAPPFLAG_SDI) fprintf(fMyApp,"%sTDecoratedFrame *Frame = new TDecoratedFrame(0, \"My Decorated Frame Application\", new MainWin((TWindow*)0));\n",UserSetup.Tabs); if(Flags & NEWAPPFLAG_CONTROLBAR) { fprintf(fMyApp,"%sTControlBar *Cbar = new TControlBar(Frame);\n",UserSetup.Tabs); fprintf(fMyApp,"%sCbar->Insert(*new TButtonGadget(BM_ABOUT,CM_ABOUT,TButtonGadget::Command) );\n",UserSetup.Tabs); fprintf(fMyApp,"%sFrame->Insert(*Cbar, TDecoratedFrame::Top);\n",UserSetup.Tabs); } if(Flags & NEWAPPFLAG_STATUSBAR) { fprintf(fMyApp,"%sTStatusBar *Sbar = new TStatusBar(Frame,TGadget::Embossed);\n",UserSetup.Tabs); fprintf(fMyApp,"%sFrame->Insert(*Sbar, TDecoratedFrame::Bottom);\n",UserSetup.Tabs); } fprintf(fMyApp,"%sSetMainWindow( Frame );\n",UserSetup.Tabs); } else // No Decorated Frame { if(Flags & NEWAPPFLAG_DIALOG) fprintf(fMyApp,"%sSetMainWindow( new TFrameWindow(0, \"My Dialog Application\", new MainDlg((TWindow*)0) ));\n",UserSetup.Tabs); else if(Flags & NEWAPPFLAG_SDI) fprintf(fMyApp,"%sSetMainWindow( new TFrameWindow(0, \"My Window Application\", new MainWin(0) ));\n",UserSetup.Tabs); // fprintf(fMyApp,"%sMainWindow->SetIcon(this,ID_MAINICON);\n",UserSetup.Tabs); // } if(Flags & NEWAPPFLAG_DIALOG) { fprintf(fMyApp,"%sMainWindow->Attr.Style &= ~WS_MAXIMIZEBOX;\n",UserSetup.Tabs); } if(Flags & NEWAPPFLAG_MENU) { fprintf(fMyApp,"%sGetMainWindow()->AssignMenu(ID_MAINMENU);\n",UserSetup.Tabs); } fprintf(fMyApp,"}\n\n"); fprintf(fMyApp,"int OwlMain(int argc, char *argv[])\n"); fprintf(fMyApp,"{\n"); fprintf(fMyApp,"%sreturn TMyApp().Run();\n",UserSetup.Tabs); fprintf(fMyApp,"}\n"); fclose(fMyApp); // ----------------------------------- FILE *fR = fopen(FResH,"wt"); if(!fR) { return 2; } fprintf(fR,"// Resouce ID Constants\n"); fprintf(fR,"#define%sID_MAINICON%s1\n",UserSetup.Tabs,UserSetup.Tabs); fprintf(fR,"#define%sCM_ABOUT%s997\n",UserSetup.Tabs,UserSetup.Tabs); fprintf(fR,"#define%sID_ABOUTDIALOG%s1002\n",UserSetup.Tabs,UserSetup.Tabs); if(Flags & NEWAPPFLAG_DIALOG) { fprintf(fR,"#define%sID_MAINDIALOG%s1001\n",UserSetup.Tabs,UserSetup.Tabs); } if(Flags & NEWAPPFLAG_MENU) { fprintf(fR,"#define%sID_MAINMENU%s101\n",UserSetup.Tabs,UserSetup.Tabs); } if(Flags & (NEWAPPFLAG_MENU | NEWAPPFLAG_DIALOG) ) { fprintf(fR,"#define%sCM_HELP%s301\n",UserSetup.Tabs,UserSetup.Tabs); fprintf(fR,"#define%sCM_HELPINDEX%s302\n",UserSetup.Tabs,UserSetup.Tabs); } if(Flags & NEWAPPFLAG_CONTROLBAR) { fprintf(fR,"#define%sBM_ABOUT%s398\n",UserSetup.Tabs,UserSetup.Tabs); } fclose(fR); ///----------------------------------- fR = fopen(FResRC,"wt"); if(!fR) { return 2; } fprintf(fR,"#include \"%s\"\n",FResH); fprintf(fR,"#include <%s\\edit.rh>\n",UserSetup.OwlPath); fprintf(fR,"#include <%s\\docview.rh>\n",UserSetup.OwlPath); fprintf(fR,"#include <%s\\mdi.rh>\n",UserSetup.OwlPath); fprintf(fR,"\n"); if(Flags & NEWAPPFLAG_DIALOG) { fprintf(fR,"DLGTEMPLATE ID_MAINDIALOG\n"); fprintf(fR,"BEGIN\n"); fprintf(fR," DIALOG \"\", ID_MAINDIALOG, 0, 0, 172, 113, FS_NOMOVEWITHOWNER | NOT FS_DLGBORDER | NOT WS_SAVEBITS | WS_VISIBLE | WS_CLIPSIBLINGS, FCF_NOBYTEALIGN\n"); fprintf(fR," BEGIN\n"); fprintf(fR," DEFPUSHBUTTON \"Close\", DID_OK, 6, 4, 51, 14\n"); fprintf(fR," PUSHBUTTON \"~About\", CM_ABOUT, 60, 4, 51, 14\n"); fprintf(fR," PUSHBUTTON \"~Help\", CM_HELP, 114, 4, 51, 14, BS_HELP\n"); fprintf(fR," END\n"); fprintf(fR,"END\n\n"); } fprintf(fR,"DLGTEMPLATE ID_ABOUTDIALOG\n"); fprintf(fR,"BEGIN\n"); fprintf(fR," DIALOG \"About This Application\", ID_ABOUTDIALOG, 50, 79, 163, 67, WS_VISIBLE, FCF_SYSMENU | FCF_TITLEBAR\n"); fprintf(fR," BEGIN\n"); fprintf(fR," DEFPUSHBUTTON \"OK\", DID_OK, 104, 4, 51, 14\n"); fprintf(fR," CONTROL \"Use Resource Workshop To\\n"); fprintf(fR,"Put Your Product Name\\n"); fprintf(fR,"And Version Number Here\", 101, 8, 28, 144, 32, WC_STATIC, SS_TEXT | DT_CENTER | DT_TOP | DT_WORDBREAK | DT_MNEMONIC | WS_VISIBLE\n"); fprintf(fR," END\n"); fprintf(fR,"END\n\n"); if(Flags & NEWAPPFLAG_MENU) { fprintf(fR,"MENU ID_MAINMENU\n"); fprintf(fR,"BEGIN\n"); fprintf(fR," SUBMENU \"~File\", 100\n"); fprintf(fR," BEGIN\n"); fprintf(fR," MENUITEM \"~New...\", CM_FILENEW\n"); fprintf(fR," MENUITEM \"~Open...\", CM_FILEOPEN\n"); fprintf(fR," MENUITEM SEPARATOR\n"); fprintf(fR," MENUITEM \"~Save...\", CM_FILESAVE\n"); fprintf(fR," MENUITEM \"Save ~As...\", CM_FILESAVEAS\n"); fprintf(fR," MENUITEM SEPARATOR\n"); fprintf(fR," MENUITEM \"~Exit...\", CM_EXIT\n"); fprintf(fR," END\n"); fprintf(fR,"\n"); fprintf(fR," SUBMENU \"~Edit\", 200\n"); fprintf(fR," BEGIN\n"); fprintf(fR," MENUITEM \"Cu~t\\tShift+Del\", CM_EDITCUT\n"); fprintf(fR," MENUITEM \"~Copy\\tCtrl+Ins\", CM_EDITCOPY\n"); fprintf(fR," MENUITEM \"~Paste\\tShift+Ins\", CM_EDITPASTE\n"); fprintf(fR," MENUITEM \"C~lear\\tDel\", CM_EDITDELETE\n"); fprintf(fR," END\n"); fprintf(fR,"\n"); fprintf(fR," SUBMENU \"~Help\", 300\n"); fprintf(fR," BEGIN\n"); fprintf(fR," MENUITEM \"~General help...\", CM_HELP\n"); fprintf(fR," MENUITEM \"Help ~index...\", CM_HELPINDEX\n"); fprintf(fR," MENUITEM SEPARATOR\n"); fprintf(fR," MENUITEM \"~About...\", CM_ABOUT\n"); fprintf(fR," END\n"); fprintf(fR,"END\n"); fprintf(fR,"\n"); } fprintf(fR,"\n"); fprintf(fR,"POINTER ID_MAINICON\n"); fprintf(fR,"BEGIN\n"); extern unsigned char MyIconData[]; WriteHexBlock(fR,64*16+2,MyIconData); fprintf(fR,"END\n\n"); // // CM_ABOUT ICON // if(Flags & NEWAPPFLAG_CONTROLBAR) { fprintf(fR,"\n"); fprintf(fR,"BITMAP BM_ABOUT\n"); fprintf(fR,"BEGIN\n"); extern unsigned char CmAboutData[]; WriteHexBlock(fR,(42*16)-4,CmAboutData); fprintf(fR,"END\n\n"); } fclose(fR); if(Flags & NEWAPPFLAG_DIALOG) { FILE *fc = fopen(FMainCPP,"wt"); if(!fc) return 3; fprintf(fc,"#define INCL_WINMESSAGEMGR\n"); fprintf(fc,"#include <os2.h>\n"); fprintf(fc,"#include <%s\\dialog.h>\n",UserSetup.OwlPath); fprintf(fc,"#include \"%s\"\n",FAboutH); fclose(fc); retCode = CreateClassTDialog(FMainH, FMainCPP, "MainDlg", "ID_MAINDIALOG",FResH); char cd1[256+1]; // When Dialog is destroyed - take parent with it ! Cproto X; sprintf(cd1,"%sWinPostMsg(GetParent(), WM_CLOSE, 0, 0);",UserSetup.Tabs); X.WriteCode(FMainCPP,"MainDlg","EvClickOk",cd1,FALSE); // X.WriteCode(FMainCPP,"MainDlg","EvClickCancel",cd1,FALSE); X.AddEvent(FMainCPP,"MainDlg","EV_BN_CLICKED","CM_ABOUT","EvClickAbout"); sprintf(cd1,"%sAboutDlg MyAbout(this);\n%sMyAbout.Execute();\n",UserSetup.Tabs,UserSetup.Tabs); X.AddFunction(FMainH,FMainCPP, "MainDlg", "protected", "","void","EvClickAbout","void","Clicked On About Button/Menu",cd1); } if(Flags & NEWAPPFLAG_SDI) { retCode = CreateClassTWindow(FMainH, FMainCPP, "MainWin",FResH); Cproto X; X.AddEvent(FMainCPP,"MainWin","EV_COMMAND","CM_ABOUT","EvClickAbout"); char cd1[256+1]; sprintf(cd1,"%sAboutDlg MyAbout(this);\n%sMyAbout.Execute();\n",UserSetup.Tabs,UserSetup.Tabs); X.AddFunction(FMainH,FMainCPP, "MainWin", "protected", "","void","EvClickAbout","void","Clicked On About Button/Menu",cd1); X.AppendIncludeFile(FMainCPP,FAboutH); GetHeaderForClass(cd1,"TDialog"); X.AppendIncludeFile(FMainCPP,cd1); } retCode = CreateClassTDialog(FAboutH,FAboutCPP,"AboutDlg","ID_ABOUTDIALOG",FResH); char *ListOfFiles[4] = { FApp, FAboutCPP, FMainCPP, NULL }; char makename[MAXPATHSIZE+1]; strcpy(makename,FApp); ForceExt(makename,""); CreateMakeFile(makename,FResRC,ListOfFiles,".","/wdpl /Toe /aa"); /// char msg[128+1]; sprintf(msg," ( make -f%s.mak )\n\n" "Would You Like To Start\n" "The Compiler and Linker\n" "To Build %s.EXE Now ?",makename,makename); if( Win->MessageBox(msg,"BUILD APPLICATION",MB_YESNOno) == IDYES) { sprintf(msg,"-f%s.MAK",makename); StartApp(0, "Professor Owl Make",".\\","MAKE.EXE",msg); } return(retCode); }
BOOL CCustinfoDriverApp::InitInstance() { InitArborLocale(); // Parse and validate command line ParseCommandLine(m_CmdInfo); if (ValidateCommandLine()) { BOOL continue_processing = TRUE; // Process command line instructions if (m_CmdInfo.m_sApplication.IsEmpty() && m_CmdInfo.m_sDialog.IsEmpty() && m_CmdInfo.m_sAccountid.IsEmpty() && !m_CmdInfo.m_bExit) { ErrorMessage(__FILE__, __LINE__, "Unknown command."); continue_processing = FALSE; } // Exit the Application if (m_CmdInfo.m_bExit) { int count = 0; while (count++ < 100 && ci_ipc::FindCustInfo()) { continue_processing = SendCommand(CArborCommandLineInfo::exit); Sleep(500); } if (count >= 100) { continue_processing = FALSE; } } // Start Application if (continue_processing && !m_CmdInfo.m_sApplication.IsEmpty()) { if (m_CmdInfo.m_sApplication == m_sAppNames[custinfo]) { if (!ci_ipc::FindCustInfo()) { // Only attempt to start the app if its not already running. continue_processing = StartApp(); // Wait for us to Find the application before continuing. if (continue_processing) { int count = 0; while (count++ < 100 && !ci_ipc::FindCustInfo()) { Sleep(500); } if (count >= 100) { continue_processing = FALSE; } else { Sleep(1000); } } } } else { continue_processing = StartApp(); } } // Open Account if (continue_processing && !m_CmdInfo.m_sAccountid.IsEmpty()) { continue_processing = OpenAccount(); } // Switch to a Specific Dialog if (continue_processing && !m_CmdInfo.m_sDialog.IsEmpty()) { continue_processing = SendCommand(CArborCommandLineInfo::dialog); } } DeleteArborLocale(); return TRUE; }