#ifndef WEBCTRL_H
#define WEBCTRL_H

#include <windows.h>
#include <windowsx.h>
#include <ocidl.h>
#include <shlobj.h>
#include <tchar.h>
#include "WebContainer.h"

// #define WEBCTRL_AUTOINIT

#define WC_WEBCTRLA "WebCtrl32"
#define WC_WEBCTRLW L"WebCtrl32"
#define THIS_PROP   _T("this")
#define WC_SET WM_APP+1
#define WC_APPEND WM_APP+2
#define WC_INSERT WM_APP+3
#define WC_SCROLL WM_APP+4

#ifdef UNICODE
#define WC_WEBCTRL WC_WEBCTRLW
#else
#define WC_WEBCTRL WC_WEBCTRLA 
#endif // UNICODE

class CWebCtrl
{
public:

   CWebCtrl( HWND );

   void SetText(const TCHAR * html);
   void Write(const TCHAR * html);
   void Clear();

private:

   friend LRESULT CALLBACK WebCtrlProc( HWND, UINT, WPARAM, LPARAM );

   LRESULT WebCtrlProc( UINT, WPARAM, LPARAM );

   void Navigate( LPTSTR );
   void SetHTML( const TCHAR * html);
   void AppendHTML( const TCHAR * html);
   void InsertHTML(const TCHAR * html);

   void Scroll(int x, int y);

   HWND m_hwnd;

   int  m_cxScroll;
   int  m_cyScroll;
   int width;
   int height;

   CWebContainer *m_pContainer;

   IWebBrowser2 *m_pweb;
   
};


bool WINAPI InitWebCtrl();
bool WINAPI UninitWebCtrl();

#ifdef WEBCTRL_AUTOINIT

HWND WINAPI CreateWebControl( LPCTSTR pszText, DWORD dwStyles, int x, int y, int cx, int cy, HWND hwndParent, UINT uId );

#endif // WEBCTRL_AUTOINIT

#endif // WEBCTRL_H
