Monday, October 08, 2007

Virtual PC 2007 Console window won' t show

Happened me last nigh, my VPC:s ran just fine but I could only access the console through the traybar.

Evidently, the options.xml file has been damaged, or at least there are faulty values in it.

You have to view hidden systemfiles to find:

C:\Users\UserName\AppData\Roaming\Microsoft\Virtual PC\Options.Xml

find the console section and you will find that the layout parameters are way off, like max(int). Change the left/right etc to 10 or something similar and the window will pop back to the desktop. You must close all VPC:s and console to be able to save the options file.

All creds go to the following blogger,

SJ's Blog

// Lazze

Tuesday, September 25, 2007

Data controls ASP NET 2

When working with the data controls in ASP NET 2 - like GridView and DetailsView you are always best of if you use templated columns. The simplest way to acomplish this is to start of with DataBound fields then just right click them and choose "Convert to template field.

There are two major reasons for using templated fields:

1. You get predictable names, like CTL_MyView_TemplatefieldName - which is good if you need to access them via Javascript.

2. From code behind you can get your fields like this:

TextBox t = (TextBox) ((DetailsView)sender).FindControl("tbStatusDetailTemplate");

// Lazze

Sunday, September 09, 2007

Application Wide(Windows Forms) - capture Keys(like functions keys)

1) Define constants

const int WM_KEYDOWN = 0x100;
const int WM_KEYUP = 0x101;

2) Add interface, IMessageFilter

public partial class Form1 : Form, IMessageFilter

3) Make message interceptor

public bool PreFilterMessage(ref Message m)
{
Keys keyCode = (Keys)(int)m.WParam & Keys.KeyCode;
if (m.Msg == WM_KEYDOWN && keyCode == Keys.F8) // We'll just handle F8 here
{

MessageBox.Show("Key: " keyCode.ToString());
return true;
}
return false;
}

4) Add message interceptor to forms message handling(in Forms constructor)

Application.AddMessageFilter(this);

Enjoy!

//Lazze

Wednesday, June 13, 2007

Loop through splitcontainer in Winforms

Control ctl = splitContainer1.GetNextControl(splitContainer1 , true);
while (ctl != null)
{
//Do something with ctl
ctl = splitContainer1.GetNextControl(ctl, true); }
}

Tuesday, June 12, 2007

ICO PNG

Want some flashy icons on your desk?

This nifty program converts PNG -> ICO or ICO -> PNG

100% free!

Get it here!

Sunday, June 03, 2007

WCF

This gave me some headace:

netsh http add urlacl url=http://+:8000/ServiceModelSamples/service/ user=lsiden

You have to run the above command(Vista) to grant HTTP on URL xxx for user XXX before you can start a WCF-server.

If you use DualHTTP you have to open the firewall for the incoming requests from the client.

Read more:

Here

and here

Sunday, May 13, 2007

Directory.GetDirectories without getting Unauthorized errors

foreach (string dir in Directory.GetDirectories(@"c:\"))
{
DirectoryInfo di = new DirectoryInfo(dir);
if ((di.Attributes & FileAttributes.System) == 0)
dirList.Add(dir);
}

DirectoryInfo.Attributes is a Flag enum list so you can't just check for equality. Using the above code makes it more or less safe :-)

Lazzes Smart Home - 2023

Here is an overview of the components in the Smart Home as of now. More stuff than I tought :-)