Click here to Skip to main content
15,896,423 members
Articles / Web Development / HTML

Dialog with HTML skin using CDHtmlDialog and SetWindowRgn

Rate me:
Please Sign up or sign in to vote.
4.83/5 (15 votes)
27 Oct 20043 min read 196K   5.8K   82  
Describes how to use an external HTML page as a non-rectangular skin of a dialog.
// HtmlSkinDlg.h : header file
//

#pragma once

#include "RegionDHtmlDialog.h"

// CHtmlSkinDlg dialog
class CHtmlSkinDlg : public CRegionDHtmlDialog
{
// Construction
public:
	CHtmlSkinDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_HTMLSKIN_DIALOG, IDH = IDR_HTML_HTMLSKIN_DIALOG };

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

// Implementation
protected:
	HICON m_hIcon;
	CString _sDestUrl;
	CString _sCurrentSkinPath;
	CString _sCurrentHtmlPath;
	CString _sCurrentMaskPath;
	CString _sCurrentRegionPath;
	int _nCurrentSubSkinIndex;
	bool _bReload;
	bool _bLoaded;

    // Overloaded members
    void OnDocumentComplete(LPDISPATCH pDisp, LPCTSTR szUrl);
	void OnBeforeNavigate2(LPDISPATCH pDisp, VARIANT FAR* URL, VARIANT FAR* Flags, VARIANT FAR* TargetFrameName, VARIANT FAR* PostData, VARIANT FAR* Headers, BOOL FAR* Cancel);
	void OnNavigateComplete2(LPDISPATCH pDisp, VARIANT FAR* URL);
	void OnNewWindow2(LPDISPATCH FAR* ppDisp, BOOL FAR* Cancel);

	// Generated message map functions
	virtual BOOL OnInitDialog();

	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();

	DECLARE_MESSAGE_MAP()
	DECLARE_DHTML_EVENT_MAP()
	DECLARE_EVENTSINK_MAP()

// Methods
protected:
	//for testing modified mask images and skin changing
	bool ReloadRegions( int );
	bool ShowSkin( int , bool );

// Html event handlers
public:
	HRESULT OnButtonOK( IHTMLElement *pElement );
	HRESULT OnButtonClose( IHTMLElement *pElement );
	HRESULT OnButtonReloadRegion( IHTMLElement *pElement );
	HRESULT OnButtonReloadPage( IHTMLElement *pElement );

	HRESULT OnButtonStar( IHTMLElement *pElement );
	HRESULT OnButtonFlower( IHTMLElement *pElement );
	HRESULT OnButtonFitTab( IHTMLElement *pElement );
	HRESULT OnButtonRestore( IHTMLElement *pElement );

	HRESULT OnButtonSkinLuna( IHTMLElement *pElement );
	HRESULT OnButtonSkinWebfx( IHTMLElement *pElement );
	HRESULT OnButtonSkinClassic( IHTMLElement *pElement );

	HRESULT OnButtonFitTab1( IHTMLElement *pElement );
	HRESULT OnButtonFitTab2( IHTMLElement *pElement );
	HRESULT OnButtonFitTab3( IHTMLElement *pElement );
	HRESULT OnButtonFitTab4( IHTMLElement *pElement );

	HRESULT OnHtmlSelectStart( IHTMLElement *pElement );
	HRESULT OnHtmlDragStart( IHTMLElement *pElement );
	HRESULT OnHtmlContextMenu( IHTMLElement *pElement );
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
China China
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions