Docking Window problem




This is a function in the free magic library from Crownwood.

My problem is that I can not move windows to the second monitor. Here is the
function where I think with the problem ( 'IntPtr hDC = User32.GetDC
(IntPtr.Zero);'). The function uses the User32.dll. How con I coding for
multiple monitor?

public static void DrawDragRectangles(Rectangle[] newRects, int indent)


if (newRects.Length > 0)


// Create the first region

IntPtr newRegion = CreateRectangleRegion(newRects[0],

for(int index=1; index<newRects.Length; index++)


// Create the extra region

IntPtr extraRegion =
CreateRectangleRegion(newRects[index], indent);

// Remove the intersection of the existing and extra

Gdi32.CombineRgn(newRegion, newRegion, extraRegion,

// Remove unwanted intermediate objects



// Get hold of the DC for the desktop

IntPtr hDC = User32.GetDC(IntPtr.Zero);

// Define the area we are allowed to draw into

Gdi32.SelectClipRgn(hDC, newRegion);

Win32.RECT rectBox = new Win32.RECT();

// Get the smallest rectangle that encloses region

Gdi32.GetClipBox(hDC, ref rectBox);

IntPtr brushHandler = GetHalfToneBrush();

// Select brush into the device context

IntPtr oldHandle = Gdi32.SelectObject(hDC, brushHandler);

// Blit to screen using provided pattern brush and invert
with existing screen contents



rectBox.right - rectBox.left,

rectBox.bottom -,


// Put old handle back again

Gdi32.SelectObject(hDC, oldHandle);

// Reset the clipping region

Gdi32.SelectClipRgn(hDC, IntPtr.Zero);

// Remove unwanted region object


// Must remember to release the HDC resource!

User32.ReleaseDC(IntPtr.Zero, hDC);



Niki Estner

Quote from MSDN, documentation of CreateDC:
"Windows 2000 and later: If there are multiple monitors on the system,
calling CreateDC(TEXT("DISPLAY"),NULL,NULL,NULL) will create a DC covering
all the monitors. "

If I got you right, this could be what you need.


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question