![]() |
To start an Win32 LGI application you have to implement a WinMain function. Here is an example WinMain function:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { OleInitialize(NULL); CoInitialize(NULL); InitCommonControls(); MemoryDevice Memory; FileDevice File; GdcDevice Gdc; MyApp App(hInstance, lpCmdLine, nCmdShow); App.AppWnd = NEW(MyAppWnd); App.OnCmdLine(lpCmdLine); App.Run(); CoUninitialize(); OleUninitialize(); return 0; }Where the class "MyApp" is derived from GApp and the class "MyAppWnd" is derived from GAppWindow. The call to App.Run() executes a message loop until LgiCloseApp() or LgiExitApp() is called. LgiCloseApp() is a graceful shutdown, LgiExitApp() shuts down hard, ignoring user intervention. This is good for getting out when a severe error has occured. If you want to implement a game or an OnIdle function this is what the window allocation and app loop look like: MyAppWnd *Wnd; App.AppWnd = Wnd = NEW(MyAppWnd); App.OnCmdLine(lpCmdLine); while (App.Run(false)) { Wnd->OnFrame(); // or OnIdle } |
![]() |
To start a BeOS LGI application you have to implement a main(...) function, here is an example main function:
int main(int Args, char **Arg) { char Parm[256] = ""; for (int i=1; i<Args; i++) { if (strlen(Parm)>0) strcat(Parm, " "); strcat(Parm, Arg[i]); } MyApp *App = NEW(MyApp("application/MyApp", 0)); if (App) { MemoryDevice Memory; FileDevice File; GdcDevice Gdc; App.AppWnd = NEW(MyAppWnd); App->OnCmdLine(Parm); App->Run(); DeleteObj(App); } return 0; }Where the class "MyApp" is derived from GApp and the class "MyAppWnd" is derived from GAppWindow. |