示例#1
0
bool MyApp::OnInit()
{
    // Create the main window
    MyFrame *frame = new MyFrame( wxT("Notebook sample") );

    // Problem with generic wxNotebook implementation whereby it doesn't size
    // properly unless you set the size again
#if defined(__WXMOTIF__)
    int width, height;
    frame->GetSize(& width, & height);
    frame->SetSize(wxDefaultCoord, wxDefaultCoord, width, height);
#endif

    frame->Show();

    return true;
}
示例#2
0
bool MyApp::OnInit()
{
	gAppHandler = this;

	wxString sFullModleName = ::wxGetFullModuleName();
	wxString sAppName = this->GetAppName();
	size_t nFind = sFullModleName.rfind(sAppName);
	gAppPath = sFullModleName.substr(0, nFind-1).c_str();

	setAutorun(BIWOO_NAME.c_str(), sFullModleName.c_str());

	wxString xmlFile(gAppPath);
	xmlFile.Append(wxT("/default/setting.xml"));
	gSetting.load(xmlFile.c_str());

	setlocale(LC_ALL, gSetting.locale().c_str());
	//setlocale(LC_ALL,"Chinese-simplified");
	//std::locale::global(std::locale("Chinese-simplified"));
	
	CCgcAddress serverAddress(gSetting.address(), CCgcAddress::ST_UDP);
	if (!m_biwoo.start(serverAddress, (CbiwooHandler*)this))
	{
		//m_biwoo.stop();
		//return false;
	}

	xmlFile = gAppPath.c_str();
	xmlFile.Append(wxT("/default/"));
	xmlFile.Append(gSetting.langtext());
	gLangText.load(xmlFile.c_str());

	/////////////////////////////////////
	// test
	//CDlgSetting dlgSetting(NULL);
	//dlgSetting.ShowModal();

    if ( !wxApp::OnInit() )
	{
		m_biwoo.stop();
        return false;
	}

	CDlglogin dlgLogin(NULL, false);
	int ret = dlgLogin.ShowModal();
	if (ret != wxID_OK)
	{
		m_biwoo.stop();
		wxApp::OnExit();
		return false;
	}
	gMyAccount = dlgLogin.accountInfo();
	BOOST_ASSERT (gMyAccount.get() != 0);

    // create the main application window
    MyFrame * frame = new MyFrame(_T("BIWOO App"), wxSize(700, 450));
	m_biwoo.setHandler(gAppHandler);
	m_biwoo.accountLoad();

	wxString title = wxString::Format("%s - %s(%s)", BIWOO_NAME.c_str(), gMyAccount->getUserinfo()->getUserName().c_str(), gMyAccount->getUserinfo()->getAccount().c_str());
	frame->SetTitle(title);
	frame->setTaskBarIcon(wxT("mainframe.ico"), title);

#if defined(__WXMOTIF__)
    int width, height;
    frame->GetSize(& width, & height);
    frame->SetSize(wxDefaultCoord, wxDefaultCoord, width, height);
#endif

    // and show it (the frames, unlike simple controls, are not shown when
    // created initially)
	frame->SetMinSize(wxSize(700, 450));
    frame->Show(true);

    //SetTopWindow(frame);

    // success: wxApp::OnRun() will be called which will enter the main message
    // loop and the application will run. If we returned false here, the
    // application would exit immediately.
    return true;
}