WebBrowserControl Scroll to Bottom

Challenge

I am working on a simple chat application using a System.Windows.Forms.WebBrowser Control to display the messages between the user and the recipient. How do I get the control to automatically scroll to the bottom every time I update the DocumentText of the control?

Solution

I tried to Google it and found below stuff which doesn’t work as expected.

ctlWebBrowser.Document.Body.ScrollIntoView(false);

// http://stackoverflow.com/questions/990651/system-windows-forms-webbrowser-scroll-to-end

webCtrl.Document.Window.ScrollTo(0, int.MaxValue);

// http://stackoverflow.com/questions/46454/webbrowsercontrol-scroll-to-bottom
Finally, I did it using following way:
[sourcecode language=”csharp”]
private void ScrollMessageIntoView()
{
// MOST IMP : processes all windows messages queue
System.Windows.Forms.Application.DoEvents();
if (webBrowserControlRcdMsg.Document != null)
{
webBrowserControlRcdMsg.Document.Window.ScrollTo(0,
webBrowserControlRcdMsg.Document.Body.ScrollRectangle.Height);
}
}
[/sourcecode]
Thanks to this Link : http://social.msdn.microsoft.com/forums/en-US/winforms/thread/74694382-dc0d-4824-ac8f-3a4046f45111/

How to Debug Windows Service

Hi Folks, Sorry for being invisible for a long time. But i got really tied up with my bits. Anyways it’s good if i be more busy then i will get more stuff to write 🙂

First of All Happy Diwali And Happy new year to all of you! I hope this year you face so many challenges which makes you strong in your field!

Challenge

If anyone of you worked developing Windows Services in Visual Studio then one thing you must be wondering too do Debug – which makes programming easier. It’s not as easy as putting breakpoint and do debug like console,windows or web. It is an art to debug windows service.

Solution

To Debug windows service you can use Debugger.Break() method — Signals a breakpoint to an attached debugger.

So here are the steps to debug any piece of code in windows service:

1. Call Debugger.Break() Method before the line you want to put Debug point.

2. Now on the point which you want to get called put breakpoint. Means next line to your Debugger.Break() Line.

3. Now start your windows service. Whenever your piece of code executed. You will see Visual Studio Just-In Time Debugger Window. Choose VS instance and here you go!

Have a Happy Debugging!

Webliography

http://dotnettipoftheday.org/tips/how-to-debug-windows-service-startup.aspx — Another Blog

http://stackoverflow.com/questions/761120/how-to-debug-a-windows-service-using-breakpoints — Same Challenge