wxWidgets / wxWidgets

Cross-Platform C++ GUI Library
https://www.wxwidgets.org/
5.81k stars 1.71k forks source link

WINCE and wxLaunchDefaultBrowserBaseImpl error #10190

Closed wxtrac closed 14 years ago

wxtrac commented 15 years ago

Issue migrated from trac ticket # 10190

component: wxMSW-CE | priority: normal | resolution: fixed

2008-11-15 16:15:07: micspi (Michele Spighi) created the issue


Trying to use wxHyperLinkCtrl I found an error in the function wxLaunchDefaultBrowserBaseImpl.

The following code seems not suitable for windows mobile:

[...] WinStruct sei; sei.lpFile = url.c_str(); sei.lpVerb = _T("open"); sei.nShow = SW_SHOWNORMAL;

::ShellExecuteEx(&sei);

const int nResult = (int) sei.hInstApp;

// Firefox returns file not found for some reason, so make an

exception // for it if ( nResult > 32 || nResult == SE_ERR_FNF ) {

ifdef WXDEBUG

    // Log something if SE_ERR_FNF happens
    if ( nResult == SE_ERR_FNF )
        wxLogDebug(wxT("SE_ERR_FNF from ShellExecute -- maybe

FireFox?"));

endif // WXDEBUG

    return true;
}

[...]

In fact nResult value is 0 but the browser is executed, the page loaded and all work fine. But the message wxLogSysError(_T("Failed to open URL \"%s\" in default browser."), url.c_str()); is fired.

Looking at the msdn documentation for windows mobile regarding SHELLEXECUTEINFO it says:

[...] hInstApp

This member is only valid if the function fails, in which case it

receives one of the following error values, which are less than or equal to 32. [...]

So it is not reliable use hInstApp as check for successful execution for windows mobile platform. Maybe we can use the value returned from ::ShellExecuteEx(&sei) and GetLasError() to avoid the problem.

I hope it helps.

Thanks! Michele

wxtrac commented 15 years ago

2008-11-18 10:58:05: micspi (Michele Spighi) uploaded file utilscmn.cpp.patch (1.1 KiB)

This patch works fine for me. No more error on wince

wxtrac commented 15 years ago

2008-11-20 19:32:18: @vadz changed priority from high to normal

2008-11-20 19:32:18: @vadz changed status from new to portneeded

2008-11-20 19:32:18: @vadz changed resolution from * to port to stable*

2008-11-20 19:32:18: @vadz commented

IMO this code is wrong for desktop Windows versions too, it seems to be a leftover from the Win16-compatibility days when we used ShellExecute() and not ShellExecuteEx(). I've changed this code to simply test the return value of the function in all ports in 56869 and it seems to work just fine for me.

This probably should be backported to 2.8 later if no problems are found with it.

wxtrac commented 15 years ago

2008-11-20 21:12:32: micspi (Michele Spighi) commented


Replying to [comment:2 vadz]:

IMO this code is wrong for desktop Windows versions too, it seems to be a leftover from the Win16-compatibility days when we used ShellExecute() and not ShellExecuteEx(). I've changed this code to simply test the return value of the function in all ports in 56869 and it seems to work just fine for me.

This probably should be backported to 2.8 later if no problems are found with it.

I think the same! It is really important for wxWinCE 2.8 otherwise

wxLaunchDefaultBrowser

cannot be used as it always produce a warning message even in case of success.

Thanks! Michele

wxtrac commented 15 years ago

2008-11-20 22:12:10: micspi (Michele Spighi) commented


Replying to [comment:2 vadz]:

IMO this code is wrong for desktop Windows versions too, it seems to be a leftover from the Win16-compatibility days when we used ShellExecute() and not ShellExecuteEx(). I've changed this code to simply test the return value of the function in all ports in 56869 and it seems to work just fine for me.

This probably should be backported to 2.8 later if no problems are found with it.

Please, if you can, in the same file in the function:


 bool wxLaunchDefaultApplication(const wxString& document, int flags) 

ShellExecute is used. It doesn't exist in WinCE could you make the same change you made here? See my ticket #10201

TIA! Michele

wxtrac commented 14 years ago

2009-09-26 22:05:20: @JulianSmart changed status from portneeded to closed

2009-09-26 22:05:20: @JulianSmart changed resolution from port to stable to fixed

2009-09-26 22:05:20: @JulianSmart commented

Thanks, applied to 2.8 (62161).