Showing posts from November, 2007

.NET vs Native Win32 code

Ok so I've been writing apps using C# for a couple of years now. I had done some work in MFC but not much. Mostly console stuff very little GUI work. Well I recently thought how hard could it be to work in win32? The answer is mixed of course. I should give some background on how this came about. I recently published a ip viewer tool written in C# that monitors your ip address. It sits in the system tray and when double clicked shows a dialog form. It took me about 8 hours of coding to put together. It runs and works and does its job well. However it takes the .net framework v2 which as much as MS wants to say isn't standard on pc desktops across the world yet. And while it's not slow, on first load it sure as hell ain't fast. After first load it's pretty snappy but damn it looks like hell until it does. And this app isn't very large a 72KB exe is all. 3 forms and 1 support dll that really could be in the exe. So I decided to write the exact same

Copying data to the clipboard using C#

So you need to copy data to the clipboard using .net. Usually Ctl-C, Ctl-V is good enough for me. But there arose a need to copy data from a context menu. Microsoft has actually made it pretty easy to get data to/from the clipboard. They have conveniently created a class to do this and called it Clipboard. For my uses I just needed to copy some basic text to the clipboard. To achieve this I simply use the method SetText. Easy as pie! so a qucik and dirty example is Clipboard.SetText( "Hello World!"); Will put the text Hello World in your clipboard. There are of course different methods for copying all sorts of data into the clipboard. Read the MSDN for the complete breakdown. Read the MSDN article

I am a published shareware author!

Woot! I am now officially a published shareware author! I released IP Viewer to the masses on 19 suckers , I mean users have downloaded my software so far. I even released it under the GPL 3.0 so if any of you cave dwellers wants to use it feel free. I have pushed it to version 1.1 already to include the host name as well. Now let's hope I don't get sued by some douche who beat me to the punch! So go to the site or visit my website and download the thing.

Creating an app that can minimize to the tray

So for a long time I've wanted to create an app that can minimize to the system tray. MFC could do it but you had to call some compilcated win32 routines. I've found .net 2.0 makes this easy! Yay for .net. What you need to do is add a NotifyIcon control to your application. This will display an icon in the system tray with an icon of your choice. For my app I simply set the initial Visible property to false so you can't see the icon and then when the user minimizes the application I set the main forms ShowInTaskbar property to false and set the NotifyIcon Visible propety to true. And instantly you get no app and an icon in the taskbar. To get it back add a DoubleClick event to the NotifyIcon and restore the main form. Now users can minimize my app to the tray and double click it to get it back. The program is done and is now ready for download at Link to the site

Awesmome pics

Linky Link . Seriously I don't know if they're all real or not but they kick ass none the less.