// maindlg.h : header file
//

#include "weblib.h"
#include "htmlpars.h"

/////////////////////////////////////////////////////////////////////////////
// CMainDlg dialog

class CMainDlg : public CDialog
{
  public:
	CMainDlg(CWnd* pParent = NULL);	// standard constructor
	~CMainDlg();
	
	virtual BOOL OnInitDialog();
	virtual void OnCancel();
	virtual LRESULT WindowProc(UINT message,WPARAM wParam,LPARAM lParam);

	//{{AFX_DATA(CMainDlg)
	enum { IDD = IDD_MAINDLG };
	//}}AFX_DATA

  protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support 

	// Generated message map functions
	//{{AFX_MSG(CMainDlg)
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnBrowserAPI();
	afx_msg void OnHtmlAPI();
	afx_msg void OnToolbarAPI();
	afx_msg void OnUtilAPI();
	afx_msg void OnGoBtn();
	afx_msg void OnDblclkListapi();
	afx_msg void OnSelchangeListapi();
	afx_msg void OnNotifyBtn();
	afx_msg void OnStatusBtn();   
	afx_msg void OnNotifyUpdateCmdUI(CCmdUI* pCmdUI);
	afx_msg void OnStatusUpdateCmdUI(CCmdUI* pCmdUI);
	afx_msg LONG OnApiNotification(UINT wParam,LONG lParam);
	afx_msg LONG OnEnumParseTree(UINT wParam,LONG lParam);
	afx_msg LONG OnEnumFindText(UINT wParam,LONG lParam);
	afx_msg LONG OnEnumFindSpecial(UINT wParam,LONG lParam);
	afx_msg LONG OnEnumFindComment(UINT wParam,LONG lParam);
	afx_msg LONG OnEnumFindTagType(UINT wParam,LONG lParam);
	afx_msg LONG OnEnumFindTagName(UINT wParam,LONG lParam);
	afx_msg LONG OnEnumFindTagAttr(UINT wParam,LONG lParam);
	afx_msg LONG OnApiDlgDestroy(UINT wParam,LONG lParam);
	afx_msg void OnDestroy();
	//}}AFX_MSG
	
	DECLARE_MESSAGE_MAP()
	
  private: 
	void ConnectBrowserAPI();
	void DisconnectBrowserAPI();
	void GetWindowInfoAPI();
    void ListWindowsAPI();
    void ActivateWindowAPI();
    void CloseWindowAPI();
    void SetWindowPosAPI();
    void ShowWindowAPI();
    void ShowFileAPI();
    void OpenURLAPI();
    void SaveURLAPI();
    void PostFormDataAPI();
    void SaveFormDataAPI();
    void RegisterProtocolAPI();
    void UnregisterProtocolAPI();
    void RegisterURLEchoAPI();
    void UnregisterURLEchoAPI();
    void RegisterViewerAPI();
    void UnregisterViewerAPI();
    void RegisterWindowChangeAPI();
    void UnregisterWindowChangeAPI();
    void ParseAnchorAPI();
    void GetVersionAPI();
    void QueryURLFileAPI();
    void SetNotifyMethodAPI();
    
    void CreateToolbarAPI();
	void DeleteToolbarAPI();
    void IsToolbarActiveAPI();
    void SetActiveToolbarAPI();
    void AddToolbarButtonAPI();
    void RemoveToolbarButtonAPI();
    void IsToolbarButtonVisibleAPI();
    void ShowToolbarButtonAPI();
    void EnableToolbarButtonAPI();
    void IsToolbarButtonEnabledAPI();
    void GetToolbarTextAPI();
    void SetToolbarTextAPI();
    void GetToolbarFontAPI();
    void SetToolbarFontAPI();
    void GetToolbarBkgndAPI();
    void SetToolbarBkgndAPI();
    void GetToolbarTextColorAPI();
    void SetToolbarTextColorAPI();
    
    void HtmlParseAPI();
	void HtmlEndParseAPI();
    void HtmlEnumParseTreeAPI();
    void HtmlGetChildAPI();
    void HtmlGetParentAPI();
    void HtmlGetSiblingAPI();
    void HtmlGetElementTypeAPI();
    void HtmlGetElementTextAPI();
    void HtmlGetTextAttrAPI();
    void HtmlGetTagNameAPI();
    void HtmlGetTagTypeAPI();
    void HtmlGetTagAttrAPI();
    void HtmlExtractTagAttrAPI();
    void HtmlFindTextAPI();
    void HtmlFindSpecialAPI();
    void HtmlFindCommentAPI();
    void HtmlFindTagTypeAPI();
    void HtmlFindTagNameAPI();
    void HtmlFindTagAttrAPI();
    void HtmlEnumFindTextAPI();
    void HtmlEnumFindSpecialAPI();
    void HtmlEnumFindCommentAPI();
    void HtmlEnumFindTagTypeAPI();
    void HtmlEnumFindTagNameAPI();
    void HtmlEnumFindTagAttrAPI();
    
    void AppendFormDataAPI();
    void GetFormDataLengthAPI();
    void ParseAbsoluteURLAPI();
    void AccessFormDataAPI();

	void ApiReturnValue(const char *pszAPI,const char *pszParm1 = NULL,
		const char *pszParm2 = NULL);
	void Error(UINT nMsgID,const char *pszParm = NULL);
	
	void EnumHtmlElement(CStringArray &nfyArray,const char *pszEnum,UINT wParam,
		LONG lParam);
	void FillInfoListbox(CStringArray &nfyArray);	
	void RemoveFromStatusArray(CStringArray &staArray,CString &strItem);
	
	CString m_strLogFile;
	BOOL m_bLogging; 
	
	HBROWSER m_hBrowser;
	HTOOLBAR m_hToolbar;
	HPARSE m_hParse;   
	HFORMDATA m_hFormData;
	
	CListBox m_ListboxInfo;
	CListBox m_ListboxAPI;
	
	HFONT m_hFont;
	HELEMENT m_hElement;
	HTAGATTR m_hTagAttr;
	
	CStringArray m_nfyShowFile;						// for tracking notifications
	CStringArray m_nfyOpenURL;
	CStringArray m_nfySaveURL;
	CStringArray m_nfyPostFormData;	
	CStringArray m_nfySaveFormData;
	CStringArray m_nfyRegProtocol;
	CStringArray m_nfyRegURLEcho;
	CStringArray m_nfyRegViewer;
	CStringArray m_nfyRegWindowChange;
	CStringArray m_nfyToolbar;
	CStringArray m_nfyEnumParseTree;
	CStringArray m_nfyEnumFindText;
	CStringArray m_nfyEnumFindSpecial;
	CStringArray m_nfyEnumFindComment;
	CStringArray m_nfyEnumFindTagType;
	CStringArray m_nfyEnumFindTagName;
	CStringArray m_nfyEnumFindTagAttr;
	
	CStringArray *m_pnfyArray;						// which array to add notification to
	
	CStringArray m_staRegProtocol;					// for tracking status
	BOOL m_staRegURLEcho;
	CStringArray m_staRegViewer;
	CDWordArray m_staRegWindowChange;
	CUIntArray m_staToolbar;
};

class CDisableDialog   		// so we can disable main dlg before calling dialogs in DLL
{ 
  public: 
  	CDisableDialog(CWnd *pWnd)
  		{ (m_pWnd = pWnd)->EnableWindow(FALSE); }
  	~CDisableDialog()
  		{ m_pWnd->EnableWindow(TRUE); }
  		
  private:
  	CWnd *m_pWnd;
};
