Mercurial > dwindows
comparison win/browser.c @ 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 | 8a11bb8ec347 |
comparison
equal
deleted
inserted
replaced
2021:0cce5fed4594 | 2022:28809bf17957 |
---|---|
35 LPWSTR _myUTF8toWide(char *utf8string, void *outbuf); | 35 LPWSTR _myUTF8toWide(char *utf8string, void *outbuf); |
36 char *_myWideToUTF8(LPWSTR widestring, void *outbuf); | 36 char *_myWideToUTF8(LPWSTR widestring, void *outbuf); |
37 #define UTF8toWide(a) _myUTF8toWide(a, a ? _alloca(MultiByteToWideChar(CP_UTF8, 0, a, -1, NULL, 0) * sizeof(WCHAR)) : NULL) | 37 #define UTF8toWide(a) _myUTF8toWide(a, a ? _alloca(MultiByteToWideChar(CP_UTF8, 0, a, -1, NULL, 0) * sizeof(WCHAR)) : NULL) |
38 #define WideToUTF8(a) _myWideToUTF8(a, a ? _alloca(WideCharToMultiByte(CP_UTF8, 0, a, -1, NULL, 0, NULL, NULL)) : NULL) | 38 #define WideToUTF8(a) _myWideToUTF8(a, a ? _alloca(WideCharToMultiByte(CP_UTF8, 0, a, -1, NULL, 0, NULL, NULL)) : NULL) |
39 LRESULT CALLBACK _wndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2); | 39 LRESULT CALLBACK _wndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2); |
40 BOOL CALLBACK _free_window_memory(HWND handle, LPARAM lParam); | |
40 | 41 |
41 // This is used by DisplayHTMLStr(). It can be global because we never change it. | 42 // This is used by DisplayHTMLStr(). It can be global because we never change it. |
42 static const SAFEARRAYBOUND ArrayBound = {1, 0}; | 43 static const SAFEARRAYBOUND ArrayBound = {1, 0}; |
43 | 44 |
44 // Our IStorage functions that the browser may call | 45 // Our IStorage functions that the browser may call |
1839 SysFreeString(bstrProp); | 1840 SysFreeString(bstrProp); |
1840 | 1841 |
1841 // Get IWebBrowser2' IConnectionPointContainer sub-object. We do this by calling | 1842 // Get IWebBrowser2' IConnectionPointContainer sub-object. We do this by calling |
1842 // IWebBrowser2' QueryInterface, and pass it the standard GUID for an | 1843 // IWebBrowser2' QueryInterface, and pass it the standard GUID for an |
1843 // IConnectionPointContainer VTable | 1844 // IConnectionPointContainer VTable |
1844 if ((hr = webBrowser2->lpVtbl->QueryInterface(webBrowser2, &IID_IConnectionPointContainer, &container))) | 1845 if (!(hr = webBrowser2->lpVtbl->QueryInterface(webBrowser2, &IID_IConnectionPointContainer, &container))) |
1845 dw_debug("QueryInterface error: Can't get IConnectionPointContainer object"); | |
1846 else | |
1847 { | 1846 { |
1848 // Get IWebBrowser2' IConnectionPoint sub-object for specifically giving | 1847 // Get IWebBrowser2' IConnectionPoint sub-object for specifically giving |
1849 // IWebBRowser2 our DWEventHandler. We do this by calling IConnectionPointContainer's | 1848 // IWebBRowser2 our DWEventHandler. We do this by calling IConnectionPointContainer's |
1850 // FindConnectionPoint, and pass it DWEventHandler VTable's GUID | 1849 // FindConnectionPoint, and pass it DWEventHandler VTable's GUID |
1851 hr = container->lpVtbl->FindConnectionPoint(container, &DIID_DWebBrowserEvents2, &point); | 1850 hr = container->lpVtbl->FindConnectionPoint(container, &DIID_DWebBrowserEvents2, &point); |
1852 | 1851 |
1853 // We don't need the IConnectionPointContainer, now that we got the one IConnectionPoint | 1852 // We don't need the IConnectionPointContainer, now that we got the one IConnectionPoint |
1854 // we want (ie, the one we use to give IWebBrowser2 our DWEventHandler) | 1853 // we want (ie, the one we use to give IWebBrowser2 our DWEventHandler) |
1855 container->lpVtbl->Release(container); | 1854 container->lpVtbl->Release(container); |
1856 | 1855 |
1857 if (hr) | 1856 if (!hr) |
1858 dw_debug("FindConnectionPoint error: Can't get IConnectionPoint object"); | |
1859 else | |
1860 { | 1857 { |
1861 DWORD cookie; | 1858 DWORD cookie; |
1862 | 1859 |
1863 // Now call the IConnectionPoint's Advise function, giving it some object | 1860 // Now call the IConnectionPoint's Advise function, giving it some object |
1864 // whose QueryInterface it will call to get our DWEventHandler object. Let's | 1861 // whose QueryInterface it will call to get our DWEventHandler object. Let's |
1869 // colossal blunder of designing COM to accomodate the limitations of early, | 1866 // colossal blunder of designing COM to accomodate the limitations of early, |
1870 // primitive editions of Visual Basic. | 1867 // primitive editions of Visual Basic. |
1871 // | 1868 // |
1872 // Advise() gives us back a "cookie" value that we'll need to later pass to | 1869 // Advise() gives us back a "cookie" value that we'll need to later pass to |
1873 // Unadvise() (when we want to tell IWebBrowser2 to stop using our DWEventHandler) | 1870 // Unadvise() (when we want to tell IWebBrowser2 to stop using our DWEventHandler) |
1874 if ((hr = point->lpVtbl->Advise(point, (IUnknown *)&MyDWEventHandler, &cookie))) | 1871 if (!(hr = point->lpVtbl->Advise(point, (IUnknown *)&MyDWEventHandler, &cookie))) |
1875 dw_debug("Advise error: Can't set our DWEventHandler object"); | |
1876 else | |
1877 dw_window_set_data(hwnd, "_dw_html_cookie", DW_INT_TO_POINTER(cookie)); | 1872 dw_window_set_data(hwnd, "_dw_html_cookie", DW_INT_TO_POINTER(cookie)); |
1878 } | 1873 } |
1879 } | 1874 } |
1880 | 1875 |
1881 // We no longer need the IWebBrowser2 object (ie, we don't plan to call any more functions in it | 1876 // We no longer need the IWebBrowser2 object (ie, we don't plan to call any more functions in it |
1930 | 1925 |
1931 case WM_DESTROY: | 1926 case WM_DESTROY: |
1932 { | 1927 { |
1933 // Detach the browser object from this window, and free resources. | 1928 // Detach the browser object from this window, and free resources. |
1934 _UnEmbedBrowserObject(hwnd); | 1929 _UnEmbedBrowserObject(hwnd); |
1935 | 1930 _free_window_memory(hwnd, 0); |
1936 return(TRUE); | 1931 return(TRUE); |
1937 } | 1932 } |
1938 } | 1933 } |
1939 | 1934 |
1940 return(DefWindowProc(hwnd, uMsg, wParam, lParam)); | 1935 return(DefWindowProc(hwnd, uMsg, wParam, lParam)); |