A Place for C Sharpers/.Netters

I Will do coding till last moment of life-Kiran Patil

Archive for the ‘Windows Forms’ Category

WebBrowserControl Scroll to Bottom

Posted by kiranpatils on July 19, 2010

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:

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);

 }
 }

Thanks to this Link : http://social.msdn.microsoft.com/forums/en-US/winforms/thread/74694382-dc0d-4824-ac8f-3a4046f45111/

Posted in Windows Forms | Leave a Comment »

How to Debug Windows Service

Posted by kiranpatils on November 1, 2009

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

Posted in Windows Forms | Tagged: | Leave a Comment »

MSI Installer for setup of Windows Service

Posted by kiranpatils on July 29, 2009

Challenge:

I have created one windows service and to install it i use “installutil.exe” — and to automate the task i have created BATCH files. But how can i do this using windows installer?

Solution:

Basically you need to add New project of type “Setup and Deployment

See this walkthroguh from microsoft : http://support.microsoft.com/kb/317421

Hope this helps :)

Happy Programming!

Posted in Windows Forms | Leave a Comment »

Add More than one file Associations to a ClickOnce Application

Posted by kiranpatils on February 27, 2009

Challenge:

One of my friend has one windows application and when he publish it using Clickonce it should be mapped with his custom file extension. For example “.JPG” and “.PNG” files should be mapped with his application called “MyPaint.exe”.

We found it that how to do it for one extension as shown in great post :

http://blogs.msdn.com/mwade/archive/2008/01/30/how-to-add-file-associations-to-a-clickonce-application.aspx

But no information provided here for how to do it for multiple file extension..hooh it took us half of the day to do it..Here is the way…

Solution:

1. Follow the steps given in Above post. Test it for one extension if it works for it then go to step 2.

[NOTE: you can open app.manifest under properties->App.manifest.dll double click it.] It will open .manifest in XML editor.

2.Here for one extension code we have added is as shown below:

<fileAssociation xmlns=”urn:schemas-microsoft-com:clickonce.v1″

extension=”.JPG”

description=”My PAINT”

progid=”16E5861B-EAC0-45d4-A53D-9D5962A63780″

defaultIcon=”myPaint.ico”

/>

3. NOW for adding one more extension here is the way:

<fileAssociation xmlns=”urn:schemas-microsoft-com:clickonce.v1″

extension=”.JPG

description=”My PAINT”

progid=”16E5861B-EAC0-45d4-A53D-9D5962A63780

defaultIcon=”myPaint.ico”

/>

<fileAssociation xmlns=”urn:schemas-microsoft-com:clickonce.v1″

extension=”.PNG

description=”My PAINT”

progid=”2601E048-C585-4bcf-8673-3A29C51D69B4

defaultIcon=”myPaint.ico”

/>

NOTE: Your both Program ID should be different!!

That’s it.

Hope it helps you kick off your project on its Release date:)

If it helped you say Thank to My friend who has introduced a nice problem to me..

Link which has given us a Kick : http://msdn.microsoft.com/en-us/library/bb892924.aspx

Sample code can be downloaded from here

Posted in Windows Forms | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.

Join 102 other followers