Computing.Net > Forums > Programming > URL-highlighting TextBoxes in C#?

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

URL-highlighting TextBoxes in C#?

Reply to Message Icon

Original Message
Name: Leo the 28C (by Sulfurik)
Date: May 31, 2005 at 14:16:14 Pacific
Subject: URL-highlighting TextBoxes in C#?
OS: Windows XP SP2
CPU/Ram: 2.8 GHz/448 MB
Comment:

Hello everyone! :D
OK, I've seen many apps that have TextBoxes that highlight URL's when you type them in, and when you click on those URL's, they open up your browser with that URL in the address bar... My question is, where can I download a C# control that does this? Or do I have to code my own? How? Thanks! ;)

http://www.boredsource.c
om/eltrucha/
http://tsfc.ath.cx
ftp://tsfc.ath.cx
hotline://tsfc.ath.cx

Little Johnny took a drink
but he shall drink no more.
For what he thought was H2


Report Offensive Message For Removal


Response Number 1
Name: StuartS
Date: May 31, 2005 at 16:48:53 Pacific
Reply: (edit)

Code your own, its easy enough. Use the Create Process API and providing the text box contains a properly formed URL, the CreateProcess API will load you default browser and run the URL.

You can use the FindExecutable API to find which is your default browser.

I can show you how to do it in VB, but in C# you are on your own.

Stuart


Report Offensive Follow Up For Removal

Response Number 2
Name: Leo the 28C (by Sulfurik)
Date: May 31, 2005 at 18:13:06 Pacific
Reply: (edit)

Hmm... all of those API's are for VB only... :S Or is it in a Windows DLL? Which one? Thanks! ;)

http://www.boredsource.c
om/eltrucha/
http://tsfc.ath.cx
ftp://tsfc.ath.cx
hotline://tsfc.ath.cx

Little Johnny took a drink
but he shall drink no more.
For what he thought was H2


Report Offensive Follow Up For Removal

Response Number 3
Name: StuartS
Date: May 31, 2005 at 20:38:47 Pacific
Reply: (edit)

There is no such thing as a VB API. APIs can be used by any language as they are part of the operating system. VB,C++, C# and many others. The only difference is the syntax. Do a search on at Microsoft to find them. All the examples are in C++ so you may have to adjust them for C# of which I know nothing.

Stuart


Report Offensive Follow Up For Removal

Response Number 4
Name: Leo the 28C (by Sulfurik)
Date: May 31, 2005 at 21:13:06 Pacific
Reply: (edit)

OK, I found this on MSDN:
http://support.microsoft.com/default.aspx?scid=kb;en-us;174156#appliesto
But the examples are in VB...I kinda understand the VB syntax, but I don't know its functions, which there are many in the article... :S

http://www.boredsource.c
om/eltrucha/
http://tsfc.ath.cx
ftp://tsfc.ath.cx
hotline://tsfc.ath.cx

Little Johnny took a drink
but he shall drink no more.
For what he thought was H2


Report Offensive Follow Up For Removal

Response Number 5
Name: StuartS
Date: May 31, 2005 at 22:27:33 Pacific
Reply: (edit)

All it is doing is creating a Dummy file with an HTML extension. It can be a zero length file.

The file name is then fed into the FindExecutalble API along with a dummy variable and fixed length string to receive the path name of the browser.

The string is then trimmed to remove extra spaces at the end then then fed into ShellExecute which is similar to CreateProcess but not so flexible.

The ShellExecute API contains the handle of the currently running task, the "open" command, the path name to the browser in the variable BrowserExec, the URL to be opened, another dummy variable, and the a constant to define the way the windows is shown.

With both APIs is the value returned < 32 then an error occurred.

Finally the dummy file created earlier is killed off.

The only code there that is unique to VB is the bit that creates the dummy HTML file and the Trim command which trims spaces of the end of a string. MsgBox just displays a message in the screen with an OK button. I am sure you can work something out in C# to do the same.

Look here for a description of the APIs

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/findexecutable.asp

It says it applies to Wint NT and Windows 95 but it works fine under Winows XP and Windows 98.

Stuart


Report Offensive Follow Up For Removal


Response Number 6
Name: Leo the 28C (by Sulfurik)
Date: June 1, 2005 at 09:31:25 Pacific
Reply: (edit)

Well, I just decided I'll cancel that program since there's many around, but someday I'll need that, so I'll check out the links. Much thanks! ;)

http://www.boredsource.c
om/eltrucha/
http://tsfc.ath.cx
ftp://tsfc.ath.cx
hotline://tsfc.ath.cx

Little Johnny took a drink
but he shall drink no more.
For what he thought was H2


Report Offensive Follow Up For Removal






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home








Do you have your own blog?

Yes
No
I did before
I will soon


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge
Poll History




Data Recovery Software