Win32: Hide to system tray – Part 2

In Part 1 of the series, we have seen how we can hide the application and display an icon in system tray. In Part 2 we will build on Part 1 example to see how we can implement a redisplay of application window upon double click on system tray icon. To do that, we need to create a message that tray icon will report to main application and check it for events.

[Read the rest of this entry…]

Win32: Hide to system tray – Part 1

I used to code in C++ a lot. And I mean, a lot. For instance, at previous gig, I created an application that measures bandwidth between multiple clients and a server. Interesting project. Specially since three quarters down that road, I had to port it from Windows platform to Linux. But that is entirely different story. However, as years went by, there was less and less things I found comfortable doing in C++. Mostly because (and I know this sounds as a heresy) C# has become my favourite language. But that is as well another story.

Lately, though, I decided to rekindle my C++ knowledge. As a result, you will be seeing some of my C++ work up here. My first project, RGB to Hex converter, was presented online about a month ago. Now I decided to go for something Windows based and created an empty Win32 application that can hide to tray and then redisplay again. Part 1 will cover hiding application and displaying icon in system tray.

[Read the rest of this entry…]

Web 3.0

Just in case you (like me) didn’t know what the **** Web 3.0 is (I didn’t even know it is a buzz word these days), you should read this post on Amit Agarwal’s blog should help you out.

RGB to HEX converter

In my line of work (building intranet business apps), I too commonly encounter a problem of converting RGB numbers to hex value. Sure, I could just use rgb notation, but I prefer a hex one, as it is easier on the eyes and makes CSS shorter. My solution, usually was, to either use a calculator to convert RGB to hex or search the web for an online converter. As first chance makes you convert each number separately, making it utterly slow and painful process, the second is of no use, when there is no internet connection around.

As I had a couple of minutes of spare time, I created a small windows command line program that does exactly that. It takes RGB value as a command line parameter and convert it to hex.

Sample usage:

> rgb2hex 100 55 234

Hex value: #6437ea

You can download it from here.

There is also source code available. You can download it using git:

> git pull https://jkovalenkov@bitbucket.org/jkovalenkov/rgb2hex.git.

 

Extending BuildMaster

I might have mentioned, or I might have not, that we have recently started to use BuildMaster as a continuous integration tool. Before continuing, let me make myself clear and say that besides being a satisfied customer of BuildMaster, I have nothing to do with the product itself. Now, with that out of the way, if you do not automate your builds yet, I deeply recommend using BuildMaster, which is also free to use (albeit with some limitations).

Anyway, back to my story. As mentioned, we are using BuildMaster for currently eight .NET applications that need to be deployed each in its own special way. And with BuildMaster it works like a charm. However, integrated Subversion Create Tag action was too general for our needs and purposes. Hence, it was time to create our own BuildMaster Extension. [Read the rest of this entry…]

Lazy

As you might have noticed, my recent post count suffered a tremendous drop. And surprisingly, work has nothing to do with it. It is just a dangerous attack of laziness that I can not shake off. In my spare time, I have become lazy to a point, where writing this article took about a month of preparation and it is written now only because I am out of moves in Triple Town and Bejeweled can entertain me only so far. Yes, I admit, I am lazy to a point where I cannot be bothered even playing a proper PC game. There are latest X-COM (and all 4 original parts), Civ5 and FM2013 waiting for me patiently in Steam, but haven’t run them in ages.

This state is mindboggling to me. I can not stand laziness. I am usually found writing my own projects or just surfing latest development tech sites in the wee hours of the morning. Lately, not so much. So all of this got me thinking. How to get out of this funk?

[Read the rest of this entry…]

Quick tip: Publishing a web application with MSBuild

We have this project, that is developed in house and at an outside contractor. Recently, we purchased and installed BuildMaster and tried to use it to automatically publish this project as well. As it occurs, it is not as easy to publish a .NET 3.5 web application as it is from Visual Studio.

To cut the long story short… After several hours of research, hair pulling and quiet swearing, I found a solution that works. So, if you want to publish a web application with references to another project with MSBuild, you need to run it like this:

cd /D x:\Source\myApp\
c:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe /target:ResolveReferences;_CopyWebApplication /p:Configuration=Release;WebProjectOutputDir=X:\Builds\myApp\;OutDir=X:\Builds\myApp\bin\ myApp.csproj

Then, just move the contents to final destination.

Developing for SQL Server merge replication

Lately, we’ve been pushing our application from single server environment into an environment with merge replication. Not only that, but we also migrated from another RDBMS to Microsoft SQL server. While application had no issues working in replication environment, I learned the hard way there are some things that I could and should have done better. This are my findings.

[Read the rest of this entry…]

Quick tip: Creating multiple user controls with simillar properties

Imagine you just created 4 or 5 or n different Web user controls in your ASP.NET WebForms application. Now you realized that they all share some properties. This is a problem, because it means you are having nearly identical code in multiple spots. What you can do is create a partial public class that inherits from System.Web.UI.UserControl class and put in all properties that your controls share. Then go to each and every of your user controls and change inheritance to your own class instead of System.Web.UI.UserControl.

Class from which your controls inherit:

public partial class MyControl : System.Web.UI.UserControl
{
	#region Properties

	public string Title { get; set; }
	public string Singature { get; set; }

	#endregion
}

This is how you use it in your controls (red represents original line):

public partial class MyControl1 : MyControl
{
	protected void Page_Load(object sender, EventArgs e)
	{

	}
	...
}

public partial class MyControl2 : MyControl
{
	protected void Page_Load(object sender, EventArgs e)
	{

	}
	...
}

And now, you can do something like:

<mytag:mycontrol ID="mc1" runat="server" Title="My title" Signature="Lotushints" />

for every control that inherits MyControl class

Microsoft cuts passwords to 16 chars

This week a big news broke out. Web mail service Hotmail apparently cut passwords to 16 character of length for years, despite allowing users to enter unlimited number of characters. According to arstechnica.com this applies to all Microsoft online services, i.e. Passport authentication.

Now, this in itself is not a worry. Allowing 16 characters is plenty and secure enough to not allow a brute force attack. Even by using rainbow tables an attacker would be helpless. However, to implement a maximum 16 character password one would either have to implement this password policy from start up or one would have to store passwords in plain text. The first one is not a worry, however, the second one suggest plain text passwords, which are a no-no and something that even a HelloWorld programmer should never do. Ever!

Personally I use Hotmail services since 1998 and, to be honest, I never had any problems using it. So, I can make an assumption, that passwords were trimmed to 16 character length and then protected by whatever protection is used by Microsoft. Hence, the news is only of sensational value.