Strange... One of 3 things is probably happening: either your location/size input parameters aren't right, or there is some interference with the regular windows drawing routine, where your rectangles are overwritten when the screen redraws itself (or portions of itself), or your draw method never get's called.
I attached a small sample application that draws semitransparent rectangles on random screen locations. Note that when you hover your mouse over some parts of the window (like minimize/maximize buttons), a part of the screen get's redrawn. You can even induce the invalidation of the entire screen area.
The gist of the sample is simple, the code below:
Code:
private void m_btnDraw_Click(object sender, EventArgs e)
{
var g = Graphics.FromHwnd(IntPtr.Zero);
int screenWidth = Screen.GetWorkingArea(this).Width;
int screenHeight = Screen.GetWorkingArea(this).Height;
int boxSize = 100;
Brush brsh = new SolidBrush(Color.FromArgb(128, m_rnd.Next(256), m_rnd.Next(256), m_rnd.Next(256)));
g.FillRectangle(brsh,
m_rnd.Next(screenWidth - boxSize),
m_rnd.Next(screenHeight - boxSize),
boxSize,
boxSize
);
brsh.Dispose();
g.Dispose();
}
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.