Mercurial > dwindows
changeset 2022:28809bf17957
Win: Switch to using _wcsicmp() from CompareStringOrdinal() for increased compatibility.
Remove debug messages from the new IE code. Add _free_window_memory() to cleanup browsers.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sat, 09 Nov 2019 07:18:21 +0000 |
parents | 0cce5fed4594 |
children | 3f265cd5b069 |
files | win/browser.c win/dw.c win/edge.cpp |
diffstat | 3 files changed, 8 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/win/browser.c Sat Nov 09 06:33:08 2019 +0000 +++ b/win/browser.c Sat Nov 09 07:18:21 2019 +0000 @@ -37,6 +37,7 @@ #define UTF8toWide(a) _myUTF8toWide(a, a ? _alloca(MultiByteToWideChar(CP_UTF8, 0, a, -1, NULL, 0) * sizeof(WCHAR)) : NULL) #define WideToUTF8(a) _myWideToUTF8(a, a ? _alloca(WideCharToMultiByte(CP_UTF8, 0, a, -1, NULL, 0, NULL, NULL)) : NULL) LRESULT CALLBACK _wndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2); +BOOL CALLBACK _free_window_memory(HWND handle, LPARAM lParam); // This is used by DisplayHTMLStr(). It can be global because we never change it. static const SAFEARRAYBOUND ArrayBound = {1, 0}; @@ -1841,9 +1842,7 @@ // Get IWebBrowser2' IConnectionPointContainer sub-object. We do this by calling // IWebBrowser2' QueryInterface, and pass it the standard GUID for an // IConnectionPointContainer VTable - if ((hr = webBrowser2->lpVtbl->QueryInterface(webBrowser2, &IID_IConnectionPointContainer, &container))) - dw_debug("QueryInterface error: Can't get IConnectionPointContainer object"); - else + if (!(hr = webBrowser2->lpVtbl->QueryInterface(webBrowser2, &IID_IConnectionPointContainer, &container))) { // Get IWebBrowser2' IConnectionPoint sub-object for specifically giving // IWebBRowser2 our DWEventHandler. We do this by calling IConnectionPointContainer's @@ -1854,9 +1853,7 @@ // we want (ie, the one we use to give IWebBrowser2 our DWEventHandler) container->lpVtbl->Release(container); - if (hr) - dw_debug("FindConnectionPoint error: Can't get IConnectionPoint object"); - else + if (!hr) { DWORD cookie; @@ -1871,9 +1868,7 @@ // // Advise() gives us back a "cookie" value that we'll need to later pass to // Unadvise() (when we want to tell IWebBrowser2 to stop using our DWEventHandler) - if ((hr = point->lpVtbl->Advise(point, (IUnknown *)&MyDWEventHandler, &cookie))) - dw_debug("Advise error: Can't set our DWEventHandler object"); - else + if (!(hr = point->lpVtbl->Advise(point, (IUnknown *)&MyDWEventHandler, &cookie))) dw_window_set_data(hwnd, "_dw_html_cookie", DW_INT_TO_POINTER(cookie)); } } @@ -1932,7 +1927,7 @@ { // Detach the browser object from this window, and free resources. _UnEmbedBrowserObject(hwnd); - + _free_window_memory(hwnd, 0); return(TRUE); } }
--- a/win/dw.c Sat Nov 09 06:33:08 2019 +0000 +++ b/win/dw.c Sat Nov 09 07:18:21 2019 +0000 @@ -703,7 +703,6 @@ _Max } _PreferredAppMode; -int CompareStringOrdinal(LPCWCH lpString1, int cchCount1, LPCWCH lpString2, int cchCount2, BOOL bIgnoreCase); HTHEME (WINAPI * _OpenNcThemeData)(HWND, LPCWSTR) = NULL; VOID (WINAPI * _RefreshImmersiveColorPolicyState)(VOID) = NULL; BOOL (WINAPI * _GetIsImmersiveColorUsingHighContrast)(IMMERSIVE_HC_CACHE_MODE) = NULL; @@ -805,7 +804,7 @@ BOOL IsColorSchemeChangeMessage(LPARAM lParam) { BOOL is = FALSE; - if(lParam && CompareStringOrdinal((LPCWCH)lParam, -1, L"ImmersiveColorSet", -1, TRUE) == CSTR_EQUAL) + if(lParam && _wcsicmp((LPCWCH)lParam, L"ImmersiveColorSet") == 0) { _RefreshImmersiveColorPolicyState(); is = TRUE;
--- a/win/edge.cpp Sat Nov 09 06:33:08 2019 +0000 +++ b/win/edge.cpp Sat Nov 09 07:18:21 2019 +0000 @@ -27,6 +27,7 @@ #define UTF8toWide(a) _myUTF8toWide(a, a ? _alloca(MultiByteToWideChar(CP_UTF8, 0, a, -1, NULL, 0) * sizeof(WCHAR)) : NULL) #define WideToUTF8(a) _myWideToUTF8(a, a ? _alloca(WideCharToMultiByte(CP_UTF8, 0, a, -1, NULL, 0, NULL, NULL)) : NULL) LRESULT CALLBACK _wndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2); + BOOL CALLBACK _free_window_memory(HWND handle, LPARAM lParam); extern HWND DW_HWND_OBJECT; BOOL DW_EDGE_DETECTED = FALSE; @@ -292,8 +293,8 @@ { dw_window_set_data(hWnd, _DW_HTML_DATA_NAME, NULL); webview->Close(); - } + _free_window_memory(hwnd, 0); return(TRUE); } }