Skip to main content
Email Password   helpLost your password?

Figure. 1 The demo dialog with HTML skin

Introduction

This program demonstrates how to use CDHtmlDialog and SetWindowRgn functions to give a dialog non-rectangular HTML skins. If you are familiar with HTML, it will be faster than other ways to deal with beautiful skins. The idea comes from the article, "Gimme Some Skin... VideoSkins", but I use CDHtmlDialog instead. There was an article, "Create Skins from Ordinary Web Pages", on CodeProject from the same author, but I can not reach it now.

Hope it is useful to you. I have tested my sample under Win98/Win2000/Win2003, with IE6 SP1.

Using the code

You need to change the following items to make the dialog into your own:

  1. Content of the external HTML file _Html_Skin.htm.
  2. The GIF mask images.
  3. The handlers for HTML events in the file HtmlSkinDlg.cpp.

Features

  1. Non-rectangular skinned dialog.
  2. Three skins in one external HTML page.
  3. Some unwanted behaviors of the browser control are banned.
  4. You will be dragging the whole window if you drag anywhere in the UI, except the scroll bar and inside edit controls.
  5. In Win2000, rectangular dragging outline always fits the current size of the whole window.
  6. In Win2000/XP/2003, with 16 bits or higher colors, window can be set transparent.
  7. Layout almost does not change when the system's theme is changed.

Compare between Figures 2a and 2b, Figures 3a and 3b, you can notice that the width of the scroll bar is the only minor difference of the same skin under two different themes.

Figure. 2a Luna skin, Windows classic theme.

Figure. 2b Luna skin, theme with super big font.

Figure. 3a WebFX skin, Windows classic theme.

Figure. 3b WebFX skin, theme with super big font.

Defects

  1. The very HTML page I use in my sample needs IE5.5+.
  2. The "WinClassic" skin only fits the Windows Classic theme of the system.
  3. This sample supports external page only. If you want to put the HTML page and images into resource, please refer to my other article: CDHtmlDialog with CSS, JavaScript and images.
  4. Loading a HTML page with beautiful images and layout may take a long time, so maybe you can add a splash screen before your skin page is loaded. Refer to this article: CSplashScreenEx.

Points of Interest

  1. Dropping target can mess up the page.

    In the dialog's OnInitDialog() member, I have banned the dropping file action like this:

    //refuse dragging file into this dialog
    
    m_pBrowserApp->put_RegisterAsDropTarget(VARIANT_FALSE);

    But when I attempt to drop a file into the dialog, the content is messed up when mouse pointer is passing across the border. I notice that the key is the margin of the HTML body. In the HTML page, the following must be added to avoid the mess:

    <STYLE type=text/css>
    ...
    BODY {
      ...
      MARGIN-BOTTOM: 0px;
      MARGIN-RIGHT: 0px;
      ...
    }
    ...
    </STYLE>
  2. First entrance of OnDocumentComplete is not for your external HTML page.

    The first one is for the internal HTML page in the program resource, so you may check this as follows:

    void CHtmlSkinDlg::OnDocumentComplete(LPDISPATCH , LPCTSTR szUrl)
    {
      CString sUrl=szUrl;
      sUrl.MakeLower();
      if( sUrl != _sDestUrl )
      {
        //OnDocumentComplete for built-in resource or other URLs,
    
        //not for your external page
    
        //...
    
      }
      else
      {
        //OnDocumentComplete for your external page
    
        //...
    
      }
    }

History

25 Oct 2004

Version 1.0.0.2

20 Oct 2004

Version 1.0.0.1, initial release.

By the way

:) This is my second article on CodeProject. Welcome to my page iTreeSoft.

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralSuperb! Pin
Paul Roberts
6:15 27 Nov '08  
GeneralGreat code! Pin
sodar
17:31 8 Jul '08  
QuestionCDHtmlDialog compatibility with Vista Pin
John Tan Jin Kiat
21:53 28 Nov '07  
GeneralLink on welcome page not working Pin
Amit2203
22:40 17 Jul '07  
Generalem... seems all iTreeSoft stuff is out of date... Pin
iTreeSoft
4:44 26 Mar '08  
AnswerSolved. Pin
iTreeSoft
4:26 29 Mar '08  
QuestionHitting return key closes the application Pin
nutz06
23:48 10 Jun '07  
GeneralRe: Hitting return key closes the application Pin
Member 3077090
9:16 9 Jan '08  
GeneralHow To Make Internet Explorer GUI "Draggable" Pin
Amit2203
23:09 1 Feb '07  
GeneralRe: How To Make Internet Explorer GUI "Draggable" Pin
Amit2203
5:43 2 Feb '07  
GeneralNeed Help on Http Header to add my own User-Agent Pin
rex_chen
8:09 13 May '06  
GeneralOther disabled functions Pin
Scott Owen
12:26 9 May '06  
GeneralCOOL! Pin
iTreeSoft
4:35 26 Mar '08  
GeneralCan CDHtmlDialog be used in CView? Pin
Eternity3577
11:04 17 Jan '05  
GeneralMaybe ATL or find in articles... Pin
iTreeSoft
17:10 18 Jan '05  
GeneralRe: Can CDHtmlDialog be used in CView? Pin
gillnrb
1:21 21 May '06  
GeneralOnHtmlDragStart Pin
Effiniti
0:58 10 Jan '05  
GeneralMake it the div background image... Pin
iTreeSoft
14:47 10 Jan '05  
GeneralRe: Make it the div background image... Pin
Effiniti
20:58 10 Jan '05  
GeneralCDHtmlDialog and IE version Pin
testgames@gmail.com
4:33 5 Jan '05  
GeneralIt should. Pin
iTreeSoft
23:57 5 Jan '05  
GeneralRe: It should. Pin
testgames@gmail.com
1:38 6 Jan '05  
GeneralSo test it first. Pin
iTreeSoft
3:16 6 Jan '05  
GeneralRe: So test it first. Pin
testgames@gmail.com
0:44 9 Jan '05  
GeneralHow to do about frameset Pin
newman2088
6:46 16 Nov '04  


Last Updated 27 Oct 2004 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2009