Click here to Skip to main content
15,894,896 members
Articles / Desktop Programming / MFC

Embedding an HTML Help window into a dialog

Rate me:
Please Sign up or sign in to vote.
3.75/5 (7 votes)
1 Feb 2000 160.2K   1.3K   31  
Placing an embedded help window inside of a dialog, property sheet, or window.
// Copyright (C) 1998-1999 KeyWorks Software. All rights reserved.

// This module contains the interface and class that can be used for reading
// files (streams) out of a .CHM or .ITS file. 


#ifndef __CITS_H__
#define __CITS_H__

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

DEFINE_GUID(CLSID_ITStorage, 0x5d02926a, 0x212e, 0x11d0, 0x9d, 0xf9, 0x0, 0xa0, 0xc9, 0x22, 0xe6, 0xec);
DEFINE_GUID(IID_ITStorage, 0x88cc31de, 0x27ab, 0x11d0, 0x9d, 0xf9, 0x0, 0xa0, 0xc9, 0x22, 0xe6, 0xec);

typedef struct _ITS_Control_Data
{
    UINT cdwControlData;     // Number of DWords to follow.
    UINT adwControlData[1];  // Actually this will be adwControlData[cdwControlData]

} ITS_Control_Data, *PITS_Control_Data;  

typedef enum ECompactionLev { 
    COMPACT_DATA = 0, 
    COMPACT_DATA_AND_PATH
};

DECLARE_INTERFACE_(IITStorage, IUnknown)
{
    STDMETHOD(StgCreateDocfile) (const WCHAR* pwcsName, DWORD grfMode, DWORD reserved, IStorage** ppstgOpen) PURE;

    STDMETHOD(StgCreateDocfileOnILockBytes) (ILockBytes * plkbyt, DWORD grfMode, 
                            DWORD reserved, IStorage ** ppstgOpen) PURE;

    STDMETHOD(StgIsStorageFile) (const WCHAR * pwcsName) PURE;

    STDMETHOD(StgIsStorageILockBytes) (ILockBytes * plkbyt) PURE;

    STDMETHOD(StgOpenStorage)(const WCHAR * pwcsName, IStorage * pstgPriority, 
                              DWORD grfMode, SNB snbExclude, DWORD reserved, 
                              IStorage ** ppstgOpen
                             ) PURE;

    STDMETHOD(StgOpenStorageOnILockBytes)
                  (ILockBytes * plkbyt, IStorage * pStgPriority, DWORD grfMode, 
                   SNB snbExclude, DWORD reserved, IStorage ** ppstgOpen
                  ) PURE;

    STDMETHOD(StgSetTimes)(WCHAR const * lpszName,  FILETIME const * pctime, 
                           FILETIME const * patime, FILETIME const * pmtime
                          ) PURE;

    STDMETHOD(SetControlData)(PITS_Control_Data pControlData) PURE;

    STDMETHOD(DefaultControlData)(PITS_Control_Data *ppControlData) PURE;
		
    STDMETHOD(Compact)(const WCHAR* pwcsName, ECompactionLev iLev) PURE;
};

class CItsFile
{
public:
    CItsFile();
    ~CItsFile();

    IStorage* GetStorage(void) { return m_pStorage; }   // this is the root storage

    HRESULT   OpenITS(PCSTR pszFile);

    HRESULT OpenStorage(PCSTR pszName, IStorage** ppStorage, DWORD dwAccess = STGM_READWRITE) {
                return m_pStorage->OpenStorage(FileNameToWCHAR(pszName), NULL, dwAccess, 0, 0, ppStorage); }
    HRESULT OpenStream(PCSTR pszFile, IStream** ppStream, IStorage* pStorage, DWORD dwAccess = STGM_READWRITE) {
                return pStorage->OpenStream(FileNameToWCHAR(pszFile), NULL, dwAccess, 0, ppStream); }

protected:
    WCHAR* FileNameToWCHAR(PCSTR psz);

    IITStorage*   m_pITStorage;
    IStorage*     m_pStorage;
    WCHAR*        m_pwTmpFile;
};

// Use this class to extract strings from the #STRINGS subfile

class CStringSubFile
{
public:
    CStringSubFile(CItsFile* pif);
    ~CStringSubFile();

    bool GetString(DWORD offset, char* pszDst, int cbDst);

protected:
    IStream*      m_pStream;     // pointer to #STRINGS stream
    CItsFile*     m_pif;
};

#endif  // __CITS_H__

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
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions