Exemple #1
0
// initialization which is always done (not customizable) before wxApp creation
static bool DoCommonPreInit()
{
#if wxUSE_LOG
    // Reset logging in case we were cleaned up and are being reinitialized.
    wxLog::DoCreateOnDemand();

    // force wxLog to create a log target now: we do it because wxTheApp
    // doesn't exist yet so wxLog will create a special log target which is
    // safe to use even when the GUI is not available while without this call
    // we could create wxApp in wxEntryStart() below, then log an error about
    // e.g. failure to establish connection to the X server and wxLog would
    // send it to wxLogGui (because wxTheApp does exist already) which, of
    // course, can't be used in this case
    //
    // notice also that this does nothing if the user had set up a custom log
    // target before -- which is fine as we want to give him this possibility
    // (as it's impossible to override logging by overriding wxAppTraits::
    // CreateLogTarget() before wxApp is created) and we just assume he knows
    // what he is doing
    wxLog::GetActiveTarget();
#endif // wxUSE_LOG

#ifdef __WINDOWS__
    // GUI applications obtain HINSTANCE in their WinMain() but we also need to
    // initialize the global wxhInstance variable for the console programs as
    // they may need it too, so set it here if it wasn't done yet
    if ( !wxGetInstance() )
    {
        wxSetInstance(::GetModuleHandle(NULL));
    }
#endif // __WINDOWS__

    return true;
}
Exemple #2
0
BOOL CTheApp::InitInstance()
{
    if ( !CWinApp::InitInstance() )
        return FALSE;

    // TODO: cmd line parsing
    WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst);
    wxSetInstance(m_hInstance);
    wxApp::m_nCmdShow = m_nCmdShow;
    int argc = 0;
    wxChar **argv = NULL;
    wxEntryStart(argc, argv);
    if ( !wxTheApp || !wxTheApp->CallOnInit() )
        return FALSE;

#if START_WITH_MFC_WINDOW
    // Demonstrate creation of an initial MFC main window.
    m_pMainWnd = new CMainWindow();
    m_pMainWnd->ShowWindow( m_nCmdShow );
    m_pMainWnd->UpdateWindow();
#else
    // Demonstrate creation of an initial wxWidgets main window.
    // Wrap wxWidgets window in a dummy MFC window and
    // make the main window.
    if (wxTheApp && wxTheApp->GetTopWindow())
    {
        m_pMainWnd = new CDummyWindow((HWND) wxTheApp->GetTopWindow()->GetHWND());
    }
#endif

    return TRUE;
}
Exemple #3
0
BOOL WINAPI DllMain(
    HINSTANCE   hinstDLL,    // handle to DLL module
    DWORD       fdwReason,   // reason for calling function
    LPVOID      lpvReserved  // reserved
   )
{
    // If wxPython is embedded in another wxWidgets app then
    // the instance has already been set.
    if (! wxGetInstance())
        wxSetInstance(hinstDLL);

    return TRUE;
}
	bool initWxWidgets(HINSTANCE hInst, int CmdShow, int argc, char** argv)
	{
		hIISHook = SetWindowsHookEx(WH_CALLWNDPROC, (HOOKPROC)CallWndProc, 0, GetCurrentThreadId());

		wxSetInstance(hInst);
		wxApp::m_nCmdShow = CmdShow;
		wxEntry(argc, argv);

		if (!wxTheApp || !wxTheApp->CallOnInit())
			return false;

		return true;
	}
Exemple #5
0
// initialization which is always done (not customizable) before wxApp creation
static bool DoCommonPreInit()
{
#if wxUSE_UNICODE && defined(__WXOSX__)
    // In OS X and iOS, wchar_t CRT functions convert to char* and fail under
    // some locales. The safest fix is to set LC_CTYPE to UTF-8 to ensure that
    // they can handle any input.
    //
    // Note that this must be done for any app, Cocoa or console, whether or
    // not it uses wxLocale.
    //
    // See http://stackoverflow.com/questions/11713745/why-does-the-printf-family-of-functions-care-about-locale
    setlocale(LC_CTYPE, "UTF-8");
#endif // wxUSE_UNICODE && defined(__WXOSX__)

#if wxUSE_LOG
    // Reset logging in case we were cleaned up and are being reinitialized.
    wxLog::DoCreateOnDemand();

    // force wxLog to create a log target now: we do it because wxTheApp
    // doesn't exist yet so wxLog will create a special log target which is
    // safe to use even when the GUI is not available while without this call
    // we could create wxApp in wxEntryStart() below, then log an error about
    // e.g. failure to establish connection to the X server and wxLog would
    // send it to wxLogGui (because wxTheApp does exist already) which, of
    // course, can't be used in this case
    //
    // notice also that this does nothing if the user had set up a custom log
    // target before -- which is fine as we want to give him this possibility
    // (as it's impossible to override logging by overriding wxAppTraits::
    // CreateLogTarget() before wxApp is created) and we just assume he knows
    // what he is doing
    wxLog::GetActiveTarget();
#endif // wxUSE_LOG

#ifdef __WINDOWS__
    // GUI applications obtain HINSTANCE in their WinMain() but we also need to
    // initialize the global wxhInstance variable for the console programs as
    // they may need it too, so set it here if it wasn't done yet
    if ( !wxGetInstance() )
    {
        wxSetInstance(::GetModuleHandle(NULL));
    }
#endif // __WINDOWS__

    return true;
}
Exemple #6
0
void *wxe_main_loop(void *vpdl)
{
    int result;
    int  argc = 1;
    char * temp = (char *) "Erlang";
    char * argv[] = {temp,NULL};
    ErlDrvPDL pdl = (ErlDrvPDL) vpdl;

    driver_pdl_inc_refc(pdl);

    // Disable floating point execption if they are on.
    // This should be done in emulator but it's not in yet.
#ifndef _WIN32
    erts_thread_disable_fpe();
#else
    // Setup that wxWidgets should look for cursors and icons in
    // this dll and not in werl.exe (which is the default)
    HMODULE WXEHandle = GetModuleHandle(_T("wxe_driver"));
    wxSetInstance((HINSTANCE) WXEHandle);
#endif

    wxe_ps_init();
    result = wxEntry(argc, argv);
    // fprintf(stderr, "WXWidgets quits main loop %d \r\n", result);
    if(result >= 0 && wxe_status == WXE_INITIATED) {
        /* We are done try to make a clean exit */
        wxe_status = WXE_EXITED;
        driver_pdl_dec_refc(pdl);
#ifndef __DARWIN__
        erl_drv_thread_exit(NULL);
#endif
        return NULL;
    } else {
        erl_drv_mutex_lock(wxe_status_m);
        wxe_status = WXE_ERROR;
        erl_drv_cond_signal(wxe_status_c);
        erl_drv_mutex_unlock(wxe_status_m);
        driver_pdl_dec_refc(pdl);
        return NULL;
    }
}
Exemple #7
0
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID)
{
    int argc = 0;
    char **argv = NULL;
    switch (ul_reason_for_call)
    {
        case DLL_PROCESS_ATTACH:
            wxSetInstance((HINSTANCE)hModule);
            wxEntryStart(argc, argv);
            break;
        case DLL_THREAD_ATTACH:
            break;
        case DLL_THREAD_DETACH:
            break;
        case DLL_PROCESS_DETACH:
            if (wxTheApp)
                wxTheApp->OnExit();
            wxEntryCleanup();
            break;
    }
    return TRUE;
}