Click here to Skip to main content
15,896,278 members
Articles / Desktop Programming / Windows Forms

C# WinForms Application Full Integration with HTMLHelp ( .chm ) - Help Topics, Context Sensitive Help, and Tooltips

Rate me:
Please Sign up or sign in to vote.
4.67/5 (12 votes)
4 May 2011CPOL5 min read 64.3K   2.2K   48  
Use HTMLHelp (.chm) to display help topics, context sensitive help and tooltips in C# Winform application
using System;
using System.IO;
using Microsoft.VisualStudio.OLE.Interop;


namespace WinHelpLib
{
    class IStreamEx : Stream 
    {
        IStream iStream;
        long lSize = 0;

        public IStreamEx(IStream iStr) 
        { 
            iStream = iStr; 
          
            Microsoft.VisualStudio.OLE.Interop.STATSTG[] stInfo = new Microsoft.VisualStudio.OLE.Interop.STATSTG[1];
            iStream.Stat(stInfo, (uint)STATFLAG.STATFLAG_NONAME);

            lSize = Convert.ToInt32(stInfo[0].cbSize.QuadPart);
        }
        
        public override bool CanRead 
        { 
            get { return true; } 
        } 
        
        public override bool CanSeek 
        { 
            get { return false; } 
        } 
        
        public override bool CanWrite 
        { get { return false; } 
        }

        public override long Length
        {
            get { return lSize; }
        }
        
        public override long Position 
        { 
            get { 
                ULARGE_INTEGER[] nlip = new ULARGE_INTEGER[1];
                nlip[0] = new ULARGE_INTEGER();

                LARGE_INTEGER li = new LARGE_INTEGER();
                li.QuadPart = 0;
                iStream.Seek(li, (uint)STREAM_SEEK.STREAM_SEEK_CUR, nlip);
                return Convert.ToInt32(nlip[0]);
            } 
            set {
                LARGE_INTEGER li = new LARGE_INTEGER();
                li.QuadPart = value;
                iStream.Seek(li, (uint)STREAM_SEEK.STREAM_SEEK_SET, null);
            } 
        } 
        
        public override int Read(byte[] buffer, int offset, int count) 
        {
            uint cb = Convert.ToUInt32(count);
            uint uiRead = 0;

            byte[] inBuffer = new byte[count];

            iStream.Read(inBuffer, cb, out uiRead);

            inBuffer.CopyTo(buffer, offset);


            return Convert.ToInt32(uiRead);
        }

        public override void Write(byte[] buffer, int offset, int count)
        {
            throw new NotImplementedException();
        }

        public override void SetLength(long value)
        {
            throw new NotImplementedException();
        }
        public override long Seek(long offset, SeekOrigin origin)
        {
            throw new NotImplementedException();
        }

        public override void Flush()
        {
            throw new NotImplementedException();
        }

    }
}

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions