使用soui开发的mbc,只支持windows版本
w1146869587
2022-01-24 0408576e9da10015ffa9da0079b8c985113ce4b3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#pragma once
#include "stdafx.h"
#include "exptcef.h"
#include "webview/Cef3WebVWndHandler.h"
#include "webview/Cef3MainContext.h"
#include <functional>
 
namespace SOUI {
 
#define WM_WEBSITE_SIZE 100
    
class DLL_EXPORT_IMPORT SWebViewWnd :
    public CSimpleWnd, public browser::IBrowserClient
{
public:
    SWebViewWnd(void);
    ~SWebViewWnd(void);
public:    
    browser::CCef3WebVWndHandler   *webview_handler_;
    SStringT                        m_strUrl;
    SStringT                        m_strTitle;
public:
    // ÊµÏֵĽӿڠIBrowserClient
    virtual HWND getWindowHandle();
    virtual CefClient  *getClient();
 
    // ÉèÖõ÷ÊÔ¹¤¾ß
    void SetDevTools(bool devtools);
    // ------------------------------------------------------------------------------
    //
    // methods for user
    //
    // ------------------------------------------------------------------------------ 
    BOOL LoadURL(const SStringT& url);
    BOOL LoadHtml(const SStringT& strHtml);
    SStringW GetTitle();
    SStringW GetURL();
    void ExecJavaScript(const SStringT& js);
    BOOL CanGoBack();
    void GoBack();
    BOOL CanGoForward();
    void GoForward();
    BOOL IsLoading();
    void Reload();
    void StopLoad();
    BOOL Open(SStringT  strUrl);
    void Close();
    void GetWebViewSource(std::function<void(const CefString&)> &&callback);
    // µ¯³ö´°£¬ÎªÁ˽â¾öcefµÄbug
    LRESULT OnOpenFileDialog(UINT uMsg,WPARAM wParam,LPARAM lParam,BOOL & bHandled);    
    LRESULT OnWebUrlDialog(UINT uMsg,WPARAM wParam,LPARAM lParam,BOOL & bHandled);     
public:
    void ReDraw();
public:
    int OnCreate(LPCREATESTRUCT lpCreateStruct);
    BOOL OnInitDialog(HWND wndFocus,LPARAM lInitParam);
    BOOL OnEraseBkgnd(HDC dc);
    void OnClose();
    void OnSize(UINT nType, CSize size);
    void OnPaint(IRenderTarget *pRT);
    void OnTimer(UINT_PTR nIDEvent);  
    //HostWndÕæÊµ´°¿ÚÏûÏ¢´¦Àí
    BEGIN_MSG_MAP_EX(SWebViewWnd)
        MSG_WM_PAINT_EX(OnPaint) 
        MSG_WM_CREATE(OnCreate)
        MSG_WM_INITDIALOG(OnInitDialog)
        MSG_WM_ERASEBKGND(OnEraseBkgnd)
        MSG_WM_CLOSE(OnClose)
        MSG_WM_SIZE(OnSize)
        CHAIN_MSG_MAP(CSimpleWnd)
        MSG_WM_TIMER_EX(OnTimer) 
        MESSAGE_HANDLER(WM_OPENFILEDIALOG,OnOpenFileDialog)  // µ¯³ö´°£¬ÎªÁ˽â¾öcefµÄbug
        MESSAGE_HANDLER(WM_WEBURLDIALOG,OnWebUrlDialog)   
        REFLECT_NOTIFICATIONS_EX();  
    END_MSG_MAP() 
//private:
//    SOUI::CRect                           m_rc; // ³õʼ»¯rc
//public:
    //void SetInitRc( SOUI::CRect &rc );
};
 
}