|
How do I add text to the end. Without removal old text.
|
|
|
|
|
Here is a managed class that implements a control
that wraps the HTMLLite functionality.
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Drawing;
namespace WindowsApplication1
{
public class HTMLLiteControl : System.Windows.Forms.TextBox
{
public HTMLLiteControl()
{
this.AutoSize = false;
this.Multiline = true;
this.SetStyle( ControlStyles.ResizeRedraw, true );
}
[DllImport( "htmllite.dll", CallingConvention = CallingConvention.StdCall,
EntryPoint = "_FRegisterHtmlLiteClass@4" )]
public static extern void RegisterHtmlLite( int zero );
private const int WM_ERASEBKGND = 0x0014;
private const int WM_NOTIFY = 0x004E;
private const int HTMLLITE_CODE_LEFTCLICK = 1000;
private const int HTMLLITE_CODE_TABCYCLE = 1001;
private const int HTMLLITE_CODE_RIGHTCLICK = 1003;
private const int HTMLLITE_CODE_MOUSEOVER = 1004;
private const int HTMLLITE_CODE_MOUSEHOVER = 1005;
private const int HTMLLITE_CODE_MOUSEEXIT = 1006;
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
}
[StructLayout(LayoutKind.Sequential)]
public struct NMHTMLLITE
{
public IntPtr hwndFrom;
public IntPtr idFrom;
public IntPtr code;
public IntPtr linkid;
public RECT linkrc;
}
protected override void OnHandleCreated( EventArgs e )
{
base.OnHandleCreated( e );
IntPtr hwndParent = GetParent( this.Handle );
if( hwndParent != IntPtr.Zero )
{
if( parentHook != null && parentHook.Handle != IntPtr.Zero )
parentHook.ReleaseHandle();
if( parentHook == null )
{
parentHook = new ParentHook( this, hwndParent );
}
}
}
protected override void OnHandleDestroyed( EventArgs e )
{
if( this.parentHook != null )
this.parentHook.ReleaseHandle();
}
[DllImport( "user32" )]
private static extern IntPtr GetParent( IntPtr hwnd );
protected override CreateParams CreateParams
{
get
{
RegisterHtmlLite( 0 );
CreateParams createParams = base.CreateParams;
createParams.ClassName = "HTMLLITE";
return createParams;
}
}
protected void OnParentNotify( NMHTMLLITE hdr )
{
if( hdr.hwndFrom == this.Handle && hdr.code.ToInt32() == HTMLLITE_CODE_LEFTCLICK )
OnLinkClicked( hdr.linkid.ToInt32() );
}
protected virtual void OnLinkClicked( int linkId )
{
if( this.LinkClicked != null )
this.LinkClicked( this, new LinkClickedEventArgs( linkId ) );
}
private class ParentHook : NativeWindow
{
public ParentHook( HTMLLiteControl owner, IntPtr hwndParent )
{
ownerControl = owner;
AssignHandle( hwndParent );
}
private HTMLLiteControl ownerControl = null;
protected override void WndProc( ref Message m )
{
if( m.Msg == WM_NOTIFY && m.LParam != IntPtr.Zero )
{
NMHTMLLITE hdr = (NMHTMLLITE) m.GetLParam( typeof( NMHTMLLITE ) );
int code = hdr.code.ToInt32();
if( code >= HTMLLITE_CODE_LEFTCLICK && code <= HTMLLITE_CODE_MOUSEEXIT )
ownerControl.OnParentNotify( hdr );
}
base.WndProc( ref m );
}
}
private ParentHook parentHook = null;
protected override void WndProc( ref Message m )
{
switch( m.Msg )
{
case WM_ERASEBKGND:
using( Graphics screenGraphics = Graphics.FromHdc( m.WParam ) )
using( Brush b = new SolidBrush( this.BackColor ) )
screenGraphics.FillRectangle( b, this.ClientRectangle );
break;
}
base.WndProc( ref m );
}
public string HTML
{
get
{
return html;
}
set
{
base.Text = value;
html = value;
}
}
private string html = string.Empty;
public event EventHandler<LinkClickedEventArgs> LinkClicked = null;
}
public class LinkClickedEventArgs : System.EventArgs
{
public LinkClickedEventArgs(int linkId)
{
this.LinkId = linkId;
}
public int LinkId = 0;
}
}
|
|
|
|
|
Good article about htmllite.dll! Thanks.
I want to show a bitmap resource in HTMLLITE control.
After some try, I found the right format of "res://"
is <IMG src="res://[resource handle]/#[bitmap number in resource
file]">
char s[256];
sprintf(s,
"<p>This is a IMG! </p>\n<IMG image-mask=auto src=\"res://%d/#%d\">",
(DWORD)::GetModuleHandle(NULL),
129//a bitmap resource
);
//129 is the value of your bitmap in resource.
CreateWindowEx(WS_EX_LEFT | WS_EX_CONTROLPARENT | WS_EX_STATICEDGE,
"HTMLLITE",
s, WS_CHILD | WS_VISIBLE, 1, 1, 200, 200, hWnd, 0, 0, 0);
I hope this may help someone.
|
|
|
|
|
Looks like a good thing to use in cases when you don't want to implement the browser control, but what about the legal part of it? Can we implement it in our commercial products or does one need a license?
Does anybody know?
Thanks,
Gideon
|
|
|
|
|
Did the Spy thing on MS Money some time ago, I thougth HTMLLite was something written by msmoney team. I dropped it, didn't catch the DLL part.
Great Job!
Still curious if it can be shipped with app.
Maybe gotta include $29 MSMoney with the product
Mikey_N
|
|
|
|
|
Hello all,
HTMLLite shows HTML in its window which cannot be scrolled by default. Is anybody has a solution to add a vertical scrolling?
I have tried to add WS_VSCROLL and to set some control flags without success.
Thank you,
AlainCD
Note: Thanks Nathan for your work about HTMLLite, very good.
|
|
|
|
|
You've done a very great job but i've the
same problem and don't know why the content
isn't scrollable.
Someone found a solution for this problem?
|
|
|
|
|
But is htmllite control is free to use?
#define __ARMEN_H__
|
|
|
|
|
I don't know. I queried it with a MS guy quite a while ago now and he never got back to me.
I really doubt MS cares if you use this control though. But just don't expect any support from them if some bug or vulnerability is found in it
|
|
|
|
|
1. Please tell me and give source code
i want to customize the browser ctl, so that
i can prevent (images,video clips, Activex ctl etc component) download,in MSDN it is given that it can be done by implementing the Ambient property , but complete detail i not get
2. i am using VC++ 6.0 , and (MSDN and In this VC Libraries) i not found the <iphlpapi.h> and <iphlpapi.lib> please tell link from where i download the SDK which contain this , i want that the our DNS server address programetically using GetNetworkParams
Thanks,
charanjetreport_gi@rediffmail.com
ekodeveloper@rediffmail.com
modified on Saturday, May 16, 2009 6:34 AM
|
|
|
|
|
Something like the outlook rule wizard? This creates a window on the fly, but how to add strings to the editbox with hyperlink that mimic the rule wizard and not using the syslink?
Thanks alot.
Jiac
|
|
|
|
|
hi!
I'm using Delphi7 when I try to compile a component that we did, it gave me the error file not found htmllite.pas... somebody can send me that file?... or advice
thanks
|
|
|
|
|
I changed the function prototype to the following and everything appears to work fine under VS6/7:
typedef BOOL (WINAPI *LPFNREGISTERHTMLLITECLASS)(HINSTANCE hInstance);
typedef BOOL (WINAPI *PFNREGISTERHTMLLITECLASS)(HINSTANCE hInstance);
typedef BOOL (WINAPI *LPFNUNREGISTERHTMLLITECLASS)(HINSTANCE hInstance);
typedef BOOL (WINAPI *PFNUNREGISTERHTMLLITECLASS)(HINSTANCE hInstance);
typedef BOOL (WINAPI *LPFNHTMLREPLACECTL)(HWND hDlg, UINT nIDDlgItem);
typedef BOOL (WINAPI *PFNHTMLREPLACECTL)(HWND hDlg, UINT nIDDlgItem);
PFNREGISTERHTMLLITECLASS pRegisterHtmlLiteClass = (PFNREGISTERHTMLLITECLASS)GetProcAddress(hHtmlLite,"_FRegisterHtmlLiteClass@4");
PFNUNREGISTERHTMLLITECLASS pUnregisterHtmlLiteClass = (PFNUNREGISTERHTMLLITECLASS)GetProcAddress(hHtmlLite,"_FUnregisterHtmlLiteClass@4");
PFNHTMLREPLACECTL pHtmlReplaceCtl = (PFNHTMLREPLACECTL)GetProcAddress(hHtmlLite,"_FHtmlReplaceCtl@8");
|
|
|
|
|
quick search in htmllite shows that following tags are supported:
<br>
<img>
<title></title>
<style></style>
<span></span>
<nobr></nobr>
<font></font>
<div></div>
Supported special chars:
&trade; (™)
&reg; (®)
&shy; (­)
&nbsp; ( )
&quot; (")
&copy; (©)
&bull; (•)
&amp; (&)
Supported protocols for img src:
hbmp://
file://
res://
Supported tag atrributes and values:
solid, dotted, dashed, right, left, justify, center, yellowgreen, yellow, windowtext, windowframe, window, whitesmoke, white, wheat, violet, turquoise, transparent, tomato, threedshadow, threedlightshadow, threedhighlight, threedface, threeddarkshadow, thistle, teal, tan, steelblue, springgreen, snow, slategray, slateblue, skyblue, silver, sienna, seashell, seagreen, scrollbar, sandybrown, salmon, saddlebrown, royalblue, rosybrown, red, purple, powderblue, plum, pink, peru, peachpuff, papayawhip, palevioletred, paleturquoise, palegreen, palegoldenrod, orchid, orangered, orange, olivedrab, olive, oldlace, navy, navajowhite, moccasin, mistyrose, mintcream, midnightblue, menutext, menu, mediumvioletred, mediumturquoise, mediumspringgreen, mediumslateblue, mediumseagreen, mediumpurple, mediumorchid, mediumblue, mediumaquamarine, maroon, magenta, link, linen, limegreen, lime, lightyellow, lightsteelblue, lightslategray, lightskyblue, lightseagreen, lightsalmon, lightpink, lightgrey, lightgreen, lightgoldenrodyellow, lightcyan, lightcoral, lightblue, lemonchiffon, lawngreen, lavenderblush, lavender, khaki, ivory, infotext, infobackground, indigo, indianred, inactivecaptiontext, inactivecaption, inactiveborder, hover, hotpink, hotlight, honeydew, highlighttext, greenyellow, green, graytext, gray, gradientinactivecaption, gradientactivecaption, goldenrod, gold, ghostwhite, gainsboro, fuchsia, forestgreen, focusrect, floralwhite, firebrick, dodgerblue, dimgray, default, deepskyblue, deeppink, darkviolet, darkturquoise, darkslategray, darkslateblue, darkseagreen, darksalmon, darkred, darkorchid, darkorange, darkolivegreen, darkmagenta, darkkhaki, darkgreen, darkgray, darkgoldenrod, darkcyan, darkblue, cyan, crimson, cornsilk, cornflowerblue, coral, chocolate, chartreuse, captiontext, cadetblue, buttontext, buttonshadow, buttonhighlight, buttonface, burlywood, brown, blueviolet, blue, blanchedalmond, black, bkground, bisque, beige, background, azure, aquamarine, aqua, appworkspace, antiquewhite, alt9, alt8, alt7, alt6, alt5, alt4, alt3, alt2, alt1, aliceblue, activecaption, activeborder, zwnj, line-through, underline, none, bold, italic, normal, matched, previous, auto, width-min, width-max, width, text-indent, text-decoration, text-align, src, size, phase, padding-top, padding-right, padding-left, padding-bottom, padding, num-phases, margin-top, margin-right-min, margin-right-max, margin-right, margin-left-min, margin-left-max, margin-left, margin-bottom, margin, linkid, line-height, image-mask, href, hover-phase, hover-highlight, hover-decoration, hover-color, highlight, font-weight, font-style, font-size, font-family, focus-rect-color, face, color, class, border-top-width, border-top-style, border-top-color, border-top, border-right-width, border-right-style, border-right-color, border-right, border-left-width, border-left-style, border-left-color, border-left, border-bottom-width, border-bottom-style, border-bottom-color, border-bottom, border, background-image, background-color, align
|
|
|
|
|
I've succeeded to build exacly the same interface as .NET setup (shown on the top left image in the article). If someone interested I can upload project. Also I've succeeded to convert dll into static lib file, so now it is possible to link htmllite component statically in the .exe file (.exe will not depend on htmllite.dll).
|
|
|
|
|
Hello, many thanks for sharing these details!
|
|
|
|
|
Nice Work Here,
Please, Sourcer, can you upload the project and lib or counld you send them to me at heshamz@yahoo.com
Thanks
|
|
|
|
|
Hello
Yes, would like to have the source lib if I can
Thanks
Alex aevans@leading.com.au
|
|
|
|
|
Hi.
I am wondering how you managed to convert htmllite.dll into a static lib? Was it by using IDA, converting to .asm, and then recompiling with something like MASM?
Also, it is possible to obtain the .lib? My e-mail is genghis86@hotmail.com
Thanks.
|
|
|
|
|
Would love this lib as well, even better would be info on how you went from a dll to a full static lib, as I've got a (free) dll I'd rather use as a static lib.
|
|
|
|
|
|
I've been playing with the markup a bit and it appears that it is very flexible on what attribute goes with which element. For instance, the following is perfectly valid:
<p color=white background-color=blue padding=5 face="Times New Roman" font-weight=bold font-size=28>hello</p><br />
I have yet to find a way to control the background color for the entire "body" of the document, however...
mZ
|
|
|
|
|
It appears that you have to simulate tables using the paragraph element's margin-top, margin-left and width attributes.
Here is a small example:
<style>
.titlerow { highlight: black; color: white; padding: 5; }
.leftcol { margin-top: auto; width: 200; highlight: #003399; color: white; padding: 5; }
.rightcol { margin-top: previous; margin-left: 200; padding:5; highlight: white; }
.bottom { margin-top: auto; align: right; highlight: infobackground; color: infotext; padding: 5; }
</style>
<p class="titlerow">Sample Page #1</p>
<p class="leftcol">Left Column<br>This is the left column.<br> </p>
<p class="rightcol">Right Column<br>This is the right column.<br> </p>
<p class="bottom">Exit</p> margin-top: auto snaps the current paragraph to the bottom of the previous paragraph. margin-top: previous aligns the top margin of the current paragraph with the top margin of the previous paragraph.
I am not entirely sure if you can pull off nested tables very easily using this technique, however.
EDIT: Forgot to escape ...
Taa, taa...
mZ
|
|
|
|
|
That's cool improvisation - Thanks for sharing!
|
|
|
|
|
>I have yet to find a way to control the background color for the entire "body" of the document
The control may send a WM_CTLCOLOR* message to determine the BG color. Or it may be possible to subclass it's WM_ERASEBKGND. I will have an experiment with this, at some point
|
|
|
|
|